REST Assured Practice API

A sandbox API for learning REST Assured and API automation testing. All data is static and deterministic.

Base URL: https://testkru.com/api

Credentials Reference

Basic Auth: admin / secret123
API Key header: X-API-Key: testkey123
Login: POST /auth/login with username & password above

Users

GET /api/users

Returns all 5 users.

Response
[
  {"id": 1, "name": "John Doe", "email": "john@example.com", "age": 30, "city": "New York"},
  {"id": 2, "name": "Jane Smith", "email": "jane@example.com", "age": 25, "city": "London"},
  {"id": 3, "name": "Bob Wilson", "email": "bob@example.com", "age": 35, "city": "Paris"},
  {"id": 4, "name": "Alice Brown", "email": "alice@example.com", "age": 28, "city": "Berlin"},
  {"id": 5, "name": "Charlie Davis", "email": "charlie@example.com", "age": 32, "city": "Tokyo"}
]
GET /api/users/{id}

Returns a single user by ID (1-5). Returns 404 if not found.

Response (id=1)
{"id": 1, "name": "John Doe", "email": "john@example.com", "age": 30, "city": "New York"}
Error (id=99)
{"error": "User with id 99 not found. Valid user IDs: 1-5", "status": 404}
POST /api/users

Creates a user (simulated). Requires name and email in JSON body. Returns 201 with id: 6.

Request Body
{"name": "Test User", "email": "test@example.com", "age": 25, "city": "Mumbai"}
Response (201)
{"id": 6, "name": "Test User", "email": "test@example.com", "age": 25, "city": "Mumbai"}
PUT /api/users/{id}

Full replacement update. Requires name and email. Returns 400 if missing.

Error (missing email)
{"error": "Missing required field(s): email. Required fields: name, email", "status": 400}
PATCH /api/users/{id}

Partial update. Merges provided fields with existing user data. Unchanged fields keep their original values.

DELETE /api/users/{id}

Deletes a user (simulated). Returns 204 No Content with empty body.

OPTIONS /api/users

Returns allowed HTTP methods in the Allow header.

Allow header
GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
HEAD /api/users

Same headers as GET but no response body.

Products

GET /api/products

Returns 5 products with nested category and specs objects.

Response (single item shown)
{
  "id": 1,
  "name": "Laptop Pro",
  "price": 1299.99,
  "category": {"id": 1, "name": "electronics"},
  "specs": {"weight": "1.5kg", "color": "silver", "inStock": true}
}
GET /api/products/{id}

Returns a single product by ID (1-5).

GET /api/categories/{category}/products

Filter products by category. Valid: electronics, books, furniture.

Response (/categories/electronics/products)
[
  {"id": 1, "name": "Laptop Pro", ...},
  {"id": 2, "name": "Wireless Mouse", ...},
  {"id": 5, "name": "Mechanical Keyboard", ...}
]

Books

GET /api/books

Returns 5 books with nested author object, tags array, and rating.

Response (single item shown)
{
  "id": 1,
  "title": "The Great Gatsby",
  "author": {"name": "F. Scott Fitzgerald", "nationality": "American"},
  "tags": ["fiction", "classic", "literature"],
  "rating": 4.5
}
GET /api/books/{id}

Returns a single book by ID (1-5).

Status Codes

GET /api/status/{code}

Returns the specified HTTP status code (100-599) with a JSON body describing it.

Response (418)
{"status": 418, "message": "I'm a teapot"}

Headers

GET /api/headers/echo

Echoes all request headers back as JSON. Header names are uppercased.

Response
{"headers": {"HOST": "testkru.com", "X-CUSTOM": "hello", ...}}
GET /api/headers/custom

Returns custom response headers.

Response Headers
X-App-Version: 1.0
X-Request-Id: req-testkru-001
Cache-Control: no-cache
GET /api/accept

Content negotiation. Returns JSON or XML based on Accept header.

Accept: application/json → Response
{"format": "json", "message": "Response in JSON format"}
Accept: application/xml → Response
<response><format>xml</format><message>Response in XML format</message></response>

Authentication

GET /api/auth/basic 10 req/min

Requires HTTP Basic Auth. Credentials: admin / secret123.

Response (200)
{"message": "Basic auth successful", "user": "admin"}
POST /api/auth/login 10 req/min

Returns a JWT token. Use with /auth/protected.

