6
Most read
11
Most read
13
Most read
Lecture Series by
Tharindu Weerasinghe
For the 3rd Year Undergrads of APIIT – Sri Lanka
www.tharinduweerasinghe.com
REST API Basics
Outline
• REST API Introduction
• REST API Action Flow
• HTTP Methods
• Sample usage of the HTTP Methods in the Requests
• Example API Requests
• 3 steps to design API end-points
• Testing REST End-Points
www.tharinduweerasinghe.com
REST API Introduction
• REST ➔ REpresentational State Transfer (REST)
• API ➔ Application Programming Interface
• It can be regarded as a protocol that defines a set of constraints to be
used for creating web services.
• It is a way of accessing web services in a less complex manner without
having any processing.
• It caters only HTTP (Hypertext Transfer Protocol) requests.
• It’s a medium for two computers to communicate over HTTP in the
same way clients and servers communicate.
www.tharinduweerasinghe.com
REST API Action Flow
• Credit:
https://faun.pub/consumin
g-rest-apis-with-python-
eb86c6b724c5
www.tharinduweerasinghe.com
HTTP Methods used in REST APIs
1. GET: The HTTP GET method is used to retrieve a representation of a resource. In the successful path, GET returns a representation in XML or JSON and
an HTTP response code of 200 (OK). In the erroneous situation, it most often returns a 404 (NOT FOUND) or 400 (BAD REQUEST).
2. POST: The POST method is used to create new resources. In particular, it is utilized to create subordinate resources. That is, subordinate to some other
(e.g. parent) resource. On successful creation, return HTTP status 201, returning a Location header with a link to the newly-created resource with the
201 HTTP status.
NOTE: POST is neither safe nor idempotent.
3. PUT: The PUT method for updating the capabilities. However, PUT can also be used to create a resource in the case where the resource ID is chosen
by the client instead of by the server. In other words, if the PUT is to a URI that contains the value of a non-existent resource ID. On successful update,
return 200 (or 204 if not returning any content in the body) from a PUT. If using PUT for create, return HTTP status 201 on successful creation. PUT is
not safe operation but it’s idempotent.
4. PATCH: The PATCH method used for modify capabilities. The PATCH request only needs to contain the changes to the resource, not the complete
resource. This resembles PUT, but the body contains a set of instructions describing how a resource currently residing on the server should be
modified to produce a new version. This means that the PATCH body should not just be a modified part of the resource, but in some kind of patch
language like JSON Patch or XML Patch. PATCH is neither safe nor idempotent.
5. DELETE: The DELETE method is used to delete a resource identified by a URI. On successful deletion, return HTTP status 200 (OK) along with a
response body.
Credits: REST API (Introduction) - GeeksforGeeks
www.tharinduweerasinghe.com
www.tharinduweerasinghe.com
Sample usage of the HTTP Methods in the Requests
Credits: https://assertible.com/blog/7-http-methods-every-web-developer-should-know-and-how-to-test-them
HTTP Status Codes
• Credits:
https://faun.pub/consuming-
rest-apis-with-python-
eb86c6b724c5
www.tharinduweerasinghe.com
Example:
Calling a REST API End-Point in Javascript
www.tharinduweerasinghe.com
The following slide will show you how can you
include your JavaScript code shown in the
previous slide in an HTML code!
www.tharinduweerasinghe.com
www.tharinduweerasinghe.com
3 steps to design API end-points using Python
• Step 1: Design your API Interface
• The most vital step
• You need to know the problem you want to address for a successful design
• Basically, this will cater the business requirements of sending relevant data for respective HTTP
requests
• You need to decide on the format of the request and response
• Use API URL best practices in designing your APIs.
• You need to describe your REST APIs using OpenAPI definition, designing an API means creating
an OpenAPI document for it.
Credit: https://blog.stoplight.io/how-to-create-an-api-in-three-steps
www.tharinduweerasinghe.com
3 steps to design API end-points using Python
(contd.)
• Step 2: Mock your API Server
• Once you have your design, you need to check the manipulated response.
• After you create your OpenAPI document for your new API, create a mock server. There are a few
ways to do this, one of the methods is to use an open-source command-line utility like the Prism API
server.
www.tharinduweerasinghe.com
Credit: https://blog.stoplight.io/how-to-create-an-api-in-three-steps
3 steps to design API end-points using Python
(contd.)
• Step 3: Code your API
• Once you have your OpenAPI
document then, you can select
whatever the platform or
language you would like to
code your API and build the
API server. Here I’m using
Python with a library called
Flask.
www.tharinduweerasinghe.com
Credit: https://blog.stoplight.io/how-to-create-an-api-in-three-steps
REST API Testing Tools
• Postman
• Swagger
https://www.softwaretestingmaterial.com/best-api-testing-tools/
Reference
• Understanding And Using REST APIs — Smashing Magazine
• REST API (Introduction) – GeeksforGeeks
• Python and REST APIs: Interacting With Web Services – Real Python
• 7 Simple REST Client Examples for Retrieving API Data (dreamfactory.com)
• REST API Example Requests – Tableau
• Building a Basic RestFul API in Python | Codementor
• REST API Testing Strategy: What Exactly Should You Test? l Sisense
• Online API Testing Tool | Test Your API Online (reqbin.com)
• Postman API Platform | Sign Up for Free
• SwaggerHub | API Design and Documentation with OpenAPI
• Python REST API Tutorial - Building a Flask REST API – YouTube
• https://levelup.gitconnected.com/all-possible-ways-of-making-an-api-call-in-plain-javascript-c0dee3c11b8b
• https://www.testim.io/blog/the-9-api-testing-tools-you-cant-live-without-in-2019-2/
• https://www.freecodecamp.org/news/rest-api-best-practices-rest-endpoint-design-examples/
• https://www.freecodecamp.org/news/rest-api-best-practices-rest-endpoint-design-examples/
• https://rapidapi.com/blog/how-to-use-an-api-with-javascript/
• https://www.softwaretestingmaterial.com/best-api-testing-tools/
www.tharinduweerasinghe.com

