Skip to content
Patrick José Pereira edited this page Feb 4, 2022 · 6 revisions

Endpoint style

An endpoint and payload variables should follow the snake_case convention. The languages and code style used in the project already follows this convention.

Delete

A delete endpoint should only accept the method DELETE and follow the format:

/delete_something/{something_id}

Where something_id is an unique identifier.

How to ensure a good API design

  • Use the proper return code, E.g: Ok, NotFound, NotAcceptable and etc.
  • Ensure that the content type is correct: application/json, text/plain, text/xml and etc.
  • Register the endpoint with the correct methods:
    • Removing something or deleting should only accept DELETE method.
    • Adding or registering something new should only accept POST
    • An informative endpoint should only accept GET.
  • If an endpoint deletes or adds something, it should return as payload the new content.

Backup

Every service should provide a /backup endpoint, used for saving and loading settings externally. This endpoint should accept at least a GET and a POST route, for saving and loading, respectively. The GET endpoint should respond with a JSON formatted string that, when sent to the POST route, should be loaded without modifications.