Api data extraction

From FerroxLabs/murage · View interactive version

Api data extraction is an AI agent skill from the GitHub repository FerroxLabs/murage. Produces an API data extraction design covering authentication approach, pagination strategy, rate limit handling, response parsing specification, and error handling protocol. Describes the extraction logic without writing executable code. Use when the user asks to plan data extraction from an API,

How to use this skill

Skill file

API Data Extraction

When to Use

Use this skill when:

Do NOT use when:

Process

  1. Assess the API. Gather key information:
  1. Design the authentication flow. Based on the auth method:
  1. Design the data retrieval strategy. Define how data is fetched:
  1. Design the pagination strategy. Based on the API's pagination method:
  1. Design rate limit handling. Based on the API's rate limits:
  1. Design the response parsing specification. Define how responses are processed:
  1. Design error handling. Define the response to each error type:

Output Format

## API Data Extraction Design: [API Name]

### API Assessment

| Attribute | Value |
|-----------|-------|
| API type | [REST / GraphQL / SOAP] |
| Base endpoint | [Base URL pattern] |
| Data format | [JSON / XML / CSV] |
| Rate limit | [Requests per time window] |
| Authentication | [Method] |
| Documentation | [Reference location] |

### Authentication Design

- **Method:** [API Key / OAuth 2.0 / Basic Auth]
- **Credential storage:** [Secrets manager / Environment variable reference]
- **Token refresh:** [Strategy for token expiry -- if applicable]
- **Auth failure handling:** [What happens when auth fails]

### Data Retrieval Strategy

- **Extraction type:** [Full / Incremental]
- **Incremental key:** [Field used for incremental detection, if applicable]
- **State storage:** [Where last extraction point is recorded]
- **Backfill process:** [How to handle initial load or catch-up]
- **Endpoints used:**

| Endpoint | Method | Parameters | Returns | Use Case |
|----------|--------|------------|---------|----------|
| [path] | [GET/POST] | [key params] | [What it returns] | [Why this endpoint] |

### Pagination Design

- **Method:** [Offset / Cursor / Link header / Keyset]
- **Page size:** [Records per page]
- **Last page detection:** [How to know extraction is complete]
- **Estimated pages per run:** [Count based on data volume]
- **Resume on failure:** [How to restart from last successful page]

### Rate Limit Handling

- **Published limit:** [Rate limit from API docs]
- **Throttling strategy:** [Proactive / Reactive / Both]
- **Backoff method:** [Fixed / Exponential / Retry-After header]
- **Budget allocation:** [If shared with other pipelines]
- **Estimated extraction time:** [Based on data volume and rate limits]

### Response Parsing

**Response structure:**

{

"data": [ ... ],

"pagination": { "next_cursor": "..." },

"meta": { "total_count": N }

}


**Field mapping:**

| API Field | Target Column | Type Conversion | Notes |
|-----------|---------------|-----------------|-------|
| [api_field] | [target_col] | [Conversion] | [Notes] |

**Nested data handling:** [Flattening rules for nested objects/arrays]

### Error Handling

| Error | Detection | Action | Max Retries | Alert |
|-------|-----------|--------|-------------|-------|
| 401 Unauthorized | HTTP status 401 | Refresh token; retry | 1 | Critical if refresh fails |
| 429 Rate Limited | HTTP status 429 | Wait for Retry-After; backoff | 5 | Warning after 3rd retry |
| 500 Server Error | HTTP status 5xx | Exponential backoff | 3 | Critical after all retries |
| Timeout | No response in [N]s | Retry with same params | 3 | Warning |
| Schema change | Missing expected field | Log; continue with available fields | 0 | Warning |

### Extraction Summary

- **Estimated total requests per run:** [Count]
- **Estimated extraction time:** [Duration]
- **Estimated data volume per run:** [Rows and bytes]
- **Recommended schedule:** [Frequency and time]

