Learn to build large language model applications: vector databases, langchain, fine tuning and prompt engineering. Learn more

As technology advances, we continue to witness the evolution of web development. One of the most important aspects of web development is building web applications that interact with other systems or services.

In this regard, the use of APIs (Application Programming Interfaces) has become increasingly popular. Amongst the different types of APIs, REST API has gained immense popularity due to its simplicity, flexibility, and scalability. In this blog post, we will explore REST API in detail, including its definition, components, benefits, and best practices. 

What is REST API? 

REST (Representational State Transfer) is an architectural style that defines a set of constraints for creating web services. REST API is a type of web service that is designed to interact with resources on the web, such as web pages, files, or other data. In the illustration below, we are showing how different types of applications can access a database using REST API. 

Understanding REST API
Understanding REST API

REST API is a widely used protocol for building web services that provide interoperability between different software applications. Understanding the principles of REST API is important for developers and software engineers who are involved in building modern web applications that require seamless communication and integration with other software components.

By following the principles of REST API, developers can design web services that are scalable, maintainable, and easily accessible to clients across different platforms and devices. Now, we will discuss the fundamental principles of REST API. 

REST API principles:  

  • Client-Server Architecture: REST API is based on the client-server architecture model. The client sends a request to the server, and the server returns a response. This principle helps to certain concerns and promotes loose coupling between the client and server. 
  • Stateless: REST API is stateless, which means that each request from the client to the server should contain all the necessary information to process the request. The server does not maintain any session state between requests. This principle makes the API scalable and reliable. 
  • Cacheability: REST API supports caching of responses to improve performance and reduce server load. The server can set caching headers in the response to indicate whether the response can be cached or not. 
  • Uniform Interface: REST API should have a uniform interface that is consistent across all resources. The uniform interface helps to simplify the API and promotes reusability. 
  • Layered System: REST API should be designed in a layered system architecture, where each layer has a specific role and responsibility. The layered system architecture helps to promote scalability, reliability, and flexibility. 
  • Code on Demand: REST API supports the execution of code on demand. The server can return executable code in the response to the client, which can be executed on the client side. This principle provides flexibility and extensibility to the API. 
REST API principles
REST API principles

Now that we have discussed the fundamental principles of REST API, we can delve into the different methods that are used to interact with web services. Each HTTP method in REST API is designed to perform a specific action on the server resources. 

REST API methods: 

1. GET Method: 

The GET method is used to retrieve a resource from the server. In other words, this method requests data from the server. The GET method is idempotent, which means that multiple identical requests will have the same effect as a single request.  

Example Code:

‘requests’ is a Python library used for making HTTP requests in Python. It allows you to send HTTP/1.1 requests extremely easily. With it, you can add content like headers, form data, multipart files, and parameters via simple Python libraries. 

2. POST Method: 

The POST method is used to create a new resource on the server. In other words, this method sends data to the server to create a new resource. The POST method is not idempotent, which means that multiple identical requests will create multiple resources. 

Example Code:

3. PUT Method: 

The PUT method is used to update an existing resource on the server. In other words, this method sends data to the server to update an existing resource. The PUT method is idempotent, which means that multiple identical requests will have the same effect as a single request. 

Example Code: 

4. DELETE Method: 

The DELETE method is used to delete an existing resource on the server. In other words, this method sends a request to the server to delete a resource. The DELETE method is idempotent, which means that multiple identical requests will have the same effect as a single request. 

Example Code: 

How these methods map to HTTP methods: 

  • GET method maps to the HTTP GET method. 
  • POST method maps to the HTTP POST method. 
  • PUT method maps to the HTTP PUT method. 
  • DELETE method maps to the HTTP DELETE method. 

In addition to the methods discussed above, there are a few other methods that can be used in RESTful APIs, including PATCH, CONNECT, TRACE, and OPTIONS. The PATCH method is used to partially update a resource, while the CONNECT method is used to establish a network connection with a resource.

