Skip to content

Instantly share code, notes, and snippets.

@kn9ts
Created November 22, 2016 21:25
Show Gist options
  • Save kn9ts/54a353de3b8e3d85968db7f4cfdfc84c to your computer and use it in GitHub Desktop.
Save kn9ts/54a353de3b8e3d85968db7f4cfdfc84c to your computer and use it in GitHub Desktop.
Example of a REST API convention
GET /persons [All persons data in a list]
{
success: true,
response: [personObject, personObject, personObject, personObject...]
}
GET /persons/1575 [returns a single person]
{
success: true,
response: {
name: 'Eugene',
age: 27,
location: 'NY for now'
...
} // personObject
}
POST /persons [adds a new single person]
{
success: true,
response: personObject (with created_at timestamp of actual create time)
}
PATCH/PUT /persons/1575
{
success: true,
response: personUpdatedObject (with modified_at timestamp of actual update time)
}
DELETE /persons/1575
{
success: true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment