Menu
Home
Log in / Register
 
Home arrow Computer Science arrow Building Applications with Scala
Source

REST API design

When you are working with REST, there are some principles that you should keep in mind, and these principles should provide guidance for your design choices when you are doing API design.

HTTP verbs design

These are the following verbs found in HTTP:

  • • GET: This is often used to answer queries
  • • PUT: This is often used to insert data
  • post: This is often used to update data
  • • DELETE: This is often used to remove data

Why do we keep saying often? Well, there are some exceptions in regards of size limitations. For instance, for the get verb, we can't have a request bigger than 8192 bytes or 8 KB. If you need to send a bigger payload, we will need to use the post verb.

Design Your REST API

Uniform API

REST uses a uniform API. For example, consider the following piece of code:

GET /users/1 = List information about user id 1

PUT /users/1 = Insert user 1

POST /users/1 = Update user 1

DELETE /users/1 = Delete user 1

GET /users/ = Lists All users

If we change the resource from users to sales, the API would almost be the same. Retrieving data is done using get and update is done via POST, so it's a uniform API.

 
Source
Found a mistake? Please highlight the word and press Shift + Enter  
< Prev   CONTENTS   Next >
 
Subjects
Accounting
Business & Finance
Communication
Computer Science
Economics
Education
Engineering
Environment
Geography
Health
History
Language & Literature
Law
Management
Marketing
Mathematics
Political science
Philosophy
Psychology
Religion
Sociology
Travel