The TRACE method is used to retrieve diagnostic information about a resource, while the OPTIONS method is used to retrieve the available methods for a resource. Each of these methods serves a specific purpose and can be used in different scenarios. 

To use REST API methods, you must first find the endpoint of the API you want to use. The endpoint is the URL that identifies the resource you want to interact with. Once you have the endpoint, you can use one of the four REST API methods to interact with the resource. 

Understanding the different REST API methods and how they map to HTTP methods is crucial for building successful applications. By using REST API methods, developers can create scalable and flexible applications that can interact with a wide range of resources on the web. 

Best practices for designing RESTful APIs 

RESTful APIs have become a popular choice for building web services because of their simplicity, scalability, and flexibility. However, designing and implementing a RESTful API that meets industry standards and user expectations can be challenging. Here are some best practices that can help you create high-quality and efficient RESTful APIs: 

  1. Follow RESTful principles: RESTful principles include using HTTP methods appropriately (GET, POST, PUT, DELETE), using resource URIs to identify resources, returning proper HTTP status codes, and using hypermedia controls (links) to guide clients through available actions. Adhering to these principles makes your API easy to understand and use. 
  2. Use nouns in URIs: RESTful APIs should use nouns in URIs to represent resources rather than verbs. For example, instead of using “/create_user”, use “/users” to represent a collection of users and “/users/{id}” to represent a specific user. 
  3. Use HTTP methods appropriately: Each HTTP method (GET, POST, PUT, DELETE) should be used for its intended purpose. GET should be used to retrieve resources, POST should be used to create resources, PUT should be used to update resources, and DELETE should be used to delete resources. 
  4. Use proper HTTP status codes: HTTP status codes provide valuable information about the outcome of an API call. Use the appropriate status codes (such as 200, 201, 204, 400, 401, 404, etc.) to indicate the success or failure of the API call. 
  5. Provide consistent response formats: Provide consistent response formats for your API, such as JSON or XML. This makes it easier for clients to parse the response and reduces confusion. 
  6. Use versioning: When making changes to your API, use versioning to ensure backwards compatibility. For example, use “/v1/users” instead of “/users” to represent the first version of the API.
  7. Document your API: Documenting your API is critical to ensure that users understand how to use it. Include details about the API, its resources, parameters, response formats, endpoints, error codes, and authentication mechanisms.
  8. Implement security: Security is crucial for protecting your API and user data. Implement proper authentication and authorization mechanisms, such as OAuth2, to ensure that only authorized users can access your API. 
  9. Optimize performance: Optimize your API’s performance by implementing caching, pagination, and compression techniques. Use appropriate HTTP headers and compression techniques to reduce the size of your responses. 
  10. Test and monitor your API: Test your API thoroughly to ensure that it meets user requirements and performance expectations. Monitor your API’s performance using metrics such as response times, error rates, and throughput, and use this data to improve the quality of your API. 


In the previous sections, we have discussed the fundamental principles of REST API, the different methods used to interact with web services, and best practices for designing and implementing RESTful web services. Now, we will examine the role of REST API in a microservices architecture. 

The role of REST APIs in a microservices architecture 

Microservices architecture is an architectural style that structures an application as a collection of small, independent, and loosely coupled services, each running in its process and communicating with each other through APIs. RESTful APIs play a critical role in the communication between microservices. 

Here are some ways in which RESTful APIs are used in a microservices architecture: 

1. Service-to-Service Communication:

In a microservices architecture, each service is responsible for a specific business capability, such as user management, payment processing, or order fulfillment. RESTful APIs are used to allow these services to communicate with each other. Each service exposes its API, and other services can consume it by making HTTP requests to the API endpoint. This decouples services from each other and allows them to evolve independently. 

2. Loose Coupling:

RESTful APIs enable loose coupling between services in a microservice architecture. Services can be developed, deployed, and scaled independently without causing any impact on the overall system since they only require knowledge of the URL and data format of the API endpoint of the services they rely on, instead of being aware of the implementation specifics of those services. 

