Moving on in the server side , you will learn what the term REST means and how it lets us communicate with the server efficiently.
REST and CRUD are two major concepts in the API industry. While REST is the most widely considered design style for Web APIs, CRUD helps in database applications. As organizations use REST API, they inherently rely on a RESTful Architecture. However, REST and CRUD operations resemble each other because REST is a superset of CRUD when performing HTTP methods.
- What is API?
- What is Rest and Restful API?
- Explain what CRUD Operations are?
- Differentiate between volatile and non-volatile storage
What is an API?
API stands for Application Programming Interface. An API establishes a connection between programs so they can transfer data.
Servers define Interfaces : which represents a set of rules which dictate how to interact with the server in order to access its resources.
An Application Programming Interface, or API offers programmers a specification on how to interact with a server in their program using HTTP requests.
API enables an application or service to access resources within another application or service. This mechanism consists of two parts — the application or service accessing is called ‘client’ and the application or service containing resources is called ‘server.’
The client could be the frontend of the same program or an external program.
In order to get this data, a structured request has to be sent to the API. If the request meets the desired requirements, a response which contains the data gets sent back to where the request was made. This response usually comes in the form of JSON or XML data.
In some cases, you’ll need some sort of authorization to gain access to external API data.
Every API has documentation that tells you what data is available and how to structure your request in order to get a valid response.
Check this a real life scenario to give an example of APIin freeCodeCamp
What is Rest & Restful API?
REST, an acronym for REpresentational State Transfer.
- It is a popular Architectural Style used for developing an API.
- It is a standard that guides the design and development of processes which enable us interact with data stored on a web servers.
An API that complies with some or all of the six guiding constraints of REST is considered to be RESTful.
Explaining CRUD Operations
Now, we are able to communicate with servers using the HTTP protocol. With these protocols, we can Create, Read, Update and Delete data – otherwise known as CRUD operations.
CRUD is a type of mechanism that allows you to create data, read data, edit it, and delete those data.
Four CRUD Operations Components Explained
Let’s review each of the four components in-depth to fully appreciate their collective importance of facilitating data interactions.
The create function allows users to create a new record in the database.
The read function is similar to a search function. It allows users to search and retrieve specific records in the table and read their values.
The update function is used to modify existing records that exist in the database. To fully change a record, users may have to modify information in multiple fields.
The delete function allows users to remove records from a database that is no longer needed.
How to communicate with a server using REST APIs
As we discussed in the previous sections, REST APIs make the communication process with the server easier for us by giving us various HTTP request methods. The most commonly used methods are:
- GET: The get method is used to Read data on the server.
- POST: The post method is used to Create data.
- PATCH/PUT: The patch method is used to Update data.
- DELETE: The delete method is used to Delete data.
These methods provided by REST allow us perform CRUD operations easily. That is:
- Create => POST.
- Read => GET.
- Update => PATCH/PUT.
- Delete => DELETE.
So if we are to make a request to a server, let’s say to retrieve data, we are going to make a GET request to an endpoint/resource provided by the server.
The endpoint is similar to a **URL**.
If the request made is a valid one, then the server will respond to us with the data we requested. It also sends a status code where 200 is a success and 400 is a client error.
Volatile and non-volatile storage
Persistent storage refers to any data storage device that retains power after the device is powered off, such as a hard disk or a solid-state drive. In contrast, random access memory and internal caching are two examples of volatile memory – they contain data that will be erased when they lose power.
In this section you can find a lot of helpful links to other content. This is a supplemental material for you if you want to dive deeper into some concepts.