JasonDavis
JasonDavis

Reputation: 48933

REST API Server

I often hear or read the term REST API Server.

I code with PHP and I have done API's for my projects in the past which could return data in XML and JSON formats, and they were in the form of REST where you would do something like

server.com/comments/123 To return/view a comment with ID 123
server.com/comments/post to post a comment
server.com/comments/123/edit to edit comment with ID 123
server.com/comments/123/delete to delete comment with ID 123

Now I would not consider this a REST server but I do think it is REST?

Could someone clarify or explain if I am wrong? I mean is there more to a REST server and it is simply a term used or is a REST server completely different then the functionality I described above?

I have a project coming up soon which will need a RESTful API so I would like to make sure I am doing it correctly.

Upvotes: 5

Views: 21720

Answers (2)

Johnathan Kanarek
Johnathan Kanarek

Reputation: 854

I think the REST standard is wide and although you don't implement custom HTTP methods, your web service could be considered as REST server. Personally I don't think that using custom HTTP methods is always wise, many firewalls don't like it. I would implement the action (CREATE / DELETE / UPDATE) as part of the path or as part of the POST data (probably as JSON property).

See more of my recommended guideline here: http://restafar.com/create-new-rest-server/

Upvotes: 0

EJK
EJK

Reputation: 12527

A similar question came up recently: What are RESTful Web Services. Give this a read.

Plus there is a ton of REST information on the web. Here is one of the better overviews I have seen: http://www.xfront.com/REST-Web-Services.html.

In short, your service is not RESTful, but it is close. Rather than specify actions (edit, delete, ...) in URL segments, you will want to make use of HTTP verbs (GET, PUT, POST, DELETE). These details are discussed in the provided links.

Upvotes: 10

Related Questions