0% found this document useful (0 votes)
2 views10 pages

Rest API Design

The document outlines key principles for REST API design, emphasizing the use of nouns for resource naming and logical grouping of resources. It introduces HATEOAS for dynamic navigation through hypermedia links and recommends using pluralized nouns and hyphens for improved readability in URLs. Additionally, it discusses the importance of versioning, filtering, sorting, and pagination in API responses.

Uploaded by

vijay kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views10 pages

Rest API Design

The document outlines key principles for REST API design, emphasizing the use of nouns for resource naming and logical grouping of resources. It introduces HATEOAS for dynamic navigation through hypermedia links and recommends using pluralized nouns and hyphens for improved readability in URLs. Additionally, it discusses the importance of versioning, filtering, sorting, and pagination in API responses.

Uploaded by

vijay kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Rest API Design

Important aspects of API design:

 Naming: Use Nouns to represents resources not verbs.

Eg:

Leverage logical grouping:

Customer Orders:
Avoid DB structuring or any hints in the resource URL that allows attackers to idea of something.

Order back to the customer:

{99} is Order ID

Implementing this can become cumbersome. A better solution is to provide navigable links to
associated resources.

Solution is HATEOAS: The term hypermedia refers to any content that contains links to other forms of
media such as other APIs, images, movies, and text. In HATEOAS, we insert the hypermedia links in
the API response contents.

These hypermedia links allow the client to dynamically navigate to the appropriate resources by
traversing the links.

Use pluralized nouns for resources:


Collection is a Group of Resources:

For eg:

/orders is a group of collection

/orders/234 is a resource with a specific information about specific order.

Don’t go or design Deeper collections.

“collection/resource/collection”

Use Hyphens to increase the readability of the url:

For eg:
Inventory-management/

Don’t change anything on existing Rest endpoint or in existing API response as many people uses it.
Have a version number in the URL such as.

Alternatively, rather than providing multiple versions in the URL we can also send the version as a
parameter.

Filtering, Sorting and pagination:

Generally, REST Apis fetch data from Databases so don’t think to fetch all the data at once.

Ways to filter items:

With specific key and value

Pagination:
A HEAD request is similar to the GET request but the HEAD request returns Headers of the response
with 200 status.

You might also like