More Related Content

PPTX
An Introduction To REST API
PPTX
REST API
PPTX
PPTX
REST & RESTful Web Services
PPT
Introduction to the Web API
PPTX
Introduction to REST - API
PDF
Laravel Introduction
PPTX
introduction about REST API
An Introduction To REST API
REST API
REST & RESTful Web Services
Introduction to the Web API
Introduction to REST - API
Laravel Introduction
introduction about REST API

What's hot (20)

PPSX
Php and MySQL
PDF
What is REST API? REST API Concepts and Examples | Edureka
PPTX
Laravel introduction
PPTX
Bootstrap
PPT
PHP - Introduction to PHP Fundamentals
PDF
Rest web services
PPTX
Design Beautiful REST + JSON APIs
PPTX
REST-API introduction for developers
PPTX
40+ tips to use Postman more efficiently
PPTX
PPTX
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
PPTX
Api gateway : To be or not to be
PPTX
Introduction to php
PPTX
Session tracking in servlets
PPT
Web Service Presentation
ODP
Joomla REST API
PDF
Php introduction
PPTX
Introduction to APIs (Application Programming Interface)
PPTX
Introduction to spring boot
PDF
API for Beginners
Php and MySQL
What is REST API? REST API Concepts and Examples | Edureka
Laravel introduction
Bootstrap
PHP - Introduction to PHP Fundamentals
Rest web services
Design Beautiful REST + JSON APIs
REST-API introduction for developers
40+ tips to use Postman more efficiently
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Api gateway : To be or not to be
Introduction to php
Session tracking in servlets
Web Service Presentation
Joomla REST API
Php introduction
Introduction to APIs (Application Programming Interface)
Introduction to spring boot
API for Beginners
Ad

Similar to REST API Basics (20)

