Our REST API is working great with a collection of endpoints that a client can send requests to.

In this chapter, we'll do something outside-of-the-box, ehem send requests to "outside our box" 🥁😅 Let me explain...

Our server will be the "client" which sends requests to external services, like Public APIs.

🙋‍♀️ Isn't mLab a public API? → mLab is external, but we used mongo library to abstract the requests and responses made to the database

How our server communicates with a public API is exactly the same as how our client communicates with our server: through HTTP requests that we know, like GET and POST 🤓

For example:

  1. Search a song from Spotify API
  2. Get a GIF/meme from Giphy API
  3. Authenticate user through Google, Facebook (part of Appendix topic Auth 2)

Client <——> Server

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/c34da7a0-eff2-4e00-a4a8-595653d17900/Untitled.png

Client <—> Server < — > external API

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/83a529af-fdcb-432d-8896-53610d89c6d3/Untitled.png

They have APIs for everything nowadays!

Public APIs require varying levels of authentication: