Skip to content

Instantly share code, notes, and snippets.

@imikay
Created April 4, 2012 12:05
Show Gist options
  • Save imikay/2300688 to your computer and use it in GitHub Desktop.
Save imikay/2300688 to your computer and use it in GitHub Desktop.
API design
The data returned from an API should have a similar structure like the following:
Success:
{status: 1, data: [A collection of data]}
Error:
{status: 0, error: { code: 1, message: 'critical error' }}
And the data returned must always have a consistent structure, for example, an image API
should always return a data structure like this: {title: A fancy image, link: http://www.example.com},
the title and link property must always present in the data, no matter whether they have a value or not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment