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.3.0.tar.gz (9.7 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.3.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: apiup-0.3.0.tar.gz
  • Upload date:
  • Size: 9.7 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.3.0.tar.gz
Algorithm Hash digest
SHA256 aeaed3c9314e5b3518e14da776d5d53733417cbf9f5ed36e47bea46a8d1b8e07
MD5 23d9f8d53156113211e204fe4de8b4c6
BLAKE2b-256 9e177227d04184c4889ff6d6fb60a43b51d99e752539116055221861a0d5d344

See more details on using hashes here.

File details

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

File metadata

  • Download URL: apiup-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 323a3a779f1af5e057022ce9971cc040b74530a70875167ab6101b7756bbcddd
MD5 20fac09fd8e056e0093e9f015b8f4288
BLAKE2b-256 f1bd134c1323e5fd22f87f2636554908537e8754562d0707c2b74b9b47ca0000

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