Guides
API testing guides
Each guide solves one task against the free API at api.testingapis.com: making a request fail on purpose, calling a SOAP service, testing an auth flow, walking every page of a list. The requests and code were run against the live API, and the responses shown are the ones it returned.
For the concepts behind them, follow the API testing tutorial. For every endpoint and parameter, see the API documentation.
- A mock API that returns errors on demandGet a 500, a 429 with Retry-After, a timeout or a truncated body whenever your tests need one.
- A free SOAP API for testing, with a WSDLA calculator service and a countries service, each with a WSDL, both answering SOAP 1.1 and 1.2.
- Test endpoints for every API authentication schemeBasic, Digest, bearer tokens, API keys, HMAC signatures, JWT, OAuth 1.0a and OAuth 2.0 with PKCE, with credentials.
- API pagination examples: offset, page, cursor, keyset, Link header and HALSix pagination styles over the same data, with a live response and a fetch-every-page loop for each.
- A JSONPlaceholder alternative where writes are savedThe same kinds of resources, but writes are saved, bad input is rejected and errors are available on demand.
- Test HTTP 503 handling in C# with HttpClientWhat HttpClient does with a 503, a DelegatingHandler that honours Retry-After, and xUnit tests against a live API.
- Test multipart/form-data file uploadsUpload a file in curl, JavaScript, Python and C#, see exactly what the server received, and avoid the boundary mistake.
- HttpClient timeouts and cancellation tokens in C#Timeouts versus cancellations, a per-request timeout helper, the ResponseHeadersRead gap, and tests against a slow API.
- Handle malformed JSON in .NET with System.Text.JsonWhat ReadFromJsonAsync does with broken and awkward JSON, which cases don't throw, and a reader that turns each into a clear error.
- API integration tests with xUnitSix xUnit tests against a live Todos API, the rules for testing a shared API, and a GitHub Actions workflow to run them.
- Free fake APIs compared: what each one does with a writeThe same requests sent to four free APIs, with the results and which one to pick.
- An httpbin alternative with the same routes and moreSwap each httpbin route for its match, with the field names that change.
- API testing practice: 10 exercises on a free live APITen exercises from a first GET to retries, each with the result to assert.
- A free GraphQL API for testing, with saved mutationsQueries, variables, saved mutations and error responses on a public endpoint.
- A free WebSocket echo server for testingAn echo server and a push ticker, with the close codes and a small test.