Version, diff, and visualize your OpenAPI spec
Project description
ApiLens
Automatically generate versioned API snapshots on every merge. Explore changes between any two versions in a UI with color-coded diff highlighting. Built for FastAPI + TypeScript teams.
How It Works
- Every time code merges to
main, a GitHub Actions workflow imports your FastAPI app, generates its OpenAPI spec, and compares it to the previous snapshot. If anything changed, it commits a new snapshot file to your repo underopenapi-snapshots/. - On every pull request, a second workflow computes the diff between the PR branch and the latest snapshot, and posts a comment summarizing what changed (comment can be disabled).
- Locally, run
apilens serveto browse and compare any two snapshots in a visual UI.
The openapi-snapshots/ folder is created automatically by the workflow on first run.
Features
- Automatic snapshots — captures your spec on every merge to
main; skips if nothing changed - Visual diff viewer — color-coded UI showing new, removed, and modified endpoints with field-level detail
- PR comments — posts a Markdown summary of API changes on every pull request
- AI prompts — one-click copy of prompts to help update frontend TypeScript types
- Zero integration — no changes to your FastAPI app; runs completely standalone
Requirements
Python 3.10 or higher. Check yours with:
python3 --version
Setup
1. Install
pip3 install "openapi-lens[serve]"
2. Copy apilens.toml into your project root
Grab [apilens.toml](apilens.toml) from this repo and place it at the root of your project. Edit one line:
[apilens]
app = "myapp.main:app" # ← change this to your FastAPI app's import path
This is the same path you'd pass to uvicorn — e.g. if you run uvicorn ocular.main:app, use "ocular.main:app". No secrets, safe to commit.
3. Copy the workflow files into your .github/workflows/
Grab both files from [workflow-templates/](workflow-templates/):
**openapi-snapshot.yml**— on every push tomain, generates your spec and commits a new snapshot toopenapi-snapshots/if anything changed**api-diff.yml**— on every PR, posts a comment showing exactly what endpoints and fields changed
Both use the built-in GITHUB_TOKEN — no secrets to configure.
4. Push to your repo
Commit and push the three files (apilens.toml, openapi-snapshot.yml, api-diff.yml). From this point:
- On the next merge to
main— the snapshot workflow fires automatically. It imports your app, generates the spec, and commits the firstopenapi-snapshots/<timestamp>.jsonfile to your repo. You can watch it run in your repo's Actions tab. - On every subsequent PR — the diff workflow fires automatically and posts a comment to the PR showing what changed.
You don't need to do anything else to keep snapshots running — it's fully automatic from here.
5. Browse snapshots
Once at least two snapshots exist in your repo (after the first merge to main), pull the latest changes and choose one of the two options below.
Note: the dropdowns will be empty until at least one snapshot exists. You need at least two snapshots to compare — meaning two separate merges to
mainthat each changed the API.
Option A — Local only
Run from your project root:
apilens serve
This starts the viewer at http://127.0.0.1:8765, visible only on your machine. ApiLens reads the snapshots_dir from your apilens.toml automatically.
Option B — Mount inside your FastAPI app (recommended for teams)
If you want the viewer deployed alongside your app so your whole team can access it, add these lines to your main.py:
import os
from apilens.viewer.app import mount
mount(app, path="/apilens", password=os.environ.get("APILENS_PASSWORD"))
Then set APILENS_PASSWORD in your server's environment variables. The viewer will be available at yourapp.com/apilens and anyone visiting it will be prompted for the password.
Disabling PR Comments
Set pr_comments = false in your apilens.toml:
[apilens]
pr_comments = false
Set it back to true to re-enable.
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openapi_lens-1.0.3.tar.gz.
File metadata
- Download URL: openapi_lens-1.0.3.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1718abe33e18e965ddcbfccb08bd4b092c38762bdd38ebeb72f166dd3f70832
|
|
| MD5 |
e2443e02ea320b2986f82b7890feb70a
|
|
| BLAKE2b-256 |
c79c750a20c602017c1cbe6ec91fca08bb32400b8465e164ad9acb39bb2dbbba
|
Provenance
The following attestation bundles were made for openapi_lens-1.0.3.tar.gz:
Publisher:
publish.yml on MariaC27/api-lens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_lens-1.0.3.tar.gz -
Subject digest:
b1718abe33e18e965ddcbfccb08bd4b092c38762bdd38ebeb72f166dd3f70832 - Sigstore transparency entry: 1353536111
- Sigstore integration time:
-
Permalink:
MariaC27/api-lens@07d2461e27fcef2b027a9b67e803e2a271841b46 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/MariaC27
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@07d2461e27fcef2b027a9b67e803e2a271841b46 -
Trigger Event:
push
-
Statement type:
File details
Details for the file openapi_lens-1.0.3-py3-none-any.whl.
File metadata
- Download URL: openapi_lens-1.0.3-py3-none-any.whl
- Upload date:
- Size: 17.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
402fe8cec5c16e32daf8136122deab701ecc3b2b8e0112128e2889e9cdb44f5b
|
|
| MD5 |
bf624896cc1b93b8aa1830123302b3c7
|
|
| BLAKE2b-256 |
b8eb4a19372e5972e89446edb42cdfef743f995b07b63646f133cf098b3d5bdd
|
Provenance
The following attestation bundles were made for openapi_lens-1.0.3-py3-none-any.whl:
Publisher:
publish.yml on MariaC27/api-lens
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
openapi_lens-1.0.3-py3-none-any.whl -
Subject digest:
402fe8cec5c16e32daf8136122deab701ecc3b2b8e0112128e2889e9cdb44f5b - Sigstore transparency entry: 1353536202
- Sigstore integration time:
-
Permalink:
MariaC27/api-lens@07d2461e27fcef2b027a9b67e803e2a271841b46 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/MariaC27
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@07d2461e27fcef2b027a9b67e803e2a271841b46 -
Trigger Event:
push
-
Statement type: