Skip to content

Sraman01-code/mock_api_testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Offline Mock API

A zero-dependency REST API for testing local API GUI tools while offline.

Run

Recommended:

.\start-api.ps1

Stop it later with:

.\stop-api.ps1

Foreground mode, useful when you want to see logs directly:

python server.py --host 127.0.0.1 --port 8000

Then open:

  • Docs: http://127.0.0.1:8000/docs
  • OpenAPI import URL: http://127.0.0.1:8000/openapi.json
  • Health check: http://127.0.0.1:8000/api/health

Run a quick check:

.\smoke-test.ps1

Authentication

Login with:

{
  "email": "admin@example.com",
  "password": "password123"
}

Protected endpoints accept this header:

Authorization: Bearer offline-demo-token

Useful Endpoints

Method Endpoint Purpose
GET /api/health Health check
POST /api/auth/login Return bearer token
GET, POST /api/echo Echo headers, query params, and JSON body
GET /api/delay?ms=1000 Test timeout/loading behavior
GET /api/error?code=500 Force JSON error responses
GET /api/products?q=keyboard&in_stock=true Public product listing and filtering
POST /api/products Create product, protected
GET, POST /api/users User collection, protected
GET, PATCH, DELETE /api/users/{id} User resource, protected
GET, POST /api/orders Order collection, protected
GET, PATCH, DELETE /api/orders/{id} Order resource, protected

Sample Bodies

Create user:

{
  "name": "Sam Tester",
  "email": "sam@example.com",
  "password": "password123",
  "role": "user"
}

Create product:

{
  "sku": "USB-C-HUB",
  "name": "USB-C Hub",
  "price": 59.99,
  "stock": 25,
  "tags": ["hardware", "accessory"]
}

Create order:

{
  "user_id": 2,
  "items": [
    { "product_id": 1, "quantity": 1 },
    { "product_id": 2, "quantity": 2 }
  ]
}

Notes

  • Data is stored in memory and resets each time the server restarts.
  • CORS is enabled for browser-based GUI clients.
  • Responses include X-Request-Id; you can also send your own X-Request-Id header.
  • Request bodies are limited to 1 MB.

About

A zero-dependency REST API for testing local API GUI tools while offline.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors