REST APIs
What they are? How they work?
APIs
Application Programming Interface
interface that defines interactions between multiple software applications
API
UI
![](https://thrillshare.com/home/img/new_hero.png)
![](https://i.pinimg.com/originals/99/61/74/99617428bbfca7e6c2fc96bcb0c3db80.png)
Interfaces for Humans
Interfaces for Software
An API defines...
- Contract: Procedures & Conventions
- Data formats
- Inputs: Calls / Requests
- Outputs: Results / Responses
APIs
- Mostly inflexible
- Ruled by Standards (Ex. IETF)
- Agnostic to programming lang(s)
- Mostly at lower network stack levels
- Wider applicability
- Highly flexible
- Custom Implementation
- Tied to programming language(s)
- At application level
- Specific applicability
- Relies on Protocols to work
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8563669/102219_1135_TCPIPvsOSIM1.png)
Protocols
vs.
"You use an API, but speak a Protocol"
TCP/IP
UDP
Gopher
FTP
SSH/SFTP
Telnet
SMTP/POP3
HTTP(S)(2)
Protocols (10-100s)
Internet
Streaming
Hypertext
File Transfers
Remote Shells
World Wide Web
APIs (♾)
Libraries / Frameworks
libc, Tensorflow, OpenGL, Rails, protobufs
Operating Systems
POSIX, Win32, DCOM, CORBA, ...
Remote APIs
JDBC, RPC
Web APIs
HTTP, XML-RPC, SOAP, REST, gRPC, GraphQL
Service-specific APIs
Twitter, Stripe, Twilio, Thrillshare, ...
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564061/Screen_Shot_2021-05-13_at_17.07.52.png)
Web APIs
(mostly over HTTP*)
Client-Server model
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8563400/eb1XzChwKf.gif)
HTTP
Text-based
<SGML>
- XML
- HTML
Multi-Media
JSON⭐️
Hypertext Transfer Protocol
hypermedia, hyperlinks
WWW (World Wide Web)
by Tim Berners-Lee at CERN in 1989
request–response in the client–server model
Resources located via URLs
Request Methods (aka Verbs):
- HEAD
- GET
- POST
- PUT/PATCH
- DELETE
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564349/440px-Internet1.svg.png)
HTTP
![](https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview/fetching_a_page.png)
HTTP
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564360/Screen_Shot_2021-05-13_at_21.43.12.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564361/Screen_Shot_2021-05-13_at_21.43.52.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564362/Screen_Shot_2021-05-13_at_21.41.06.png)
So, REST?
Architectural style & set of conventions heavily based on the HTTP protocol to make easier to develop Web APIs :
REST
(Representational State Transfer)
- Client-server: Separation of concerns
- Stateless: Each request is isolated from each other
- Cacheable: Avoid double work and save bandwidth
- Uniform interface: Components based on Resources
Roy Fielding dissertation: http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm
Resources
- Key abstraction/entity of information
- Resource identifiers: Usually some sort of ID
- Semantic: Self-descriptive
-
Support HTTP CRUD vebs/mehtods:
- GET
- PUT/PATCH
- POST
- DELETE
Example REST
Usage Lifecycle
Example
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564404/Screen_Shot_2021-05-13_at_22.19.29.png)
Example
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564405/Screen_Shot_2021-05-13_at_22.21.04.png)
Example
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564410/Screen_Shot_2021-05-13_at_22.25.42.png)
Example
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564406/Screen_Shot_2021-05-13_at_22.22.08.png)
Example
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564411/Screen_Shot_2021-05-13_at_22.26.52.png)
Example
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564407/Screen_Shot_2021-05-13_at_22.23.09.png)
Example
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564409/Screen_Shot_2021-05-13_at_22.24.36.png)
Example
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564408/Screen_Shot_2021-05-13_at_22.24.07.png)
Example
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564412/Screen_Shot_2021-05-13_at_22.29.40.png)
Example
![](https://s3.amazonaws.com/media-p.slid.es/uploads/333800/images/8564414/Screen_Shot_2021-05-13_at_22.32.52.png)
Quick Demo
- Browser
- Postman / Insomnia
- cURL (command line)
- Code
Thanks!
REST APIs
By Benjamin Orozco (benoror)
REST APIs
REST APIs
- 975