Skip to main content

CompanyStack for Python

The Python client for the CompanyStack API: UK company data from Companies House. It covers company search and profiles, officers, persons with significant control, filing history, financials parsed from filed accounts, health scores, KYB checks, the register change feed and your company lists.

  • Typed: every response model is a TypedDict, so mypy and your editor know the fields.
  • Sync (CompanyStack) and asyncio (AsyncCompanyStack) clients on httpx.
  • Retries a 429 after Retry-After, and retries 5xx and network errors on reads.
  • Pagination helpers (iter_*) for search, filings, list items, the change feed, KYB checks and prospects.

Requires Python 3.9 or later.

Install

pip install companystack

Quick start

Get an API key (it starts with cs_) by signing up free: no card, 1,000 requests a day on the Free plan. Then set it in COMPANYSTACK_API_KEY, or pass api_key=.

from companystack import CompanyStack

cs = CompanyStack()  # reads COMPANYSTACK_API_KEY

results = cs.search_companies(q="tesco", limit=5)
for company in results["results"]:
    print(company["company_number"], company["company_name"], company["company_status"])

profile = cs.get_company("00445790")
print(profile["accounts"]["next_due"])

Examples

# Officers and beneficial owners (Starter plan and above)
officers = cs.list_officers("00445790")
pscs = cs.list_persons_with_significant_control("00445790")

# Financials from filed accounts. Money values are whole pounds (GBP) as filed, not pence.
history = cs.get_financial_history("06450847")
for period in history["periods"]:
    print(period["balance_sheet_date"], period["net_assets"], period["turnover"])

# Health score: a rules-based 0-100 indicator (not a credit rating)
score = cs.get_health_score("06450847")
print(score["overall_score"], score["grade"], score["risk_level"])

# KYB check. Each call uses quota and stores a record on your account.
check = cs.run_kyb_check({"company_number": "06450847", "expected_name": "Club Free Spirit Limited", "reference": "client-42"})
print(check["outcome"], check["reason_codes"])

# Every search result, fetching pages as you go
for company in cs.iter_search_companies(q="bakery", town="LEEDS", max_items=200):
    print(company["company_name"])

# The change feed: store the cursor and resume from it next time
page = cs.list_changes(types="added,dissolved", postcode="LS")
cursor = page["next_cursor"]

# Your lists
lists = cs.list_lists()
cs.add_list_items(42, {"items": [{"company_number": "00445790", "custom_ref": "CL-0042"}]})

asyncio

import asyncio
from companystack import AsyncCompanyStack

async def main():
    async with AsyncCompanyStack() as cs:
        company = await cs.get_company("00445790")
        async for event in cs.iter_list_changes(types="added", max_items=100):
            print(event["company_number"], event["change_type"])

asyncio.run(main())

Errors

Every failure raises a subclass of CompanyStackError, which carries status, code, body, upgrade_url and retry_after:

Exception When
AuthenticationError 401: the key is missing, malformed or revoked
PermissionDeniedError 403: your plan does not include the endpoint (code == "plan_upgrade_required"; see upgrade_url)
NotFoundError 404
ValidationError 400 or 422
ConflictError 409
RateLimitError 429 after the retries; retry_after says how long to wait
ServerError 5xx
APIConnectionError No response (network error or timeout)
from companystack import CompanyStack, PermissionDeniedError, RateLimitError

try:
    cs.get_health_score("00445790")
except PermissionDeniedError as e:
    print("Upgrade at", e.upgrade_url)
except RateLimitError as e:
    print("Try again in", e.retry_after, "seconds")

Configuration

CompanyStack(
    api_key="cs_…",          # default: COMPANYSTACK_API_KEY
    base_url="https://api.companystack.co.uk",
    timeout=30.0,            # seconds per attempt
    max_retries=2,           # 429 on any method; 5xx and network errors on GET
    max_retry_delay=60.0,    # cap on Retry-After waits
    http_client=None,        # bring your own httpx.Client (proxies, transports)
)

After each call, cs.last_rate_limit holds the rate-limit headers (limit, remaining, reset, daily_limit, daily_remaining). What each plan includes, and its limits, is on the pricing page.

Development

_generated.py is generated from the OpenAPI specification and is replaced on each release, so send changes to _base.py (the runtime) or open an issue.

pip install -e ".[test]"
pytest            # runs against a local mock server; no network, no key
mypy

Pricing

Free API plan: £0, 1,000 requests a day, 30 a minute, no card: search (first page, up to 10 results), autocomplete and full company profiles. Starter: £29/month or £288/year, adding officers, owners (PSC), filing history, filed accounts and health scores. Pay as you go, without a monthly plan: prepaid credits from £10 (1,000 credits), used only for calls your plan does not include. Current prices and limits: companystack.co.uk/pricing.

About the data

The data is a copy of public registers (Companies House and the others listed at companystack.co.uk/data-sources), as CompanyStack holds them, and can be incomplete or out of date. Register details and accounts figures are the company's own filings, shown as filed: CompanyStack does not audit or verify them. Health scores and KYB results are indicators that support your own checks, not credit ratings or advice.

Contains public sector information licensed under the Open Government Licence v3.0. CompanyStack is not affiliated with or endorsed by Companies House.

Licence

MIT

Metadata

Release files for companystack 0.1.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 companystack 0.1.0
File Size Uploaded Provenance Actions
companystack-0.1.0.tar.gz 107.3 kB With provenance Details for companystack-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 212.8 kB

Release files / companystack-0.1.0.tar.gz

Download URL companystack-0.1.0.tar.gz
Size 107.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6362129c59a4ad614798bddd208203df8895d84b28a4080a54d3b59a05b9abcc
BLAKE2b-256 checksum
How to use checksums
d964347b71cf9389c5eb9f421d5f9b4319926a5b3f5969c9ccedc52de3a289bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / companystack-0.1.0-py3-none-any.whl

Download URL companystack-0.1.0-py3-none-any.whl
Size 105.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49645fb0f22f646da3220bf64cd88867036a9b6f0e24d5f4fb113e0ec18aff5b
BLAKE2b-256 checksum
How to use checksums
4df1a74442a9c0f409a5087433c8c3a219517c407d090afbaff6d5dbb3e3faeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for companystack 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for companystack-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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