Skip to content
Mock APIs

Getting started

Getting started

Every endpoint follows the same conventions. Learn them once and the rest of the API is predictable.

URLs and versioning

Endpoints are grouped under /api/v1. Resources use plural nouns, records are addressed by numeric ID, and relationships are nested one level deep:

URL patterns
GET https://test.naimulhassan.me/api/v1/users
GET https://test.naimulhassan.me/api/v1/users/1
GET https://test.naimulhassan.me/api/v1/users/1/posts
GET https://test.naimulhassan.me/api/v1/posts/search?q=coffee

IDs are positive integers. A malformed ID such as /users/abc returns 400 INVALID_ID; a well-formed ID that does not exist returns 404 RESOURCE_NOT_FOUND.

JSON in, JSON out

Responses are JSON with Content-Type: application/json (except placeholder images, which are SVG). Request bodies must be JSON objects sent with Content-Type: application/json; other content types get 415, malformed JSON gets 400 INVALID_JSON, and bodies over 100 KB get 413.

Methods and status codes

HTTP methods
MethodPurposeSuccess
GETRead lists, single records, searches, and relations200
POSTCreate a record (simulated)201
PUTReplace a record with a complete body (simulated)200
PATCHUpdate some fields of a record (simulated)200
DELETEDelete a record (simulated)204 (empty body)

Using a method a route does not support returns 405 METHOD_NOT_ALLOWED with an Allow header listing the supported methods.

Simulated writes

Users, products, posts, comments, and todos accept POST, PUT, PATCH, and DELETE. The API validates the body, checks that referenced records exist (for example a comment's postId), detects conflicts such as duplicate emails, and returns what the record would look like. Nothing is stored, so a follow-up GET returns the original data. Simulated responses include this header:

Response header
X-MockAPIs-Simulated: true

Building a CRUD app?

Keep created and edited records in your client state (or a local store) and use the API responses as the source of truth for IDs and validation.

Carts, recipes, and quotes are read-only.

Useful response headers

Response headers
HeaderMeaning
X-Request-IdUnique ID for the request. Also included in error bodies. You may send your own (8-64 letters, digits, ".", "_" or "-").
X-Response-TimeServer processing time, e.g. 3.2ms.
X-MockAPIs-SimulatedPresent on simulated writes.
RateLimit-Limit / -Remaining / -ResetYour current rate-limit window. See Rate limits.
Retry-AfterSeconds to wait, sent with 429 and 503 responses.

About the data

Synthetic and deterministic

Every record is generated from a fixed seed, so the same request returns the same data on every deployment. Names are fictional, emails use example.com, and phone numbers use the reserved 555-01xx range. No real person's data is included.

Images

image and thumbnail fields point to deterministic SVG placeholders served by the API itself, so they never expire and do not depend on a third-party image host.

Next

Continue with Pagination & query params or jump into a resource such as Users.