PPTX
REST library.pptx
PPTX
Standards of rest api
PPTX
Understanding APIs.pptx
PPTX
Understanding APIs.pptx introduction chk
PDF
Introduction to REST - REST Basics - JSON
PPTX
Pragmatic REST APIs
PPTX
A Deep Dive into RESTful API Design Part 2
PPTX
Super simple introduction to REST-APIs (2nd version)
PDF
Facebook & Twitter API
PPTX
rest-api-basics.pptx
PDF
PDF
REST APIS web development for backend familiarity
PDF
Api FUNdamentals #MHA2017
PPTX
Best Practices for Architecting a Pragmatic Web API.
PDF
Api fundamentals
PDF
REST APIs, Girls Who Code
PDF
Modern REST API design principles and rules.pdf
PPTX
Rest WebAPI with OData
PPTX
rest-api-basics.pptx
PDF
REST API Recommendations
REST library.pptx
Standards of rest api
Understanding APIs.pptx
Understanding APIs.pptx introduction chk
Introduction to REST - REST Basics - JSON
Pragmatic REST APIs
A Deep Dive into RESTful API Design Part 2
Super simple introduction to REST-APIs (2nd version)
Facebook & Twitter API
rest-api-basics.pptx
REST APIS web development for backend familiarity
Api FUNdamentals #MHA2017
Best Practices for Architecting a Pragmatic Web API.
Api fundamentals
REST APIs, Girls Who Code
Modern REST API design principles and rules.pdf
Rest WebAPI with OData
rest-api-basics.pptx
REST API Recommendations
Ad

More from Tharindu Weerasinghe (20)

PPTX
Professionalism & Industry Expectations from undergraduates
PPTX
Importance of Knowing what you need to Know!
PDF
C Propgramming.pdf
PDF
Basics of Computer Networks in Sinhala
PDF
Data Structures & Algorithms in Sinhala
PDF
Object Oriended Programming in Sinhala
PDF
Tips For A Better Undergraduate Research
PDF
Basics of Block Chain
PDF
Basics of IoT
PDF
Cloud Conputing Basics and some Related Research Topics
PDF
Basic Concepts and Trends in Emerging Technologies
PDF
Introcution to EJB
PDF
Introduction to Enterprise Applications and Tools
PPT
Introduction to Agile Software Development & Python
PDF
Agile Languages for Rapid Prototyping
PPTX
Things to ponder before you start building [cooperate] software
PDF
How to make screens and the internet safe for Children
PDF
Different Concepts on Databases
PPTX
A Survey Study on Higher Education Trends among Sri Lankan IT Professionals
PDF
A Survey Study on Higher Education Trends among Information Technology Prof...
Professionalism & Industry Expectations from undergraduates
Importance of Knowing what you need to Know!
C Propgramming.pdf
Basics of Computer Networks in Sinhala
Data Structures & Algorithms in Sinhala
Object Oriended Programming in Sinhala
Tips For A Better Undergraduate Research
Basics of Block Chain
Basics of IoT
Cloud Conputing Basics and some Related Research Topics
Basic Concepts and Trends in Emerging Technologies
Introcution to EJB
Introduction to Enterprise Applications and Tools
Introduction to Agile Software Development & Python
Agile Languages for Rapid Prototyping
Things to ponder before you start building [cooperate] software
How to make screens and the internet safe for Children
Different Concepts on Databases
A Survey Study on Higher Education Trends among Sri Lankan IT Professionals
A Survey Study on Higher Education Trends among Information Technology Prof...

Recently uploaded (20)

