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.4.0.tar.gz (9.8 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.4.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: apiup-0.4.0.tar.gz
  • Upload date:
  • Size: 9.8 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.4.0.tar.gz
Algorithm Hash digest
SHA256 55e717af2bee06dd2510b64abab6b5bee13b880dc177941d9b0c5a283ed2d357
MD5 2e14bb4abf93e0a4463e5ef3835f91ce
BLAKE2b-256 f79582a3ef76a142168f8fa6480bd957ba127f1ddd02055db8184a934ab7ba82

See more details on using hashes here.

File details

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

File metadata

  • Download URL: apiup-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2d33173b658c17f35fa0dc8cef48318f491c9bed1f06de22f1354ac59d1bc281
MD5 d7e3e8ba909d57130562135de7d216c6
BLAKE2b-256 e0f73f91a4f97242330accad14d70b81982d119307ffdffc0b13663393a0ecc2

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