Home > Mobile >  Is every API created with Django Rest Framework an REST API?
Is every API created with Django Rest Framework an REST API?

Time:12-31

I just wonder if the fact that the API is created with DRF means it is really an Rest Api? Or is there something important to remember in order to make it truly REST?

When I communicate with endpoints, I send JWT in requests, so I believe it makes it Stateless. Naming conventions for rest endpoints are probably important too. But is there anything else to remember so I could call my Api a Rest Api?

CodePudding user response:

I am quoting from https://www.redhat.com/en/topics/api/what-is-a-rest-api:

" In order for an API to be considered RESTful, it has to conform to these criteria:

  • A client-server architecture made up of clients, servers, and resources, with requests managed through HTTP.
  • Stateless client-server communication, meaning no client information is stored between get requests and each request is separate and unconnected.
  • Cacheable data that streamlines client-server interactions.
  • A uniform interface between components so that information is transferred in a standard form. This requires that:
    • resources requested are identifiable and separate from the representations sent to the client.
    • resources can be manipulated by the client via the representation they receive because the representation contains enough information to do so. self-descriptive messages returned to the client have enough information to describe how the client should process it.
    • hypertext/hypermedia is available, meaning that after accessing a resource the client should be able to use hyperlinks to find all other currently available actions they can take.
  • A layered system that organizes each type of server (those responsible for security, load-balancing, etc.) involved the retrieval of requested information into hierarchies, invisible to the client.
  • Code-on-demand (optional): the ability to send executable code from the server to the client when requested, extending client functionality. "

Roy Fielding have a very detailed answer (from 2008) on what should not be called a REST API here https://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven.

The last and maybe most important thing for your answer is the DRF own answer to your question that you can find here:

https://www.django-rest-framework.org/topics/rest-hypermedia-hateoas/#building-hypermedia-apis-with-rest-framework

Where they state clearly that DRF is a web api toolkit that will help guide you to build a Hypermedia API but does not enforce it.

  • Related