Agentic AI · Intermediate level

Intermediate level · Module 4 of 9 · 11 guided hours

External API Integration

Connecting agents to web APIs reliably: a local mock API for practice, HTTP clients with timeouts, retries with back-off, caching for low bandwidth, rate limits and API credentials.

Learning objectives

  • Build and call a local mock API
  • Make API calls reliable with timeouts, retries and caching
  • Handle rate limits and protect API credentials

Topics

  • a mock API with FastAPI
  • HTTP clients (httpx)
  • timeouts and retries with back-off
  • caching for low bandwidth
  • rate limits and HTTP 429
  • API credentials and scopes

Lessons

  1. Lesson 1 A Local Mock API for Practice

    Learners build a small FastAPI service with fictional data (for example market prices or programme timetables) so that API-calling agents can be developed offline and safely.

    FastAPIGET endpointsJSON responsesfictional dataAPI documentation

  2. Lesson 2 Reliable API Calls

    Learners call APIs from agent tools with httpx, using timeouts, retries with exponential back-off for temporary errors and clear error results for the model.

    httpx.Clienttimeoutretry with exponential back-offtemporary vs permanent errorserror messages for the model

  3. Lesson 3 Caching, Rate Limits and Credentials

    Learners cache API responses to save bandwidth and money, respect rate limits including Retry-After, and handle API credentials with minimal scopes.

    response cachingtime-to-liveHTTP 429 and Retry-AfterAPI key scopescredential rotation

Practical activity

Build the mock data API and a reliable, cached, rate-limit-aware API tool for the project, with a credential policy.

Expected outcomes

  • Reliable API integration for agents
  • Bandwidth- and cost-aware design

Assessment

API tool with failure tests (70%) and credential policy (30%).

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.