Dev API Integration Guide Writer ================================ Create an API integration guide for [external service/API] integration. Integration details: - Service: [name] - API type: [REST/GraphQL/WebSocket/gRPC] - Auth: [API key/OAuth/JWT] - Language: [JavaScript/Python/other] - Use case: [what you are integrating for] API INTEGRATION GUIDE 1. PREREQUISITES - Account setup: [where to create account] - API credentials: [how to obtain] - Required packages: [install commands] - Environment variables needed: * [SERVICE]_API_KEY=your_key_here * [SERVICE]_BASE_URL=https://api.service.com 2. AUTHENTICATION API KEY AUTH ```javascript const headers = { 'Authorization': `Bearer ${process.env.SERVICE_API_KEY}`, 'Content-Type': 'application/json' } ``` OAUTH 2.0 ```javascript // Step 1: Get access token const tokenResponse = await fetch('/oauth/token', { method: 'POST', body: JSON.stringify({ client_id: process.env.CLIENT_ID, client_secret: process.env.CLIENT_SECRET, grant_type: 'client_credentials' }) }) const { access_token } = await tokenResponse.json() ``` 3. BASIC REQUEST PATTERN ```javascript async function callApi(endpoint, method = 'GET', data = null) { const options = { method, headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' } } if (data) options.body = JSON.stringify(data) const response = await fetch(`${BASE_URL}${endpoint}`, options) if (!response.ok) { throw new Error(`API error: ${response.status}`) } return response.json() } ``` 4. COMMON OPERATIONS FETCH DATA ```javascript // Example: Get list const items = await callApi('/items?limit=10') ``` CREATE RESOURCE ```javascript // Example: Create item const newItem = await callApi('/items', 'POST', { name: 'Item Name', type: 'example' }) ``` 5. ERROR HANDLING ```javascript try { const data = await callApi('/endpoint') } catch (error) { if (error.status === 429) { // Rate limited — implement retry with backoff } else if (error.status === 401) { // Refresh token or re-authenticate } } ``` 6. RATE LIMITING - Limit: [X requests per minute] - Strategy: [exponential backoff] - Retry after: [check Retry-After header] 7. TESTING - Sandbox/test environment: [URL] - Test credentials: [how to get] - Mock for unit tests: [how to mock] 8. WEBHOOK HANDLING (if applicable) - Endpoint to create: [your receiving URL] - Signature verification: [required] - Idempotency: [handle duplicate events] Source: https://promptzyo.com/prompt/dev-api-integration-guide-writer