wfortin / rest

RESTful API cheat sheet

Home Page:http://wfortin.github.io/rest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rest

RESTful API cheat sheet

GET /users


Collection of resource
Represented as an array

Possible status codes

Use 200 OK when the collection exists


### `GET` /users/:id --- Single resource by id #### Possible status codes Use `200 OK` when the resource exists
Use `404 Not found` when the resource with id :id does not exist
### `POST` /users --- Create a resource
Return the URI to the newly created resource in `Location` header #### Possible status codes Use `201 Created` when the resource was created successfully - Body includes the full resource with id
Use `400 Bad Request` when the resource is missing some parameters or has invalid values
### `PUT` /users/:id --- Update the resource
Create a resource with a specific id #### Possible status codes Use `200 OK` when returning the updated resource
Use `201 Created` when the resource is created with a specific id
Use `204 No content` when no data is returned in the body
Use `400 Bad Request` when he resource is missing some parameters or has invalid values

### `PATCH` /users/:id --- > `PATCH` should be used when partialy updating the resource.
> We dont use `PATCH` since some browsers, REST clients and proxys do not correctly support `PATCH`
### `DELETE` /users --- Delete the collection
Probably should not be implemented ### `DELETE` /users/:id --- Delete the resource #### Possible status codes Use `204 No content` when the delete is synchronous and successful
Use `202 Accepted` when the delete will be asynchronous and the resource has been flagged as deleted but is not yet deleted
Use `200 OK` when returning information about the deleted resource
Use `404 Not found` when the resource with id :id does not exist

Can't find your use case ?

For more sophisticated use cases refer to : MDN HTTP Response Code

About

RESTful API cheat sheet

http://wfortin.github.io/rest/