3. Scalability:

RESTful APIs allow services to be scaled independently to handle increasing traffic or workload. Each service can be deployed and scaled independently, without affecting other services. This allows the system to be more responsive and efficient in handling user requests. 

4. Flexibility:

RESTful APIs are flexible and can be used to expose the functionality of a service to external consumers, such as mobile apps, web applications, and other services. This allows services to be reused and integrated with other systems easily. 

5. Evolutionary Architecture:

RESTful APIs enable an evolutionary architecture, where services can evolve without affecting other services. New services can be added, existing services can be modified or retired, and APIs can be versioned to ensure backward compatibility. This allows the system to be agile and responsive to changing business requirements. 

6. Testing and Debugging

RESTful APIs are easy to test and debug, as they are based on HTTP and can be tested using standard tools such as Postman or curl. This allows developers to quickly identify and fix issues in the system. 

In conclusion, RESTful APIs play a critical role in microservices architecture, enabling service-to-service communication, loose coupling, scalability, flexibility, evolutionary architecture, and easy testing and debugging. 


This article provides a comprehensive overview of REST API and its principles, covering various aspects of REST API design. Through its discussion of RESTful API design principles, the article offers valuable guidance and best practices that can help developers design APIs that are scalable, maintainable, and easy to use.

Additionally, the article highlights the role of RESTful APIs in microservices architecture, providing readers with insights into the benefits of using RESTful APIs in developing and managing complex distributed systems.


March 30, 2023

Billions of users use various social media daily and see a lot of new suggestions there. The content includes text, images, videos, and so on depending on the social platform. Do you know how that content is suggested? 

We will learn about it in this blog.

Social media recommendation system: 

It is an algorithm that suggests relevant products to users based on a variety of factors. Sometimes, when you search for a certain product on a website you notice that you start receiving several suggestions of similar products, there is a system behind this. It is generally used to target potential users more efficiently and improve the user experience by suggesting new items, saving users’ time, and narrowing down the set of choices. 


Learn about Data Science here


Watch the video to see what a recommendation system is and how it is used in various real-world applications. 


Introduction to Recommender Systems 



Now that we know the concept, let’s dive deeper into a real-world application to better comprehend it. 


YouTube’s recommendation system journey

YouTube has over 800 million videos, which is about 17,810 years of continuous video watching. It is hard for a user to repeatedly search for certain sorts of videos from millions of videos. This problem is solved by recommendation systems, which provide relevant videos based on what you are currently watching.

The system also works when you open YouTube’s home page and do not watch any videos. In this case, it shows the mixture of the subscribed, most up-to-date, promoted, and most recently watched videos.  

Let’s discuss the journey of the recommendation system on YouTube. 

In 2008, YouTube’s recommendation system ranked videos based on popularity. The issue with this approach was sometimes violent or racy videos get popular. To avoid this, YouTube built classifiers to identify this type of content and avoid recommending them. After a couple of years, YouTube started to incorporate video watch time in its recommendation system.

The reason for this was that users often watched different types of videos and there were different recommendations for them. Later, YouTube took surveys where users rated the watched videos and answered the questions upon giving low or high stars.  

Soon, YouTube’s management realized that everyone did not fill out the survey. So, YouTube trained a machine learning model on completed surveys and predicted the survey responses. YouTube did not stop there; they started to consider the likes/dislikes and share information to make the recommender system better.  

Nowadays, they are also using classifiers to identify authoritative and borderline (doesn’t quite violate community) content to make a better recommender system. 


Read more about social media algorithms in this blog


Before diving deep into the technical detail, let’s first discuss common types of recommendation systems. 

Classification of recommendation system:  

Recommendation system
Recommendation system


These types of recommendation systems are widely used in industry to solve different problems. We will go through these briefly. 


1. Content-based recommendation system

 According to the user’s past behavior or explicit feedback, content-based filtering uses item features (such as keywords, categories, etc.) to suggest additional items that are similar to what they already enjoy. 

