Learn REST APIs

In this thread, we will talk about HTTP methods, principles of REST APIs, security, and versioning.

πŸ§΅πŸ‘‡πŸ»
The abbreviation REST stands for "REpresentational State Transfer".

REST APIs operate on a simple request/response system. You can send a request using these HTTP methods:
HTTP has a fixed number of methods that the client can use to indicate what type of operation it wants to perform via the request.

πŸ”Ή GET
πŸ”Ή POST
πŸ”Ή PUT
πŸ”Ή PATCH
πŸ”Ή DELETE
πŸ”Ή HEAD
πŸ”Ή TRACE
πŸ”Ή OPTIONS
πŸ”Ή CONNECT
If an HTTP method doesn’t alter the server's state apart from logging, it is called a safe method.

GET, HEAD, or OPTIONS methods are safe methods.
It is important to note that all the safe HTTP methods are also idempotent, but not all idempotent HTTP methods are safe.
When multiple calls of an HTTP method yield the same result and leave the server in the same state, then the HTTP method is called idempotent.

When implemented correctly, the GET, HEAD, PUT, and DELETE methods are all idempotent, but not the POST method.
It's possible to cache the response and use it later.

β—Ύ GET, and HEAD methods are cacheable.
β—Ύ POST and PATCH methods are also cacheable if the Content-Location header is set.
β—Ύ The 200, 203, 204, 206, 300, 301, 404, 405, 410, 414, and 501 status codes are cacheable.
πŸ“Œ REST APIs follows six design principles which are as follows: πŸ‘‡πŸ»
1️⃣ Client-server Separation

In a RESTful API, the client and server are always kept independent, ensuring that both the client and the server can be scaled independently.
2️⃣ Stateless

Servers aren’t allowed to store any data related to the client. No session or authentication state is stored on the server.

If the client requires authentication, then the client needs to authenticate itself before sending a request to the server.
3️⃣ Cacheable

Responses can be explicitly or implicitly defined as cacheable or non-cacheable to improve scalability and performance.

The main idea of caching is to improve the performance of the client by reducing the bandwidth required to load the resource.
4️⃣ Layered System

It isn’t always necessarily true that the client connects directly to the server and requests a resource. There can be multiple systems in between them that are responsible for handling security, traffic, balancing the load, redirection, etc.
5️⃣ Uniform Interface

The client and server can interact with each other in a single language irrespective of the architecture that they are based upon.
6️⃣ Code on Demand (optional)

When a client requests a resource, the server can return executables as a part of the response. This is an optional constraint.

In some instances, this might help reduce the amount of code that has to be written on the client.
πŸ“Œ Security

We can use Content Security Policy (CSP) to provide an extra layer of security over various issues like XSS and data injection.
Using CSP, it is possible to limit the amount of data sources that a web application can load. This is done by properly configuring the CSP headers. Content-Security-Policy:  < policy-directive >;   < policy-d
CSP can prevent errors that occur due to unsigned inline JavaScript and CSS style tags as well as JavaScript code using eval().
πŸ“Œ Versioning

There are three different types of versioning strategies: πŸ‘‡πŸ»
1️⃣ URI versioning

This is the most common versioning strategy, although it violates every URI should contain a unique resource. When a URI version is done, all the resources get updated to a new version. https://website.com/api/v1/users https://website.com/api/v2/
2️⃣ Query parameters versioning

This strategy states the version of an API by using query parameters. An example of this kind of strategy can be the following: πŸ‘‡πŸ» https://website.com/users?version=1
3️⃣ Custom headers versioning

Versioning can also be done by passing custom request headers. An example will be the following: curl -H "accept-version: 1" https://website.com/us
Visit RapidAPI Learn (RapidAPI.com/learn/rest-api…) to play around with interactive components and build a strong understanding of REST APIs.
With that being said, this is the end of this thread.

We recommend you head over to RapidAPI Hub (RapidAPI.com/hub?utm_source…) to access more than 35,000 APIs. πŸ’™πŸ˜‰

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with RapidAPI

RapidAPI Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Rapid_API

2 Dec
GraphQL Schema Stitching

Let’s take a look at one of the practices that are widely adopted when working with GraphQL.

Thread πŸ§΅πŸ‘‡πŸ»
GraphQL Schema Stitching is the process of creating a single GraphQL schema from multiple underlying GraphQL APIs.

You can use two or more GraphQL schemas and merge them into one endpoint to get data from all the underlying schemas.
It provides you with a unified API that you can use to query multiple GraphQL schemas simultaneously.

You can also use it to customize an existing GraphQL API.
Read 8 tweets
1 Dec
Top five Visual Recognition APIs you can use to build excellent web applications.

Thread πŸ§΅πŸ‘‡πŸ»
1️⃣ Face Detection

Face Detection API helps you detect the location of human faces in your images with optional extra features like Age and Gender.

πŸ”— RapidAPI.com/inferdo/api/fa…

πŸ“ˆ Popularity: 9.7/10
πŸ•› Latency: 1,149ms
βœ… Service Level: 100%
2️⃣ Brand Recognition

This ready-to-use API provides high-accuracy brand detection and logo recognition.

πŸ”— RapidAPI.com/api4ai-api4ai-…

πŸ“ˆ Popularity: 8.6/10
πŸ•› Latency: 911ms
βœ… Service Level: 100%
Read 7 tweets
30 Nov
A complete introduction to GraphQL

GraphQL is a query language that lets your client request the server to send only the required data.

Let's deep dive into it. πŸ§΅πŸ‘‡πŸ»
GraphQL was created by developers at Facebook in 2012.

GraphQL was developed to support the complicated data structures required to show the Facebook News Feed on the mobile application.
Using GraphQL, the client can request the necessary data using a single endpoint with a defined schema.
Read 17 tweets
29 Nov
A complete introduction to RPC and gRPC

Microservices are usually written in different languages, making it challenging to manage them and exchange information.

Here gRPC comes into play.

Thread πŸ§΅πŸ‘‡πŸ»
Before jumping onto gRPC, we need to understand what RPC is πŸ‘‡πŸ»
πŸ“Œ RPC

RPC stands for Remote Procedure Call, and it's a client-server communication method in use today.

In typical HTTP, the client makes a request and gets a response from the server.
Read 9 tweets
26 Nov
There are different kinds of specifications available that you can use while building an API.

In this thread, we will talk about the OpenAPI spec.

🧡 πŸ‘‡πŸ»
In simple terms, OpenAPI spec is a format to define structure and syntax for REST APIs.
OpenAPI spec provides a standard that allows both humans and computers to discover and understand the service's capabilities without access to source code, documentation, or traffic inspection
Read 13 tweets
25 Nov
CORS can be tackled quickly with the understanding of a few HTTP headers.

Let's discuss them in a bit more detail. πŸ§΅πŸ‘‡πŸ»
We are going to cover HTTP request headers first, and then we will jump onto HTTP response headers.
πŸ“Œ HTTP Request Headers

The client can use a few HTTP request methods with their API calls in order to make maximum use of the Cross-Origin resource sharing feature.
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(