8 Integrate third-party APIs

This chapter covers

  • Sending HTTP requests from your codebase
  • Authenticating at third-party APIs
  • Modeling structs for JSON responses
  • Sending multiple requests at once
  • Handling timeouts and retries
  • Integrating external HTTP calls in your route handlers

There is rarely a web service that doesn’t need to communicate with either third-party APIs or internally with other microservices. For this book, we are making HTTP requests to external APIs to demonstrate how that affects your codebase. It is up to you, after having a basic understanding of how to use HTTP crates in conjunction with Tokio, to find another crate able to talk the protocol of your choosing.

Use cases for sending HTTP requests can be as follows:

  • Shortening ...

Get Rust Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.