Content based recommendation system
Content based recommendation system



2. Collaborative recommendation system 

Collaborative filtering gives information based on interactions and data acquired by the system from other users. It is divided into two types: memory-based, and model-based systems. 


a) Memory-based system 

This mechanism is further classified as user-based and item-based filtering. In the user-based approach, recommendations are made based on the user’s preferences that are similar to the preferences of other users. In the item-based approach, recommendations are made based on items similar to other items the active user likes. 


Let’s see the below illustration to understand the difference:  

User-based recommendation system
User-based and item-based recommendation system


b) Model-based system 

This mechanism provides recommendations by developing machine learning models from users’ ratings. A few commonly used machine learning models are clustering-based, matrix factorization-based, and deep learning models.  

Model-based system
Model-based system

2. Demographic-based recommendation system 

This system provides recommendations based on user demographic attributes, such as age, sex, and location. This system uses demographic information, such as a user’s age, gender, and location, to provide personalized recommendations. This type of system uses data about a user’s characteristics to suggest items that may be of particular interest to them.

For example, a recommendation system might use a user’s age and location to suggest events or activities in the user’s area that might be of interest to someone in their age group.



3. Knowledge-based recommendation system 

This system offers recommendations based on queries made by the user rather than a user’s rating history. Shortly, it is based on explicit knowledge of the item variety, user preference and suggestion criteria. This strategy is suited for complex domains where products are not acquired frequently, such as houses and automobiles. 


4. Community-based recommendation system 

This system provides recommendations based on user-interacted items within a community that shares a common interest. A community-based recommendation system is a tool that uses the interactions and preferences of a group of people with a shared interest to provide personalized recommendations to individual users.

This type of system takes into account the collective experiences and opinions of the community in order to provide personalized recommendations.


5. Hybrid recommendation system 

This system is a combination of two or more discussed recommendation systems such as content-based, collaborative-based, and so on. Sometimes a single recommendation system cannot solve an issue, thus we must combine two or more recommendation systems. 

We now have a high-level understanding of the various recommendation systems. Recall the YouTube discussion, what do you think, which recommendation method suits YouTube the most. 


It is a memory-based collaborative recommendation system. YouTube can use an item-based approach to suggest videos based on other similar videos using users’ ratings (clicked on and watched videos). To determine the most similar match, we can use matrix factorization. This is a class of collaborative recommendation systems to find the relationship between items’ and users’ entities. However, this approach has numerous limitations, such as  

  • Not being suitable for complex relations in the users and items 
  • Always recommend popular items 
  • Cold start problem (cannot anticipate items and users that we have never encountered in training data) 
  • Can only use limited information (only user IDs and item IDs)  

To address the shortcomings of the matrix factorization method, deep neural networks are designed and used by YouTube. Deep learning is based on artificial neural networks, which enable computers to comprehend and make decisions in the same way that the human brain does.

Let’s watch the video below to gain a better understanding of deep learning.



YouTube uses the deep learning model for its video recommendation system. They provide users’ watch history and context to the deep neural network. The network then learns from the provided data and uses the softmax classifier (used for multiclass classification) to differentiate among the videos. This model provides hundreds of videos from a pool of over 800 million videos. This procedure was named “candidate generation” by YouTube.  

But we just need to reveal a few of them to a certain user. So, YouTube created a ranking system in which they provide a rank (score) to each of a few hundred videos. They used the same deep learning model that assigns a score to each video for this. The score may be based on the video that the user watched from any channel and/or the most recently watched video topic.

User history and context
User history and context – Source 


We studied different recommendation systems that can be used to address various real-world challenges. These systems help to connect people with resources and information that may not have been easily discoverable otherwise, making them a useful tool for solving these challenges.

We discussed the journey of YouTube’s recommendation system, a collaborative system used by YouTube, and examined how YouTube performed well using deep learning in their systems.  

January 2, 2023