PPTX
Lesson-3-Operation-System-Support.pptx-I
PDF
IT Consulting Services to Secure Future Growth
PDF
Crypto Loss And Recovery Guide By Expert Recovery Agency.
PPTX
Lecture 5 Software Requirement Engineering
PDF
MAGIX Sound Forge Pro CrackSerial Key Keygen
PPTX
Why 2025 Is the Best Year to Hire Software Developers in India
PDF
Cloud Native Aachen Meetup - Aug 21, 2025
PDF
infoteam HELLAS company profile 2025 presentation
PPTX
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
PPT
3.Software Design for software engineering
PPTX
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
PPTX
string python Python Strings: Literals, Slicing, Methods, Formatting, and Pra...
PDF
Building an Inclusive Web Accessibility Made Simple with Accessibility Analyzer
PDF
CapCut PRO for PC Crack New Download (Fully Activated 2025)
PPTX
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
PDF
Sanket Mhaiskar Resume - Senior Software Engineer (Backend, AI)
PPTX
ROI from Efficient Content & Campaign Management in the Digital Media Industry
PPTX
Folder Lock 10.1.9 Crack With Serial Key
PDF
Internet Download Manager IDM Crack powerful download accelerator New Version...
PDF
Practical Indispensable Project Management Tips for Delivering Successful Exp...
Lesson-3-Operation-System-Support.pptx-I
IT Consulting Services to Secure Future Growth
Crypto Loss And Recovery Guide By Expert Recovery Agency.
Lecture 5 Software Requirement Engineering
MAGIX Sound Forge Pro CrackSerial Key Keygen
Why 2025 Is the Best Year to Hire Software Developers in India
Cloud Native Aachen Meetup - Aug 21, 2025
infoteam HELLAS company profile 2025 presentation
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
3.Software Design for software engineering
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
string python Python Strings: Literals, Slicing, Methods, Formatting, and Pra...
Building an Inclusive Web Accessibility Made Simple with Accessibility Analyzer
CapCut PRO for PC Crack New Download (Fully Activated 2025)
WJQSJXNAZJVCVSAXJHBZKSJXKJKXJSBHJBJEHHJB
Sanket Mhaiskar Resume - Senior Software Engineer (Backend, AI)
ROI from Efficient Content & Campaign Management in the Digital Media Industry
Folder Lock 10.1.9 Crack With Serial Key
Internet Download Manager IDM Crack powerful download accelerator New Version...
Practical Indispensable Project Management Tips for Delivering Successful Exp...

