API Integration Prompt: Contracts, Retries and Error States
Plan a small API integration from official documentation. Handle authentication, rate limits and failures without inventing endpoints or retry rules.
Illustrative cover; not a verified result from this prompt.
Read the full prompt
Help integrate [API NAME AND VERSION] into [LANGUAGE/FRAMEWORK]. Official documentation or supplied contract: [REFERENCE]. Required operation: [OPERATION]. Explain authentication without exposing real credentials, map request and response fields, and implement the smallest useful call. Handle documented error cases, timeouts and rate limits. Retry only where safe; explain duplicate-operation risk. Include tests using fixtures or a sandbox. Mark unavailable documentation and assumptions clearly instead of inventing endpoints or response fields.
Bring the actual API contract
Supply the official endpoint documentation, version and operation you need. An API name alone does not tell the model which authentication flow or fields your account can use. Remove real tokens from example requests.
Example: load a weather summary
Use a fictional contract for practice: “GET /weather?city=Jaipur returns city, temperature_c and updated_at. A missing city returns 400; a rate limit returns 429 with Retry-After.” Ask for one typed function and separate display states for success, invalid input and temporary failure.
Keep this fixture separate from any real weather provider. The model should not silently treat the invented endpoint as a live service.
Test the failure path
Try an empty city, a timeout and an unexpected response shape in tests. Confirm that retries respect the documented limit. Repeating a read request and repeating a payment creation are different risks. Keep secrets server-side where appropriate, log useful error context without credentials and verify the real service's current behavior before shipping.