Backend Basics: RESTful API (API, REST, Methods, JSON, Examples) (2024)

Backend Basics: RESTful API (API, REST, Methods, JSON, Examples) (1)

As you probably know, a typical modern application consists of 2 main parts: Frontend and Backend.

If you want to create a web or mobile app, you need to have at least a basic understanding of REST API which is commonly used on backend development.

Todays technology enables developers to create complex backend apps using these simple concepts in no time by using BaaS platforms like Altogic.

Let’s break it down and understand the REST & API terms.

Italian Restaurant Metaphor

Let’s say you are trying to find nearby Italian restaurants on your favorite restaurant review app. You open up your mobile app, type “Italian” into a search field, hit enter, and you see a list of restaurants near your location.

A REST API works similarly. You request something, and you get a list of results back from the service you are requesting.

What is API?

An API is an Application Programming Interface. It is a set of rules that allow applications to talk to each other. The developer creates the API on the server and allows the client to talk to it.

In our Italian restaurant example, the server is the application running in the cloud, and the client is the mobile app you use to search for Italian restaurants.

What is REST?

REST determines what the API looks like. It stands for “Representational State Transfer,” and it is a set of rules that developers follow when they create their API. In the above example, the search functionality is an API resource exposed by REST.

Methods

In RESTful API, the client and server communicate using the HTTP protocol. The client sends a request to the server, and the server processes this request and sends back a response in return.

Here is the HTTP methods that are commonly used in RESTful APIs:

1. GET

This request is used to get a resource from a server. If you perform a GET request, the server looks for the data you requested and sends it back to you. In other words, a GET request performs a READ operation. This is the default request method.

2. POST

This request is used to create a new resource or perform an action on a server. If you perform a POST request, the server creates a new entry in the database or performs an action and tells you whether the creation is successful or returns the action results according to your service design.

3. PUT/PATCH

Primarily used for updating a resource on a server. For example, if you perform a PUT/PATCH request, the server updates an entry in the database and tells you whether the update is successful. In other words, a PUT/PATCH request performs an UPDATE operation.

4. DELETE

This request is used to delete a resource from a server. If you perform a DELETE request, the server deletes an entry in the database and tells you whether the deletion is successful. In other words, a DELETE request performs a DELETE operation.

As I told you, todays technology enables developers to create complex backend apps with these simple concepts in no time by using BaaS platforms.

Let’s see an example with Altogic where we use RESTful API to create our backend app:

1. Create your database models

Backend Basics: RESTful API (API, REST, Methods, JSON, Examples) (4)

2. Define your business logic (services)

Backend Basics: RESTful API (API, REST, Methods, JSON, Examples) (5)

3. Create your RESTful Endpoints and associate them with your services

Backend Basics: RESTful API (API, REST, Methods, JSON, Examples) (6)

In this case, when a POST request is sent to the path “/posts/{postId}/comments” (3rd photo), it will trigger the “Add comment to a post service” (2nd photo) which creates a comment object under “comments” model on our database (1st photo) with the input given.

This is the logic behind your backend apps. You can create complex backend apps and connect them to your frontend using Altogic client library with ease.

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write.

Backend Basics: RESTful API (API, REST, Methods, JSON, Examples) (7)

It is mainly used to store data in document databases and transport data between different applications, primarily between a server and web applications.

JSON is also frequently used in RESTFul APIs to provide data in request and response body. Below is an example JSON document summarizing a menu of a restaurant.

Backend Basics: RESTful API (API, REST, Methods, JSON, Examples) (8)

JSON supports the following two data structures;

  • Collection of name/value pairs
  • An ordered list of values − It includes arrays, lists, or sequences, etc.

A name/value pair consists of a field name (in double quotes), followed by a colon, followed by a value. So in the below example, the name is “firstName”, and the value is “John”.

Example: “firstName”: “John”

You need to put text values between double-quotes. For numbers, boolean values, or null values, you do not need double quotes.

Example: “age”: 24

Backend Basics: RESTful API (API, REST, Methods, JSON, Examples) (2024)
Top Articles
Green Bonds: Definition, History, Advantages, and Disadvantages
Sacagawea Coin Value
Craigslist Lake Of Ozarks Mo
Fantasy Football Week 3: 5 players who could make or break your lineups
Christine Paduch Howell Nj
Understanding Sheryl Crow's Impressive Net Worth And Wealth
Lubbock Avalanche Journal Newspaper Obituaries
Sunbiz Llc Search Florida
Skeleton Soldier Failed To Defend The Dungeon Wiki
Indiana Anon Ib
Li Bai - New World Encyclopedia
Olivia Dunne 2023: Puerto Rico
Rose Tree Park Italian Festival 2023
IFA - The REACH Chemical Regulation and OS&H: Classification and labelling inventory
Mywinners Wager Online
Curtis Ingraham Net Worth
Scout Haven Ruins
What is a CVT Transmission & is it Any Good?
Nipr To Sipr File Transfer Dots
Best All-In-One Printer For Home Use
Rubfinder
Math-Aids.com Answers
8009405707
HLS Fetch Download tools - Chrome Web Store
Recruiting: Alabama trying to flip Michigan football's top 2025 commit
Journal and Courier from Lafayette, Indiana
Barbie Showtimes Near Cmx Hollywood 16 & Imax
Florida Atlantic University
Standard Page Field
WeeCars, le réseau d'agences spécialisées dans les véhicules d'occasion - Le Quotidien des Entreprises
Upcoming Events & Tickets | Thompson Boling Arena
Olivia Dunne says 'tears filled my eyes' as LSU won NCAA women's gymnastics championship
Kaay 6Razy
Imvu Hov
Carefirst.webpay.md
Orange Theory Class Packages
Busted Barren County Ky
Ixl Ld Northeast
The Ben Shapiro Show Soundcloud
Jesus Many Faces - He Was Born, Lived And Died As A Jew | From Jesus To Christ | FRONTLINE
Ucsd Financial Aid Appeal
Excel Module 4 Sam End Of Module Project 2
R. Kelly trial: A look at the key moments after star found guilty
Indiana Wesleyan University Sharepoint
Oklahoma Craigslist Pets
Ixl Jobcorps
Vera Bradley Factory Outlet Sunbury Photos
Sheboygan Press Obit
Bulletbound Codes
Litter Robot Pinch Fault
Latest Posts
Article information

Author: Tish Haag

Last Updated:

Views: 6300

Rating: 4.7 / 5 (67 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Tish Haag

Birthday: 1999-11-18

Address: 30256 Tara Expressway, Kutchburgh, VT 92892-0078

Phone: +4215847628708

Job: Internal Consulting Engineer

Hobby: Roller skating, Roller skating, Kayaking, Flying, Graffiti, Ghost hunting, scrapbook

Introduction: My name is Tish Haag, I am a excited, delightful, curious, beautiful, agreeable, enchanting, fancy person who loves writing and wants to share my knowledge and understanding with you.