Documentation / API Testing

    API Testing Patterns

    Real-world techniques for testing REST, GraphQL, and WebSocket APIs with Apicurl using environments, variables, and reusable examples.

    1. Cover the Happy Path First

    Start by making sure your core flows work end to end. For most products, this means authentication, a handful of core CRUD operations, and any billing or payment flows. Model each step as a request in Apicurl, then group them into a collection that can be run as a whole.

    2. Add Critical Error Scenarios

    Once the happy path is stable, add tests that validate how your API behaves under failure: invalid tokens, missing permissions, rate limits, and invalid payloads. These tests should assert on both HTTP status codes and response bodies so you can catch regressions in error semantics, not just success responses.

    3. Use Examples for Integration Flows

    Many APIs depend on third-party services such as GitHub, Stripe, OpenAI, or Slack. The examples at /examples give you ready-made requests that demonstrate best practices for calling these APIs from Apicurl.

    Adapt those examples to your own accounts and credentials, then use them as part of your staging and production checks to ensure integrations keep working over time.

    4. Test Pagination, Caching, and Rate Limits

    For APIs that return lists, test pagination using parameters such as page, cursor, or limit. Verify that responses include next-page markers and that clients can safely request the next batch without missing or duplicating data.

    When rate limits are involved, include checks that intentionally exceed the limit in a safe environment so you understand the responses your clients will see in production.

    5. Include GraphQL and Real-Time APIs

    GraphQL and WebSocket APIs deserve the same level of attention as REST. Use Apicurl to send GraphQL queries and mutations with variables, and to attach headers such as auth tokens or tenant IDs.

    For WebSockets and server-sent events, focus on connection lifecycle: establishing a connection, subscribing to the right channels, and handling disconnects or error frames gracefully.

    6. Automate the Most Important Checks

    Pair these patterns with the CLI & Automation guide so your most important scenarios run automatically in CI or on a schedule. That way changes to upstream providers, infrastructure, or application code are caught quickly rather than surfacing as user-facing incidents.