Sitemap
Maneesha Nirman

Maneesha Nirman

Techie at Virtusa | Python, Java & Azure | Exploring AI & automation | Sharing real-world dev tips & HCM insights | Building smarter systems daily

REST URL Conventions

4 min readAug 30, 2022

--

The Internet is now spread all over the world. Even vehicles are also connected to the internet.

What is REST?

REST stands for Representational state transfer. REST is an architectural style for providing standards between computer systems on the web, making it easier for systems to communicate with each other.

REST Uses,

HTTP/ HTTPS as a transfer protocol.

It used Resource Oriented Architecture (ROA). It means resources will be at the center of the communication. and also REST uses client-server as a communication methodology.

REST is Stateless.

In REST, the server doesn’t store any client-related information. So all the requests are independent of each other.

There are two things rest communication flow,

  1. Request
  2. Response

Request consists,

  • URI
  • HTTP Method
  • Header
  • Request Body

Response Consists,

  • Request Body
  • Request Response Code

The above points will help you to refresh your knowledge about REST.

What is a URL?

URL stands for Uniform Resource Locator. It is a reference to a resource on the internet.

URL must be readable for users. A good URL must include,

  • uniformity
  • easy to understand
  • easy adoption across the enterprise.

URL made up with,

  1. scheme — The scheme represents the protocol used by REST. There are 2 types,
  • HTTP
  • HTTPS

2. domain — Domain represents the domain name or IP address (IPv4) of the host that serves the API.

Get Maneesha Nirman’s stories in your inbox

Join Medium for free to get updates from this writer.

3. path — path specify a prefix for all API paths.

4. query string (This is optional)

There are some standards to generate REST URL.

  • Use “/” to represent hierarchical relationships.

In course type, there are many subject types. in a subject, type includes many courses.

  • Use plural nouns when required

students have to pay for university. This is how to check students' payment history. This indicates student there are many payments done by each student.

  • Use “-” (Hyphen) in the URL in possible. Avoid using “_” (underscore).
  • Use query strings for data filtering.
Press enter or click to view image in full size

Here I used query as “?subject_code=250255” to filter students who study on the subject related to the 250255 subject code.

Use URL without CRUD operations.

CRUD stands for,

  • c — create
  • r — read
  • u — update
  • d — delete

You should use nouns. Avoid using getData,updateData,deleteData like wise CRUD operation related keywords.

Press enter or click to view image in full size
Avoid from this

Here have been used “getStudents”. Avoid using CRUD-related keywords. Get is one of the CRUD operations.

Do it this way
  • The URL is too long.

There is a standard RFC 7230, and the URL had size limitations. URL can only contain 2048 characters. If the server received more than 2048 characters, it returns a 414 status code which means the URL is too long an exception. Most of the time this issue happens with GET method.

  • Avoid using file extensions.

Avoid using file extensions in URL like .HTML, .jpg, .png, .asp. etc…

Follow those tips when you naming conventions for naming REST services.

See you in the next chapter….

--

--

Maneesha Nirman
Maneesha Nirman

Written by Maneesha Nirman

Techie at Virtusa | Python, Java & Azure | Exploring AI & automation | Sharing real-world dev tips & HCM insights | Building smarter systems daily