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 with a WSDL and a countries service, 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.