Skip to main content

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 GET and POST, only to an allowlist of /v1 read paths. Dot segments and backslashes are refused before allowlisting.
  • Nothing from the browser request is forwarded except the /v1 path, 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-Remaining when metered; the React SDK's onLimit reads it.
  • A missing key answers 503; an unreachable upstream answers 502. 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

filingstudio_proxy-0.4.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

filingstudio_proxy-0.4.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

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

Hashes for filingstudio_proxy-0.4.0.tar.gz
Algorithm Hash digest
SHA256 395e2132066ebfcca6889f85c492ca112d852a811a4d7144b8eea6ec69aaa572
MD5 bfd74b954bda88d2dd0c5c513fbbd8af
BLAKE2b-256 42e45f0fdbe1dfb77f09e385ade317f034ca99a3a926e7a0a3eb29471c32fa8b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for filingstudio_proxy-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b1bba6ae84bd0d12ef847c64ee83dd6b08f08c75f835fdf67009a2ee7194f29
MD5 bffc21aa6844a0ed10bdfc1b1ca8c947
BLAKE2b-256 8f031850c14a202d65df195850f63f7dda58767c53cbb637a47ccfa23ff608d3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.2.0

2 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