REST_Url_Conventions..

Shanira Perera
3 min readAug 31, 2022

--

What is REST & Naming Guide

Hi everyone Welcome again for a another Techie Talk…

Today im going to talking about the REST and its Naming Structure. Lets go to the rest.

What is REST?

First let’s know the abbreviation of the rest REpresentational State Transfer. and an architectural style for distributed hypermedia systems. REST has its guiding principles and constraints, if a service interface needs to be referred to as Restful it must be fulfill these principles.

REST Principles

  1. Uniform interface
  2. Client–server
  3. Stateless
  4. Cacheable
  5. Layered system
  6. Code on demand (optional)

So now let’s see how to design the rest full URLs.

image by Author via URL_Anatomy

Represent Hierarchical relationships by “/”

If we have a hierarchical type relation like,

Product_category > Subcategory > product.

in this case we have one product_category and it has multiple subcategories and that sub category have multiple products so if we found these kind of hierarchical relations its better to use Slash “/” .

Hierarchical relationships

Use Plural nouns when required

When you dealing with collections its better to represent it on your URL. As an example Organization has too many departments. so that we use “departments” rather than “department” to Indicate the plural.

Use Plural nouns

Design to improve readability

Always ensure that the writing is easy for the reader to read. As an example see this,

improve readability

The former is quite difficult to read while the latter is relatively easy to read. This one called improving the readability.

Do not use any file extensions like .html .asp .js …. because we are dealing with resources not the web pages.

Use Query parameters for filtering

When we need to filter a query we write it with this format

?Name of the parameter = Value of the parameter

As a example we need employee name saman → ?Employee=saman

Query parameters

Do not used CRUD operations to URLs

Using CRUD operations to rest naming is not a good practice so write url with adding the CRUD operator as a request not in the URL part refer below,

Do not use CRUD Operations

--

--

Shanira Perera
Shanira Perera

Written by Shanira Perera

Hello, I’m Shanira, welcome to the world of technology. I am an Associate software engineer at virtusa. So let’s begin!