Rules

  1. NEVER include actual API keys, tokens, or credentials in the extraction design -- use placeholder references to a secrets manager
  2. ALWAYS specify the pagination strategy -- without it, the extraction will only retrieve the first page of results
  3. Rate limit handling must be proactive (throttle before hitting limits), not only reactive (wait after getting a 429) -- proactive throttling is more reliable and does not risk API key suspension
  4. The incremental extraction state (last timestamp, last ID, last cursor) must be stored durably outside the pipeline execution -- if the state is only in memory, a crash loses the extraction position
  5. NEVER assume API response schemas are stable -- include a schema change detection strategy (log unexpected fields, alert on missing required fields)
  6. Error handling must distinguish between retryable errors (429, 5xx, timeout) and non-retryable errors (400, 403, 404) -- retrying a 400 Bad Request wastes rate limit budget
  7. Estimated extraction time must account for rate limits AND pagination -- the total time = (total pages x page request time) + (total requests / rate limit) whichever is larger
  8. This skill produces the extraction DESIGN, not executable code -- describe the logic, parameters, and flow, not the implementation
  9. Backfill strategy must be defined at design time -- every API extraction eventually needs a backfill (initial load, catch-up after downtime, schema migration)
  10. ALWAYS include an extraction time estimate based on rate limits and data volume -- this determines whether the extraction fits within the pipeline's time window

Edge Cases

Example

Input: "Design data extraction from the HubSpot CRM API to pull contact records into our data warehouse. We have about 50,000 contacts and need daily updates."

Output:

API Data Extraction Design: HubSpot CRM Contacts

API Assessment

| Attribute | Value |

|-----------|-------|

| API type | REST (HubSpot CRM API v3) |

| Base endpoint | /crm/v3/objects/contacts |

| Data format | JSON |

| Rate limit | 100 requests per 10 seconds (private app), 150,000 requests per day |

| Authentication | Private app access token (Bearer token in Authorization header) |

| Documentation | HubSpot Developer Docs - CRM API |

Authentication Design

Data Retrieval Strategy

| Endpoint | Method | Parameters | Returns | Use Case |

|----------|--------|------------|---------|----------|

| /crm/v3/objects/contacts/search | POST | filterGroups (hs_lastmodifieddate > timestamp), properties list, limit, after | Matching contacts with requested properties | Incremental extraction |

| /crm/v3/objects/contacts | GET | limit, after, properties | All contacts (paginated) | Full backfill only |

Pagination Design

Rate Limit Handling

Response Parsing

Response structure:

{
  "total": 487,
  "results": [
    {
      "id": "123",
      "properties": {
        "email": "jane@example.com",
        "firstname": "Jane",
        "lastname": "Doe",
        "company": "Acme Corp",
        "lifecyclestage": "customer",
        "hs_lastmodifieddate": "2026-02-25T14:30:00.000Z"
      },
      "createdAt": "2025-01-15T10:00:00.000Z",
      "updatedAt": "2026-02-25T14:30:00.000Z"
    }
  ],
  "paging": {
    "next": {
      "after": "cursor_token_abc"
    }
  }
}

Field mapping:

| API Field | Target Column | Type Conversion | Notes |

|-----------|---------------|-----------------|-------|

| id | hubspot_contact_id | String to BIGINT | HubSpot's internal ID |

| properties.email | email | None (VARCHAR) | May be null for some contacts |

| properties.firstname | first_name | None (VARCHAR) | May be null |

| properties.lastname | last_name | None (VARCHAR) | May be null |

| properties.company | company_name | None (VARCHAR) | May be null |

| properties.lifecyclestage | lifecycle_stage | None (VARCHAR) | Enumerated: subscriber, lead, mql, sql, opportunity, customer, evangelist |

| properties.hs_lastmodifieddate | last_modified_at | String to TIMESTAMP (UTC) | Used as incremental key |

| createdAt | created_at | String to TIMESTAMP (UTC) | Contact creation date |

Nested data handling: The "properties" object is flattened: each property becomes a top-level column in the target table. Only the 7 properties listed above are extracted (specified in the request's "properties" parameter to minimize response size).

Error Handling

| Error | Detection | Action | Max Retries | Alert |

|-------|-----------|--------|-------------|-------|

| 401 Unauthorized | HTTP status 401 | Log error; do NOT retry (manual token fix needed) | 0 | CRITICAL: "HubSpot token invalid" to #data-alerts |

| 429 Rate Limited | HTTP status 429 | Wait Retry-After seconds; exponential backoff | 5 | WARNING after 3rd occurrence in single run |

| 500/502/503 Server Error | HTTP status 5xx | Exponential backoff (1s, 2s, 4s, 8s) | 3 | CRITICAL after all retries fail |

| Timeout (no response in 30s) | Response timeout | Retry same request | 3 | WARNING |

| Unexpected response format | Missing "results" key | Log full response; skip page; continue | 0 | WARNING: "Schema change detected" |

Extraction Summary

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.