filingstudio-proxy
Server-side proxy for Filing Studio on FastAPI.
Your API key stays on your server; the browser talks only to your route.
This is the Python twin of @filingstudio/proxy (Next.js and Express), with
the same contract, so @filingstudio/react works unchanged in front of it.
pip install filingstudio-proxy
import os
from fastapi import FastAPI
from filingstudio_proxy import filing_studio_router
app = FastAPI()
app.include_router(
filing_studio_router(api_key=os.environ["FILING_STUDIO_API_KEY"]),
prefix="/api/filings",
)
Then in the browser: <ProvenanceProvider proxy="/api/filings">.
Public demo? Cap each visitor
filing_studio_router(api_key=key, budget=40) # 40 metered requests per visitor per day
Over budget the route answers 429 with an honest note the drawer shows
("Daily demo limit reached… This says nothing about what the filings
contain"), never a fake "not found". Coverage checks are never metered, and
cached answers are served before the meter, so reopening a receipt is free.
Meter on your own login instead of the visitor IP:
filing_studio_router(
api_key=key,
budget=100,
visitor_key=lambda req: req.state.user_id,
limit_for=lambda req: req.state.daily_limit, # optional per-user quota
)
Share links
app.include_router(filing_studio_router(KEY, share=True), prefix="/api/filings")
# POST /api/filings/share {kind: "research" | "receipt", ...} -> 201 {id, path}
# GET /api/filings/share/{id} -> the snapshot
Creation is metered and can be gated (ShareOptions(allow=...)); reads are
public and cacheable. ShareOptions(store=...) takes any object with
create(snapshot, request) -> id and read(id, request); the default is in
memory, capped at 1,000.
What it guarantees
- Only
GETandPOST, only to an allowlist of/v1read paths. Dot segments and backslashes are refused before allowlisting. - Nothing from the browser request is forwarded except the
/v1path, its query string, and a POST body (capped at 64 KB). - Successful
GETs are cached in-process (one hour by default) and served before the meter. Errors are never cached. - The reply carries
X-FS-Demo-Remainingwhen metered; the React SDK'sonLimitreads it. - A missing key answers
503; an unreachable upstream answers502. Neither message can contain the key.
Options
| option | default | meaning |
|---|---|---|
api_key |
required | your fsk_… key, server-side only |
base_url |
https://api.filingstudio.com |
upstream base |
allow |
search, trace, traces, verify, coverage, filings, tables | allowed /v1 prefixes |
cache_ttl_s |
3600 |
GET cache TTL; 0 disables |
budget |
None |
per-visitor daily cap (int) or a shared Budget |
visitor_key |
client IP, cookie fallback | who a request is charged to |
limit_for |
None |
per-request quota override |
timeout_s |
30 |
upstream timeout |
transport |
None |
an httpx transport, for tests |
Develop
pip install -e .[test]
pytest
MIT
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 filingstudio_proxy-0.4.0.tar.gz.
File metadata
- Download URL: filingstudio_proxy-0.4.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
395e2132066ebfcca6889f85c492ca112d852a811a4d7144b8eea6ec69aaa572
|
|
| MD5 |
bfd74b954bda88d2dd0c5c513fbbd8af
|
|
| BLAKE2b-256 |
42e45f0fdbe1dfb77f09e385ade317f034ca99a3a926e7a0a3eb29471c32fa8b
|
File details
Details for the file filingstudio_proxy-0.4.0-py3-none-any.whl.
File metadata
- Download URL: filingstudio_proxy-0.4.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b1bba6ae84bd0d12ef847c64ee83dd6b08f08c75f835fdf67009a2ee7194f29
|
|
| MD5 |
bffc21aa6844a0ed10bdfc1b1ca8c947
|
|
| BLAKE2b-256 |
8f031850c14a202d65df195850f63f7dda58767c53cbb637a47ccfa23ff608d3
|