Skip to main content

Start a local mock REST API server from an OpenAPI 3.x spec. Convention: reads ~/.openapi/spec.yaml by default.

Project description

apiup

⚡ Start a local mock REST API server from an OpenAPI 3.x spec — one command.

CI PyPI Python License: CC BY-NC-SA 4.0

Install

pip install apiup

Or with uv:

uv tool install apiup

Convention: ~/.openapi/

apiup follows an XDG-style user convention — place your default spec at:

~/.openapi/spec.yaml

Optional config:

# ~/.openapi/config.yaml
port: 8080
host: 127.0.0.1
mode: mock
spec: ~/.openapi/spec.yaml

Usage

apiup                          # reads ~/.openapi/spec.yaml, starts on :8080
apiup --spec ./my-api.yaml     # custom spec path
apiup --port 9000              # custom port
apiup --host 0.0.0.0           # bind all interfaces
apiup --list                   # list routes without starting server
apiup --version
apiup --help

Example session

$ apiup --list

Routes in: /home/roebi/.openapi/spec.yaml

  GET      /                      # Health check
  GET      /items                 # List all items
  POST     /items                 # Create an item
  GET      /items/{id}            # Get item by ID
  DELETE   /items/{id}            # Delete item by ID

5 route(s) found.

$ apiup
⚡ apiup 0.1.0 — My API v1.0.0
   Spec  : /home/roebi/.openapi/spec.yaml
   Mode  : mock
   Listen: http://127.0.0.1:8080
   Docs  : http://127.0.0.1:8080/schema/swagger
   Routes: 5

$ curl http://localhost:8080/items
[{"id": 1, "name": "Widget", "price": 9.99}]

Python API

from apiup.spec import load_spec, extract_routes
from apiup.mock import extract_mock_response
from apiup.server import build_mock_app, serve
from apiup.config import load_config

cfg    = load_config(spec="./my-api.yaml", port=9000)
spec   = load_spec(cfg.spec)
routes = extract_routes(spec)
app    = build_mock_app(routes, spec)
serve(app, host=cfg.host, port=cfg.port)

Development

uv sync --all-extras
uv run pytest
uv run ruff check .
uv run ruff format .

License

MIT License — see LICENSE.

Part of the roebi agent-skills ecosystem.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

apiup-0.6.0.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

apiup-0.6.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file apiup-0.6.0.tar.gz.

File metadata

  • Download URL: apiup-0.6.0.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for apiup-0.6.0.tar.gz
Algorithm Hash digest
SHA256 7792fab457018bf6f9a79c8d4e99372f1c1d7537ff9946f2672ab543313c0b65
MD5 89a249734ea35129530b129deace0f32
BLAKE2b-256 0da6206ab3c55c9ecc9a57acb32762985baf37e136431a484e274936f075563b

See more details on using hashes here.

File details

Details for the file apiup-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: apiup-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for apiup-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f23258e6296416585f3b8ca6d89c876e670778773f6e5386cb68ca1bdd22144f
MD5 4742ceef2653e8233929afed6ab8ccd5
BLAKE2b-256 01bf7bbc372aabe999ea0ecdae36ac3e3fe2fc8cfda112ab6f4aa81b5c1d72be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page