Request Body
{"username": "admin", "password": "secret123"}
Response (200)
{"token": "eyJ...", "user": "admin"}
GET /api/auth/protected 10 req/min

Requires Bearer token from /auth/login.

Header Required
Authorization: Bearer <token>
Response (200)
{"message": "Access granted", "user": "admin"}
Error (401 — no token)
{"error": "Missing Bearer token. Send Authorization: Bearer <token> header. Get a token from POST /api/auth/login"}
GET /api/auth/apikey 10 req/min

Requires X-API-Key: testkey123 header.

Response (200)
{"message": "Valid API key", "key": "testkey123"}

XML Responses

GET /api/xml/users

Returns users as XML. Content-Type: application/xml.

Response
<users>
  <user>
    <id>1</id>
    <name>John Doe</name>
    <email>john@example.com</email>
    <age>30</age>
    <city>New York</city>
  </user>
  ...
</users>
GET /api/xml/products

Returns products as XML with flat structure (no nested objects).

Response
<products>
  <product>
    <id>1</id>
    <name>Laptop Pro</name>
    <price>1299.99</price>
    <category>electronics</category>
    ...
  </product>
  ...
</products>

Cookies

GET /api/cookies/set

Sets two cookies via Set-Cookie headers: session_id=abc123 and theme=dark.

Response Body
{"message": "Cookies have been set", "cookies": {"session_id": "abc123", "theme": "dark"}}
GET /api/cookies/read

Returns all cookies sent by the client in the request.

Response
{"cookies": {"session_id": "abc123", "theme": "dark"}}
GET /api/search

Searches across a combined dataset of 15 items (5 users + 5 products + 5 books).

Query Parameters
query     - Search text (matches name/title)
category  - Filter: users, products, or books
sort      - asc (default) or desc
page      - Page number (default: 1)
limit     - Items per page (default: 5, max: 50)
Response
{
  "data": [{"name": "...", "category": "users", ...}, ...],
  "meta": {"page": 1, "per_page": 5, "total": 15, "last_page": 3}
}

Request Body

POST /api/echo

Echoes the JSON request body back verbatim.

Request
{"message": "Hello REST Assured", "framework": "REST Assured"}
Response (same)
{"message": "Hello REST Assured", "framework": "REST Assured"}
POST /api/validate/json

Validates that JSON body contains non-empty name and email fields.

Valid Response (200)
{"valid": true, "data": {"name": "Alice", "email": "alice@test.com"}}
Invalid Response (400)
{"valid": false, "errors": [
  "Field 'name' is required and must not be empty",
  "Field 'email' is required and must not be empty"
]}

Form Data

POST /api/form

Accepts application/x-www-form-urlencoded data and echoes params back.

Response
{
  "received": {"name": "John", "city": "New York"},
  "contentType": "application/x-www-form-urlencoded"
}

File Upload

POST /api/upload 10 req/min

Accepts multipart file upload (max 2MB). Returns file metadata. File is not stored.

Response
{"filename": "file.txt", "size": 1024, "mimeType": "text/plain"}

File Download

GET /api/download

Downloads a small CSV text file with Content-Disposition: attachment.

Response Delay

GET /api/delay/{seconds} 5 req/min

Delays the response by the specified number of seconds (max 3).

Response
{"delayed": 2, "message": "Response delayed by 2 seconds"}

Redirects

GET /api/redirect/{code}

Issues a redirect to /api/users. Valid codes: 301, 302, 303, 307.

Response Headers
HTTP/1.1 302 Found
Location: https://testkru.com/api/users

Orders (Request Chaining)

POST /api/orders 10 req/min

Creates an order by combining user and product data. Practice request chaining.

Request Body
{"userId": 1, "productId": 2}
Response (201)
{
  "orderId": "ORD-001",
  "user": {"id": 1, "name": "John Doe", "email": "john@example.com"},
  "product": {"id": 2, "name": "Wireless Mouse", "price": 29.99},
  "total": 29.99,
  "status": "confirmed"
}

JSON Schema

GET /api/schema/user

Returns the JSON Schema document for the User object. Use for JSON Schema validation.

GET /api/schema/product

Returns the JSON Schema document for the Product object (includes nested category and specs).

Error Format

All errors return a consistent JSON shape:

{"error": "User with id 99 not found. Valid user IDs: 1-5", "status": 404}