REST API Basics

  • 1. Lecture Series by Tharindu Weerasinghe For the 3rd Year Undergrads of APIIT – Sri Lanka www.tharinduweerasinghe.com REST API Basics
  • 2. Outline • REST API Introduction • REST API Action Flow • HTTP Methods • Sample usage of the HTTP Methods in the Requests • Example API Requests • 3 steps to design API end-points • Testing REST End-Points www.tharinduweerasinghe.com
  • 3. REST API Introduction • REST ➔ REpresentational State Transfer (REST) • API ➔ Application Programming Interface • It can be regarded as a protocol that defines a set of constraints to be used for creating web services. • It is a way of accessing web services in a less complex manner without having any processing. • It caters only HTTP (Hypertext Transfer Protocol) requests. • It’s a medium for two computers to communicate over HTTP in the same way clients and servers communicate. www.tharinduweerasinghe.com
  • 4. REST API Action Flow • Credit: https://faun.pub/consumin g-rest-apis-with-python- eb86c6b724c5 www.tharinduweerasinghe.com
  • 5. HTTP Methods used in REST APIs 1. GET: The HTTP GET method is used to retrieve a representation of a resource. In the successful path, GET returns a representation in XML or JSON and an HTTP response code of 200 (OK). In the erroneous situation, it most often returns a 404 (NOT FOUND) or 400 (BAD REQUEST). 2. POST: The POST method is used to create new resources. In particular, it is utilized to create subordinate resources. That is, subordinate to some other (e.g. parent) resource. On successful creation, return HTTP status 201, returning a Location header with a link to the newly-created resource with the 201 HTTP status. NOTE: POST is neither safe nor idempotent. 3. PUT: The PUT method for updating the capabilities. However, PUT can also be used to create a resource in the case where the resource ID is chosen by the client instead of by the server. In other words, if the PUT is to a URI that contains the value of a non-existent resource ID. On successful update, return 200 (or 204 if not returning any content in the body) from a PUT. If using PUT for create, return HTTP status 201 on successful creation. PUT is not safe operation but it’s idempotent. 4. PATCH: The PATCH method used for modify capabilities. The PATCH request only needs to contain the changes to the resource, not the complete resource. This resembles PUT, but the body contains a set of instructions describing how a resource currently residing on the server should be modified to produce a new version. This means that the PATCH body should not just be a modified part of the resource, but in some kind of patch language like JSON Patch or XML Patch. PATCH is neither safe nor idempotent. 5. DELETE: The DELETE method is used to delete a resource identified by a URI. On successful deletion, return HTTP status 200 (OK) along with a response body. Credits: REST API (Introduction) - GeeksforGeeks www.tharinduweerasinghe.com
  • 6. www.tharinduweerasinghe.com Sample usage of the HTTP Methods in the Requests Credits: https://assertible.com/blog/7-http-methods-every-web-developer-should-know-and-how-to-test-them
  • 7. HTTP Status Codes • Credits: https://faun.pub/consuming- rest-apis-with-python- eb86c6b724c5 www.tharinduweerasinghe.com
  • 8. Example: Calling a REST API End-Point in Javascript www.tharinduweerasinghe.com
  • 9. The following slide will show you how can you include your JavaScript code shown in the previous slide in an HTML code! www.tharinduweerasinghe.com
  • 11. 3 steps to design API end-points using Python • Step 1: Design your API Interface • The most vital step • You need to know the problem you want to address for a successful design • Basically, this will cater the business requirements of sending relevant data for respective HTTP requests • You need to decide on the format of the request and response • Use API URL best practices in designing your APIs. • You need to describe your REST APIs using OpenAPI definition, designing an API means creating an OpenAPI document for it. Credit: https://blog.stoplight.io/how-to-create-an-api-in-three-steps www.tharinduweerasinghe.com
  • 12. 3 steps to design API end-points using Python (contd.) • Step 2: Mock your API Server • Once you have your design, you need to check the manipulated response. • After you create your OpenAPI document for your new API, create a mock server. There are a few ways to do this, one of the methods is to use an open-source command-line utility like the Prism API server. www.tharinduweerasinghe.com Credit: https://blog.stoplight.io/how-to-create-an-api-in-three-steps
  • 13. 3 steps to design API end-points using Python (contd.) • Step 3: Code your API • Once you have your OpenAPI document then, you can select whatever the platform or language you would like to code your API and build the API server. Here I’m using Python with a library called Flask. www.tharinduweerasinghe.com Credit: https://blog.stoplight.io/how-to-create-an-api-in-three-steps
  • 14. REST API Testing Tools • Postman • Swagger https://www.softwaretestingmaterial.com/best-api-testing-tools/
  • 15. Reference • Understanding And Using REST APIs — Smashing Magazine • REST API (Introduction) – GeeksforGeeks • Python and REST APIs: Interacting With Web Services – Real Python • 7 Simple REST Client Examples for Retrieving API Data (dreamfactory.com) • REST API Example Requests – Tableau • Building a Basic RestFul API in Python | Codementor • REST API Testing Strategy: What Exactly Should You Test? l Sisense • Online API Testing Tool | Test Your API Online (reqbin.com) • Postman API Platform | Sign Up for Free • SwaggerHub | API Design and Documentation with OpenAPI • Python REST API Tutorial - Building a Flask REST API – YouTube • https://levelup.gitconnected.com/all-possible-ways-of-making-an-api-call-in-plain-javascript-c0dee3c11b8b • https://www.testim.io/blog/the-9-api-testing-tools-you-cant-live-without-in-2019-2/ • https://www.freecodecamp.org/news/rest-api-best-practices-rest-endpoint-design-examples/ • https://www.freecodecamp.org/news/rest-api-best-practices-rest-endpoint-design-examples/ • https://rapidapi.com/blog/how-to-use-an-api-with-javascript/ • https://www.softwaretestingmaterial.com/best-api-testing-tools/ www.tharinduweerasinghe.com