Feedzai Techblog
Published in

Feedzai Techblog

REST API Guidelines at Feedzai

Bread and butter (by Whitney Wright)

Naming

  • Use camelCase — camelCase has the advantage that it can also be used as variable names and is more easily readable than lowercase.
  • Write resource names in plural (e.g., plans).

Examples of what to do 👍

  • GET /api/users/:id/deletedRepositories/:id
  • GET /api/blogs/:id/visitorStatistics

Examples of what not to do 👎

  • GET /api/users/:id/deletedrepositories/:id
  • GET /api/blogs/:id/visitor_statistics

Use Simple Nouns and Avoid Verbs

  • Use simple nouns and avoid long chains of words.
  • Avoid verbs and instead use the semantics of the HTTP methods.

Examples of what to do 👍

  • GET /api/users
  • POST /api/blogs/:id/drafts

Examples of what not to do 👎

  • GET /api/users/:id/repository/:id/repositoryAbreviatedHistoryListPaged
  • POST /api/blogs/createDraft

Think of the REST API, not only the Back-End API

Respect the Semantic of the HTTP Methods

Return Codes

2xx codes should be used for successful operations

  • 200 for successful requests that have a response
  • 204 for successful requests that do not have a response

3xx codes should be used for redirects

4xx codes should be used for handled errors

  • 400 for requests that contain errors such as validation errors or invalid input errors
  • 401 for requests that are not authorised
  • 403 for requests that are trying to access a resource for which they do not have permissions (but that they can know it exists)
  • 404 for requests that contain an id that points to a resource that no longer exist (and for similar errors)

5xx codes should be used for unhandled errors

  • 500 for unhandled errors (sent only by a catch all handler)

Always Use JSON

Keep Relevant Stakeholders in the Loop

Documentation

Returning Errors

[{    error: <ERROR_CODE>,    parameters: [<STRING>]}, {    ...}, {    ...}]
[{    error: 12,    parameters: ["gs62hhsdd"]}]

Wrapping Up

--

--

Welcome to Feedzai Techblog, a compilation of tales on how we fight villainous villains through data science, AI and engineering.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store