API integrations
Connecting to third-party services with real examples
Starting any API integration
"I need to integrate with the [Service Name] API. The API docs are at: [URL] — fetch and read them.
I need to:
1. Authenticate using [auth method: API key / OAuth / Bearer]
2. [List the specific endpoints/operations needed]
Build an API client module with:
- Clean error handling (log errors, don't crash)
- Rate limit awareness (respect their limits)
- Retry logic for transient failures (3 retries, exponential backoff)
Start with just authentication and a test call."
Real example: Shopify integration
"Build a Shopify Admin API client for our sync middleware.
Auth: Private app with API key and secret in .env
Endpoints needed:
- getProducts(page) — with pagination support
- updateProduct(id, fields) — partial updates only
- getInventoryLevels(locationId)
- updateInventory(inventoryItemId, locationId, quantity)
Rate limits: 2 req/second — enforce this.
All calls must log: endpoint called, response time, HTTP status."
Webhook handling
"Build a webhook handler for Shopify order events. We receive POSTs to /webhooks/shopify/orders.
The handler needs to:
1. Verify the webhook signature (HMAC with our shared secret)
2. Parse the payload
3. Route to the right handler based on topic
4. Return 200 immediately, process async (don't make Shopify wait)
5. Log all received webhooks with timestamp and topic"
Handling API credentials safely
"Move all API credentials to a .env file. Make sure:
- .env is in .gitignore
- The code reads from process.env, not hardcoded values
- There's an .env.example with placeholder values"
Never commit credentials. Before every commit, ask Claude to check for accidentally staged credentials: “Scan the staged changes for any API keys, passwords, tokens, or secrets before I commit.”
Quizzes