API Automation

RESTful Booker API Automation

REST API Testing Framework with Playwright & TypeScript

An independent API test automation case study using Playwright and TypeScript to test the public RESTful Booker demo API: authentication, booking create, read, update and delete, negative cases and multi-step workflows, run in GitHub Actions.

RESTful Booker TypeScript API Automation: project coverCover for RESTful Booker TypeScript API Automation: 47 test definitions (9 spec files). Booking lifecycle covered by the suite: authenticate, create, read, update with PUT and PATCH, delete. Built with Playwright, TypeScript, REST API.API AUTOMATIONRESTful BookerTypeScript APIAutomationPlaywright · TypeScript · REST API47test definitions9 spec files1AuthPOST /auth2CreatePOST3ReadGET4UpdatePUT · PATCH5DeleteDELETEBooking lifecycle, negative cases and read-back checkssayedasif.comRESTful Booker TypeScript API Automation: project coverCover for RESTful Booker TypeScript API Automation: 47 test definitions (9 spec files). Booking lifecycle covered by the suite: authenticate, create, read, update with PUT and PATCH, delete. Built with Playwright, TypeScript, REST API.RESTful BookerTypeScript APIAutomation47test definitions9 spec filesPlaywright · TypeScript · REST APIAuthCreateReadUpdateDelete
Playwright Test Framework
TypeScript Language
5 HTTP Methods
GitHub CI/CD

01 Context

Project Context

This is an independent, public QA automation project built to show how I structure and run API tests. The target is the RESTful Booker API, a public booking system designed for API testing practice.

The project prioritizes code quality, maintainability, and clarity. It demonstrates how to design reusable API clients, organize test suites effectively, and structure meaningful test coverage rather than simply increasing test count.

02 System under test

API Testing Workflow

The test suite validates a complete API lifecycle:

API testing workflow Six steps in order: authenticate, create, retrieve, update, patch, delete. 1Authenticate 2Create 3Retrieve 4Update 5Patch 6Delete API testing workflow Six steps in order: authenticate, create, retrieve, update, patch, delete. 1Authenticate 2Create 3Retrieve 4Update 5Patch 6Delete

This flow validates state management, data persistence, and the correctness of multi-step API interactions. Each step verifies response structure, data integrity, and error handling.

03 Approach

An API client method, from the repository

async post<T>(endpoint: string, payload: RequestPayload, token?: string): Promise<T> {
  const headers = this.getHeaders(token);
  const response = await this.request.post(`${this.baseURL}${endpoint}`, {
    headers,
    data: payload,
  });
  return response.json();
}
  // ...
  if (token) {
    headers['Cookie'] = `token=${token}`;
  }
APIClient.post and the token header, condensed. The booking client calls these, for example createBooking() is this.post('/booking', booking). src/api/clients/api-client.ts, lines 17–24, 86–88 @ a385240 (opens in a new tab)

04 Coverage

Test Coverage

47 tests organized across 9 suites covering distinct API concerns:

Health Check
1
Authentication
5
Create
7
Retrieve
6
Update (Full)
6
Update (Partial)
5
Delete
6
Negative Testing
8
Workflows
3

05 HTTP methods

HTTP Methods Coverage

The tests send GET, POST, PUT, PATCH and DELETE requests. They pin the status codes RESTful Booker actually returns, listed under Testing Strategy below. Some are not the textbook code: a PUT or DELETE on a booking that does not exist gets 405, and a failed login gets 200.

GET
Retrieve booking data
POST
Create new bookings
PUT
Replace booking entirely
PATCH
Partial booking updates
DELETE
Remove booking

06 Strategy

Testing Strategy

Status Code Validation

22 of the 47 tests assert a status code. These are all the codes asserted, by request, with the number of tests that assert each:

  • GET /ping: 201 (1 test)
  • POST /auth: 200 (3 tests)
  • POST /booking: 200 (1 test), 500 (2 tests)
  • GET /booking/{id}: 404 (6 tests)
  • PUT /booking/{id}: 400 (1 test), 403 (2 tests), 405 (1 test)
  • PATCH /booking/{id}: 403 (1 test)
  • DELETE /booking/{id}: 403 (2 tests), 405 (2 tests)

