Skip to main content

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

With uv:

uv tool install apiup

With validation support:

pip install 'apiup[validate]'

Convention: ~/.openapi/

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

~/.openapi/spec.json      ← preferred
~/.openapi/spec.yaml      ← fallback

Optional config:

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

Usage

apiup                          # reads ~/.openapi/spec.json, 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 --validate               # validate spec against OpenAPI 3.x schema
apiup --version
apiup --help

Example session

$ apiup --validate
   Validating: /home/roebi/.openapi/spec.json
   OpenAPI   : 3.0.3
   Title     : My API v1.0.0
   ✓ spec valid  (7 route(s))

$ apiup --list
Routes in: /home/roebi/.openapi/spec.json

  GET      /skills        # List all skills
  POST     /skills        # Create a new skill
  GET      /skills/{id}   # Get skill details
  DELETE   /skills/{id}   # Delete a skill

4 route(s) found.

$ apiup
⚡ apiup 0.6.0 — My API v1.0.0
   Spec  : /home/roebi/.openapi/spec.json
   Mode  : mock
   Listen: http://127.0.0.1:8080
   Docs  : http://127.0.0.1:8080/docs
   Spec  : http://127.0.0.1:8080/spec.json
   Routes: 4

$ curl http://localhost:8080/skills
[{"id": "create-agent-skill-en", "name": "Create Agent Skill", "version": "1.0.0"}]

Built-in endpoints

Every apiup instance exposes two additional routes:

Endpoint Description
GET /docs Swagger UI (no extra dependencies)
GET /spec.json Raw OpenAPI spec served directly

Mock behaviour

In mock mode apiup:

  • Registers one route handler per [METHOD] /path in the spec
  • Returns the first example value found in the spec responses
  • Falls back to {"_mock": true, "note": "no example in spec"} if none present
  • Returns 204 No Content with no body for routes that declare it
  • Resolves local $ref pointers in spec components

Add example: fields to your spec responses to get real data back:

/skills:
  get:
    responses:
      "200":
        content:
          application/json:
            example:
              - id: create-agent-skill-en
                name: Create Agent Skill
                version: "1.0.0"

Server modes

Mode Status Description
mock ✓ available returns spec examples
proxy planned forwards requests to a real backend
record planned proxy + saves real responses as spec examples

Validation

pip install 'apiup[validate]'
apiup --validate
apiup --validate --spec ./my-api.yaml

# use in CI — exits 1 if spec is invalid
apiup --validate || exit 1

Requires openapi-spec-validator. If not installed, --validate warns but does not block startup.

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, cfg.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

CC BY-NC-SA 4.0 — see LICENSE.

Part of the roebi agent-skills ecosystem.

Metadata

Release files for apiup 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for apiup 0.7.0
File Size Uploaded
apiup-0.7.0.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for apiup 0.7.0
File Interpreter ABI Platform
apiup-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.7 kB

Release files / apiup-0.7.0.tar.gz

Download URL apiup-0.7.0.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
097b758161b2f9940029a292f92701a4e9da8a91b8c26eb1dce22a0831a32c29
BLAKE2b-256 checksum
How to use checksums
6e95414cde68d71e29568f8da3a0afa2dc52ac5bde6d4c2d51c235b36a3d5fb6
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release files / apiup-0.7.0-py3-none-any.whl

Download URL apiup-0.7.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a1697fd8bee5175f74de59b1acd35523e2391654f492b0736b8124078aaf2fc
BLAKE2b-256 checksum
How to use checksums
ebc930e056d7d172c24f24cc2bcf7f5acc5067b7fae62c97be89bf3297263c06
Upload date
Uploaded using Trusted Publishing?
What is 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}

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page