Skip to main content
Loss of provenance

A previous release had provenance metadata, but this release does not. View details.

Stavrophora: Python client for the Crossref API

Samuel Mok -- s.mok@utwente.nl -- 2026

Stavrophora is a Python client for the Crossref REST API, built on bibliofabric. It ships an async variant and a generated sync twin (StavrophoraSyncClient).

License: MIT

Features

  • Async by design -- built on httpx + asyncio with proper connection pooling
  • Typed end-to-end -- Pydantic v2 models with extra="allow" (the Crossref spec is incomplete; extra fields are preserved, never dropped)
  • Cursor pagination -- async for work in client.works.iterate(...) over next-cursor
  • Polite pool by default -- one mailto= line triples your rate limit
  • Batch DOI lookup -- comma-separated repeated filter=doi: keys (Crossref's supported OR form)
  • Scoped works -- client.journals.works(issn), client.funders.works(id), client.members.works(id), client.prefixes.works(prefix), client.types.works(type)
  • Facets and sampling -- client.works.facets(...) returns {facet: {value: count}}; client.works.sample(n) draws up to 100 random works
  • Sync twin -- StavrophoraSyncClient and the Sync* resource classes are generated from the async source; same parameters, same errors, same pacing, no event loop required
  • Route-aware parameters -- works-only parameters (sort, select, filters) are rejected client-side on routes that would answer 400

Installation

uv add stavrophora

Or with pip: pip install stavrophora. Requires Python >=3.12.

Quick Start

import asyncio
from stavrophora import StavrophoraClient, WorksFilters


async def main():
    async with StavrophoraClient(mailto="you@example.org") as client:
        # Get a single work by DOI (bare or doi.org-prefixed, mixed case)
        work = await client.works.get("10.1038/nature12373")
        print(work.title[0], work.issued.date_parts)

        # Search: filters, sort/order split, field selection
        page = await client.works.search(
            WorksFilters(type="journal-article"),
            query="crow nesting",
            sort="is-referenced-by-count:desc",
            select=["DOI", "title", "is-referenced-by-count"],
            page_size=5,
        )
        for item in page.results:
            print(item.doi, item.is_referenced_by_count)

        # Facet distributions
        facets = await client.works.facets(
            WorksFilters(type="journal-article"), facets=("published",)
        )


asyncio.run(main())

The same calls with the sync twin, in a plain script or a notebook:

from stavrophora import StavrophoraSyncClient

with StavrophoraSyncClient(mailto="you@example.org") as client:
    work = client.works.get("10.1038/nature12373")
    print(work.title[0], work.issued.date_parts)

    page = client.works.search(
        WorksFilters(type="journal-article"),
        query="crow nesting",
        sort="is-referenced-by-count:desc",
        select=["DOI", "title", "is-referenced-by-count"],
        page_size=5,
    )
    for item in page.results:
        print(item.doi, item.is_referenced_by_count)

The sync client never starts or touches an event loop, so it also works when called from inside a running one.

search() returns a bibliofabric.Page: .results (typed models), .total, .next_cursor, and .meta (the raw envelope minus results, e.g. facets).

No authentication required. When rate limits are not explicitly configured, StavrophoraClient applies pool-aware defaults: Public Pool (no credentials) runs at 5 req/s single / 1 req/s list with concurrency 1; Polite Pool (mailto or STAVROPHORA_MAILTO) runs at 10 req/s single / 3 req/s list with concurrency 3; Metadata Plus (plus_token or STAVROPHORA_PLUS_TOKEN, sent as crossref-api-key: Bearer <key>) runs at 50 req/s for both classes with concurrency 10. When both are set, plus_token replaces the query-parameter mailto while mailto still rides the User-Agent. client.last_pool and client.last_rate_limit_headers expose Crossref's x-api-pool / x-rate-limit-* headers from the latest response.

Basic Usage

Get a single entity

work = await client.works.get("10.1038/nature12373")  # DOI (bare or doi.org-prefixed)
journal = await client.journals.get("0028-0836")  # ISSN or eISSN
funder = await client.funders.get("10.13039/501100000923")
member = await client.members.get("78")  # e.g. Elsevier
prefix = await client.prefixes.get("10.1016")  # no /prefixes list route exists

Search, sort, filter, select

from stavrophora import WorksFilters

response = await client.works.search(
    filters=WorksFilters(type="journal-article", from_pub_date="2026-01-01"),
    sort="is-referenced-by-count:desc",
    select=["DOI", "title", "is-referenced-by-count"],
    page_size=20,
)

Crossref has no publisher filter (400, verified live); scope by prefix, member or ror-id instead.

Iterate all results (cursor)

async for work in client.works.iterate(
    filters={"from-created-date": "2026-08-01"},
    page_size=1000,
    on_page=checkpoint,
):
    process(work)

Iteration defaults to 1000 rows per page and follows next-cursor until an empty page. Since 2026-08-24 cursor result sets are not stable and cursors must be re-read from every page (the client always repeats all parameters). Combining iteration with the issued / published* sorts raises a client-side error: the API rejects that combination with 400. For incremental sync prefer from-created-date / until-created-date windows over from-index-date (index-date windows drift); pass on_page(page_number, next_cursor) to checkpoint and resume with cursor=.

Scoped works

nature_works = client.journals.works("0028-0836")
response = await nature_works.search(page_size=5)

ut_works = client.prefixes.works("10.3990")  # UT student theses
async for w in ut_works.iterate():
    ...

Batch DOI lookup

found = await client.works.batch_get_by_doi(
    ["10.1038/nature12373", "10.1103/PhysRevLett.116.061102"]
)

Keys are normalized bare lowercase DOIs; misses are absent from the dict. Requests are batched 50 DOIs per call via repeated filter=doi: keys (the pipe form doi:a|b returns zero results -- verified live).

Registration agency

agency = await client.works.agency("10.1038/nature12373")
print(agency.agency.label)  # "Crossref"

Configuration

Settings load from env vars prefixed STAVROPHORA_ (or a .env file):

STAVROPHORA_MAILTO=s.mok@utwente.nl

Generic settings are inherited under the same prefix: STAVROPHORA_TIMEOUT, STAVROPHORA_MAX_RETRIES, STAVROPHORA_MAX_REQUESTS_PER_SECOND (default 3), STAVROPHORA_MAX_CONCURRENCY (default 3), STAVROPHORA_USER_AGENT. STAVROPHORA_PLUS_TOKEN holds a Metadata Plus key (sent as crossref-api-key: Bearer <key>).

Known Crossref API Quirks

  • No pipe-OR in filters. filter=doi:a|b silently returns 0 results (OpenAlex-style). Repeated key:value pairs (filter=doi:a,doi:b) are the supported OR form.
  • Unknown query parameters are rejected with 400 (no silent ignoring). The client therefore sends only rows, offset, query, filter, sort, order, select, cursor, mailto.
  • page is not a parameter -- paging is offset with offset + rows <= 10000 (the client raises before requesting past the cap; use iterate()) + rows (max 1000, 400 otherwise). Deep paging must use cursor.
  • Cursor requests reject publication-date sorts (400 sort-criteria-incompatible-with-cursor, since 2026-08-24): iterate(sort="published") raises client-side; sort by is-referenced-by-count or iterate unsorted.
  • sample (max 100) cannot combine with rows/offset; client.works.sample(n) handles that for you.
  • Cursor exhaustion is implicit: the last non-empty page still returns a next-cursor; only the following request returns an empty items and no cursor.
  • /prefixes has no list route (404) -- only /prefixes/{prefix} and /prefixes/{prefix}/works. /licenses has no single-item route (404) -- only the list.
  • The message envelope is one level deep for everything: single items live in message, lists in message.items with totals in message.total-results.
  • Rate limits changed 2025-12-01, split by request type 2026-07-21: polite pool 3 req/s for top-level /works lists (x-api-pool: polite-array), 10 req/s for single records and scoped works routes (polite-single), 3 concurrent; limits apply per mailto address. Metadata Plus: 150/s via the crossref-api-key header. On 429 back off (the client retries with Retry-After/exponential backoff); 403 means blocked.
  • API is served at both https://api.crossref.org and .../v1 with identical payloads (verified 2026-09); stavrophora pins /v1, the versioned form.
  • The Crossref spec is incomplete -- several returned fields are missing from the official schema. All models use extra="allow", same defense as aletheca.
  • Schemas differ between list and single-item routes (verified live): /journals/{issn} returns title as a bare string while /journals returns a list; member prefix entries are {name, value} objects. The models normalize both shapes (SafeStrList, dict-typed prefix entries).
  • /types ignores rows/offset (verified live 2026-09): the route always returns the complete list (~30 types) regardless of paging parameters.
  • /prefixes/{prefix} returns member and prefix as full https://id.crossref.org/member/297-style URIs (verified live 2026-09). The Prefix model normalizes both the URI and bare forms to bare values ("297", "10.1038").

Development

Stavrophora lives in the bibliofabric uv workspace at packages/stavrophora. From the repository root:

uv sync --all-packages --all-groups    # install everything
uv run pytest packages/stavrophora/tests  # mocked tests (live tests excluded by default)
uv run pytest packages/stavrophora/tests -m live_api  # live API smoke tests

Lint, type check, and docs run at the workspace root (uv run ruff check, uv run ty check packages/*/src, uv run mkdocs build --strict); see the root AGENTS.md.

License

MIT

Metadata

Release files for stavrophora 0.4.0

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

Loss of provenance

These files do not have provenance metadata, despite files in a prior release including this data.

We recommend further investigation before installing these files. View details.

Source distribution (sdist)

Source distribution for stavrophora 0.4.0
File Size Uploaded Provenance Actions
stavrophora-0.4.0.tar.gz 38.1 kB Without provenance Details for stavrophora-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 90.9 kB

Release files / stavrophora-0.4.0.tar.gz

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL stavrophora-0.4.0.tar.gz
Size 38.1 kB
Tags Source
SHA-256 checksum
How to use checksums
16d97634f4363d7c707975a023d6fcd6e3ffca5ba224bcc24e2167b736b58a6f
BLAKE2b-256 checksum
How to use checksums
d2af758045e77f0d130b7821d890e4cbc3693c7ff9c1eb824a1f16b2a964e540
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / stavrophora-0.4.0-py3-none-any.whl

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL stavrophora-0.4.0-py3-none-any.whl
Size 52.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e22c38e5e10f272aaeeb5e473c5c7a4abaacdf63915d8c7e229512648e9f973
BLAKE2b-256 checksum
How to use checksums
05ef524034d7a2c512a8486523fac99131c5e32f02a2dcf10e111a5085095a62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for stavrophora 0.4.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.

Loss of provenance

A previous release of these files had provenance metadata, but this release does not.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Release comparison

  • Removed 0.3.0 2 files With provenance
  • Added 0.4.0 2 files Without provenance

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.

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