Questions tagged [rest]

REST (Representational State Transfer) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. It has increased in popularity relative to RPC architectures such as SOAP due to the intrinsic de-coupling of client from server that comes from having a uniform interface between heterogeneous systems.

(Not to be confused with or reST)

REST (REpresentational State Transfer) is an architectural style that uses identification of resources; manipulation of resources through representations; self-descriptive messages, and hypermedia as the engine of application state, to build distributed systems that are scalable and resilient to change.

The term was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation. Fielding is one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification versions 1.0 and 1.1.

In simple language, REST is an alternative to SOAP based web services. Where SOAP tries to model the exchange between client and server as calls to objects, REST tries to be faithful to the web domain.

Resources


Examples

A website's RESTful API is queried to find out information on a user, specified by a numerical ID.

Request Type: GET
http://www.api.website.com/users/12345

Returns, in a format for this example:

{"username" : "theuser",
 "userid"   :  12345,
 "first"    : "George",
 "last"     : "Washington"}

Question Index

Searching

REST search interface and the idempotency of GET
RESTful URL design for search
Best practice for implementing long-running searches with REST
Querystring in REST Resource url
What is the best way to create RESTful complex queries?
Question on REST conventions: retrieving information where lots of params are needed

Resource Design

How to design a RESTful collection resource?
RESTful design of a resource with binary states
RESTFful/Resource Oriented Design
RESTful resource - accepts a list of objects
RESTful API creates a globally unique resource
REST's 'resource communication mechanisms' and 'on-the-fly' improvement of a client's knowledge of them
How to move a REST resource?

Media Types

REST Media type explosion
Creating hypermedia links in a custom media-type
Custom content types: XLink vs. Atom

Books

Related tags

92665 questions
222
votes
8 answers

Is REST DELETE really idempotent?

DELETE is supposed to be idempotent. If I DELETE http://example.com/account/123 it's going to delete the account. If I do it again would I expect a 404, since the account no longer exists? What if I attempt to DELETE an account that has never…
Ben Noland
  • 34,230
  • 18
  • 50
  • 51
221
votes
10 answers

Are there any naming convention guidelines for REST APIs?

When creating REST APIs, are there any guidelines or defacto standards for naming conventions within the API (eg: URL endpoint path components, querystring parameters)? Are camel caps the norm, or underscores? others? For…
jnorris
  • 6,350
  • 8
  • 30
  • 33
219
votes
8 answers

Which HTTP status code means "Not Ready Yet, Try Again Later"?

I'm developing a RESTful API in which http://server/thingyapi/thingyblob/1234 returns the file (aka "blob") associated with item #1234 to download. But the request could be made before the file has been generated. It definitely will be available at…
JCCyC
  • 16,140
  • 11
  • 48
  • 75
219
votes
4 answers

Rails new vs create

Why is there a need to define a new method in RESTful controller, follow it up with a create method? Google search didn't provide me the answer I was looking for. I understand the difference, but need to know why they are used the way they are.
sent-hil
  • 18,635
  • 16
  • 56
  • 74
218
votes
15 answers

How to make remote REST call inside Node.js? any CURL?

In Node.js, other than using child process to make CURL call, is there a way to make CURL call to remote server REST API and get the return data? I also need to set up the request header to the remote REST call, and also query string as well in GET…
murvinlai
  • 48,919
  • 52
  • 129
  • 177
216
votes
11 answers

Django REST Framework: adding additional field to ModelSerializer

I want to serialize a model, but want to include an additional field that requires doing some database lookups on the model instance to be serialized: class FooSerializer(serializers.ModelSerializer): my_field = ... # result of some database…
Neil
  • 7,042
  • 9
  • 43
  • 78
216
votes
6 answers

How to implement a secure REST API with node.js

I start planning a REST API with node.js ,express and mongodb. The API provides data for a website (public and private area) and maybe later a mobile app. The frontend will be developed with AngularJS. For some days I read a lot about securing REST…
tschiela
  • 5,231
  • 4
  • 28
  • 35
213
votes
4 answers

Status code when deleting a resource using HTTP DELETE for the second time

Given that the DELETE verb in HTTP is idempotent, when I issue the following request, what should happen the second (or third, or fourth, etc...) time I make it? DELETE /person/123 The first time, the resource is deleted and I return a 204…
Craig Wilson
  • 12,174
  • 3
  • 41
  • 45
211
votes
10 answers

With Spring can I make an optional path variable?

With Spring 3.0, can I have an optional path variable? For example @RequestMapping(value = "/json/{type}", method = RequestMethod.GET) public @ResponseBody TestBean testAjax( HttpServletRequest req, @PathVariable String type, …
Shamik
  • 6,938
  • 11
  • 55
  • 72
209
votes
9 answers

ReferenceError: describe is not defined NodeJs

I am trying to define some endpoints and do a test using nodejs. In server.js I have: var express = require('express'); var func1 = require('./func1.js'); var port = 8080; var server = express(); server.configure(function(){ …
N34
  • 2,153
  • 2
  • 11
  • 7
207
votes
4 answers

REST API - DTOs or not?

I am currently creating a REST-API for a project and have been reading article upon article about best practices. Many seem to be against DTOs and simply just expose the domain model, while others seem to think DTOs (or User Models or whatever you…
benbjo
  • 2,382
  • 3
  • 18
  • 21
206
votes
6 answers

How do I retrieve query parameters in a Spring Boot controller?

I am developing a project using Spring Boot. I've a controller which accepts GET requests. Currently I'm accepting requests to the following kind of URLs: http://localhost:8888/user/data/002 but I want to accept requests using query…
Mehandi Hassan
  • 2,381
  • 4
  • 16
  • 20
206
votes
8 answers

Difference between OData and REST web services

What is the difference between OData and REST-ful web services?
Scott
  • 11,046
  • 10
  • 51
  • 83
201
votes
3 answers

URL matrix parameters vs. query parameters

I'm wondering whether to use matrix or query parameters in my URLs. I found an older discussion to that topic not satisfying. Examples URL with query params: http://some.where/thing?paramA=1¶mB=6542 URL with matrix params:…
deamon
  • 89,107
  • 111
  • 320
  • 448
201
votes
4 answers

Design RESTful query API with a long list of query parameters

I need to design a RESTful query API, that returns a set of objects based on a few filters. The usual HTTP method for this is GET. The only problem is, it can have at least a dozen filters, and if we pass all of them as query parameters, the URL can…
missionE46
  • 2,362
  • 4
  • 19
  • 18