No test asserts a 401. The status of a successful create, update, patch or delete is not asserted either, because the client helpers that return a parsed body do not check it. The 200 on POST /auth is a failed login (the body carries a reason), and the 500 is a booking missing a required field.

Response Structure

Validate JSON payload structure, data types, and required fields

Data Integrity

Confirm sent data matches retrieved data and persists across requests

Authentication

Test token creation, validation, and rejection of invalid credentials

Negative Testing

Validate API behavior with invalid inputs, edge cases, and error scenarios

Workflow Validation

Test multi-step sequences and state management across requests

07 Architecture

Framework Architecture

The layout of the repository at the pinned commit (a385240): client classes, models and test data under src/api, and one spec file per area under tests/api.

src/api/ ├── clients/ │ ├── api-client.ts (base class) │ ├── auth-client.ts │ └── booking-client.ts ├── models/ │ └── booking.types.ts ├── test-data/ │ └── booking-data.ts └── config.ts tests/api/ ├── auth.spec.ts ├── booking-create.spec.ts ├── booking-delete.spec.ts ├── booking-partial-update.spec.ts ├── booking-read.spec.ts ├── booking-update.spec.ts ├── health-check.spec.ts ├── negative-testing.spec.ts └── workflow.spec.ts playwright.config.ts .github/workflows/playwright.yml

Key Design Principles:

  • Reusable API Clients — A base APIClient holds the HTTP calls and headers; AuthClient and BookingClient add one named method per endpoint. Four tests send a raw request instead: the health check, two malformed booking IDs and a PATCH without a token.
  • TypeScript Interfaces — booking.types.ts defines interfaces for a booking and the two responses, which type the test data and the client methods. They are checked at compile time only; nothing validates a response against them at run time.
  • Centralized Test Data — src/api/test-data/booking-data.ts exports four sample bookings. The specs use three of them (validBooking, updatedBooking and bookingWithoutAdditionalNeeds); validBooking2 is not used. There are no Playwright fixtures: each test creates its own bookings.
  • Clean Test Organization — One spec file per operation (create, read, update, partial update, delete), plus health check, authentication, negative cases and workflows: nine files under tests/api.
  • Assertions — Status codes (22 of the 47 tests), response fields and a read-back after writes. Three negative tests cannot fail and the delete test checks only that the reply is truthy (see Negative Testing below).

08 Negative tests

Negative Testing

The test suite includes 8 negative tests, covering these areas:

  • Invalid Credentials
  • Invalid IDs
  • Invalid Inputs
  • Missing Fields
  • Edge Cases

Two of the eight assert a rejection (an incomplete PUT returns 400, a non-numeric ID returns 404). The other six record input this practice API accepts: zero and negative prices, an invalid date, a checkout before the check-in, special characters in the login and a 1,000-character name. Three of those six use expect(response.ok).toBeTruthy() without calling ok(), so the assertion cannot fail. The article explains what I would change.

09 Skills

What This Project Demonstrates

  • API Testing
  • TypeScript
  • Test Architecture
  • Negative Testing
  • CI/CD Automation

10 Evidence

Evidence & Verification

Source code, tests and the CI workflow are public on GitHub. CI run logs and report artifacts need a GitHub sign-in. Artifacts are kept for 30 days, so those from the 10 September runs have expired.

  • Source Code

    The Playwright Test project: API client classes, models, test data and the 47 test definitions.

  • CI/CD Execution

    GitHub Actions workflow that runs the tests on every push and pull request to main. Its run history has 3 runs: two on 10 September 2026 (the first failed, the second passed) and one on 22 October 2026 (passed; by my reading of its job log, no retry). Job logs require a GitHub sign-in.

  • Documentation

    README file with project structure, test descriptions, setup instructions, and framework architecture overview.

Explore the Project

Inspect the complete source code, test suites, CI/CD configuration, and documentation on GitHub.

For the decisions and weaknesses behind these tests, read API Testing Lessons from a Playwright and TypeScript Suite. To see which API risks these tests do and do not cover, next to my other two repositories, see the API testing evidence map. If you need similar API testing, see QA Services.