Why should I care
about REST?
Taking advantage of REST today!
Raúl Sánchez
Víctor Martínez
Antonio Hernández
Miguel Sánchez
Adrián Muro
Julio Tinajero
Agenda
• HTTP
• Methods
• Headers
• Body
• Status Codes
• What is REST anyway?
• Who uses REST?
Agenda (cont.)
• How to use REST?
• cURL
• JavaScript
• Postman
• Swagger
• The Oracle way
HTTP
The protocol of the web
HTTP
Methods (Subset)
GET POST PUT DELETE
Obtain a resource Create a resource Update a resource Delete a resource
HTTP
Headers
• Request Headers



Accept: Tells the server what type of content we want

Authorization: Sends our credentials to the server

• Response Headers



Content-Type: Tells us about the content of a response

Content-Length: Tells us about the content of a response
HTTP
Body
HTTP
Status Codes
Sample HTTP 404 error page at github.com
• 1xx: Informational
• 2xx: Success
• 3xx: Redirection
• 4xx: Client Error
• 5xx: Server Error
See https://devhints.io/http-status
REST
REpresentational State Transfer
• An architectural style
• Uses a subset of HTTP
• Modeling is resource based
• Typically uses JSON for resource representation
REST
REpresentational State Transfer
Who uses REST?
TLDR; A lot of people
• GitHub: https://docs.github.com/en/rest
• GitLab: https://docs.gitlab.com/ee/api/
• Kubernetes: https://kubernetes.io/docs/concepts/overview/kubernetes-api/
• Twitter: https://developer.twitter.com/en/docs/twitter-api
• Spotify: https://developer.spotify.com/documentation/web-api/
• Google Spreadsheets: https://developers.google.com/sheets/api
Find lots of public APIs in https://github.com/public-apis/public-apis
How to use REST
cURL
• Lives in the command line
• Is virtually available anywhere
• Important options



-L Follow redirects

-k Allow insecure SSL certs

-X Set the HTTP Method

-H Set a header

-u BASIC Authentication

-v Debugging output

-s No progress output
How to use REST
cURL + jq
• Install jq



brew install jq

• Use jq



curl -s http://... | jq
How to use REST
Google Chrome + JavaScript
• Use the DevTools



await fetch(

'<URI>',

<OPTIONS>

)

.then(

response => response.json()

);
See the fetch documentation at

https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
How to use REST
Postman
• Allows to define request collections
• Saves history
• Allows to generate code to test APIs
• Has a CLI app to run tests
Download Postman from
https://www.postman.com/
How to use REST
Swagger/OpenAPI
• Allows to define a REST api as JSON
or YAML
• Can generate a UI to test your API
• Can generate code to test your API
• Can be imported into postman
Use Swagger Editor at
https://editor.swagger.io/
Using REST the Oracle way
Demo Time
https://signup.cloud.oracle.com/
Sign up to Oracle Cloud
Thank You!

Why should I care about REST?

  • 1.
    Why should Icare about REST? Taking advantage of REST today! Raúl Sánchez Víctor Martínez Antonio Hernández Miguel Sánchez Adrián Muro Julio Tinajero
  • 2.
    Agenda • HTTP • Methods •Headers • Body • Status Codes • What is REST anyway? • Who uses REST?
  • 3.
    Agenda (cont.) • Howto use REST? • cURL • JavaScript • Postman • Swagger • The Oracle way
  • 4.
  • 5.
    HTTP Methods (Subset) GET POSTPUT DELETE Obtain a resource Create a resource Update a resource Delete a resource
  • 6.
    HTTP Headers • Request Headers
 
 Accept:Tells the server what type of content we want
 Authorization: Sends our credentials to the server
 • Response Headers
 
 Content-Type: Tells us about the content of a response
 Content-Length: Tells us about the content of a response
  • 7.
  • 8.
    HTTP Status Codes Sample HTTP404 error page at github.com • 1xx: Informational • 2xx: Success • 3xx: Redirection • 4xx: Client Error • 5xx: Server Error See https://devhints.io/http-status
  • 9.
    REST REpresentational State Transfer •An architectural style • Uses a subset of HTTP • Modeling is resource based • Typically uses JSON for resource representation
  • 10.
  • 11.
    Who uses REST? TLDR;A lot of people • GitHub: https://docs.github.com/en/rest • GitLab: https://docs.gitlab.com/ee/api/ • Kubernetes: https://kubernetes.io/docs/concepts/overview/kubernetes-api/ • Twitter: https://developer.twitter.com/en/docs/twitter-api • Spotify: https://developer.spotify.com/documentation/web-api/ • Google Spreadsheets: https://developers.google.com/sheets/api Find lots of public APIs in https://github.com/public-apis/public-apis
  • 12.
    How to useREST cURL • Lives in the command line • Is virtually available anywhere • Important options
 
 -L Follow redirects
 -k Allow insecure SSL certs
 -X Set the HTTP Method
 -H Set a header
 -u BASIC Authentication
 -v Debugging output
 -s No progress output
  • 13.
    How to useREST cURL + jq • Install jq
 
 brew install jq
 • Use jq
 
 curl -s http://... | jq
  • 14.
    How to useREST Google Chrome + JavaScript • Use the DevTools
 
 await fetch(
 '<URI>',
 <OPTIONS>
 )
 .then(
 response => response.json()
 ); See the fetch documentation at
 https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
  • 15.
    How to useREST Postman • Allows to define request collections • Saves history • Allows to generate code to test APIs • Has a CLI app to run tests Download Postman from https://www.postman.com/
  • 16.
    How to useREST Swagger/OpenAPI • Allows to define a REST api as JSON or YAML • Can generate a UI to test your API • Can generate code to test your API • Can be imported into postman Use Swagger Editor at https://editor.swagger.io/
  • 17.
    Using REST theOracle way Demo Time
  • 18.
  • 19.