Skip to content

Instantly share code, notes, and snippets.

@hoitomt
Created June 5, 2017 15:26
Show Gist options
  • Save hoitomt/242b101c07443d8a2d677d041c34087d to your computer and use it in GitHub Desktop.
Save hoitomt/242b101c07443d8a2d677d041c34087d to your computer and use it in GitHub Desktop.
API Best Practices Notes

Source: http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api

  • Use SSL
  • Do not redirect from non-SSL to SSL (encourages clients to keep doing it)
  • Version in the URL (At least major)
  • Unary attribute (+/-) in sort params to indicate direction of sort
  • Provide way for user to specify return fields
  • snake_case is easier to read (Even though it is not the standard way to define variables in Javascript: CamelCase)
  • pretty print by default (responses are slightly larger). Over-arching concept is that an API should also be human-readable
  • Support .gz compression, if not default to it. Much faster API
  • Accept json bodies for POST, PATCH, PUT
  • Add pagination info to the header (RFF 5988)
  • Add rate limit information to the header
  • API should be stateless - no cookies or sessions for authentication
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment