Skip to content

Works

client.works covers the /works route: search, filters, sorting, field selection, cursor paging, and batch DOI lookup. Later blocks on this page reuse the client from the first block.

import asyncio

from bibliofabric.crossref import CrossrefClient, WorksFilters


client = CrossrefClient()


async def main() -> None:
    async with client:
        page = await client.works.search(
            WorksFilters(type="journal-article", has_abstract=True),
            query="proteomics",
            sort="is-referenced-by-count:desc",
            select=["DOI", "title", "is-referenced-by-count"],
            page_size=5,
        )
        print("total:", page.total)
        for w in page.results:
            print(" ", w.doi, w.is_referenced_by_count, w.primary_title)


asyncio.run(main())
total: 20629
  10.1093/nar/gkab1038 6453 The PRIDE database resources in 2022: a hub for mass spectrometry-based proteomics evidences
  10.1093/bioinformatics/btq054 4736 Skyline: an open source document editor for creating and analyzing targeted proteomics experiments
  10.1016/j.gpb.2015.08.002 2143 PacBio Sequencing and its Applications
  10.1093/bioinformatics/btn323 2002 ProteoWizard: open source software for rapid proteomics tools development
  10.1016/s1672-0229(10)60008-3 1962 KaKs_Calculator 2.0: A Toolkit Incorporating Gamma-Series Methods and Sliding Window Strategies

sort takes one field, optionally with :asc or :desc. Crossref accepts a single sort field; two fields raise ConfigurationError. select takes a list of field names. The works route also accepts the query.* sub-fields through params; prefer query.bibliographic for citation matching, because Crossref deprecates query.title. For the shared search signature and typed filter models, see Searching.

Pass on_error="skip" with a failures list to drop records that fail validation instead of raising ValidationError for the whole page.

Filter works

WorksFilters mirrors the Crossref filter list; kebab-case wire names are handled by aliases, so from_pub_date sends from-pub-date. A list value uses the repeated-key OR form (filter=doi:a,doi:b), and different keys AND together.

page = await client.works.search(
    WorksFilters(
        type="journal-article",
        orcid="0000-0002-1825-0097",
        from_pub_date="2020-01-01",
    ),
    select=["DOI", "title"],
    page_size=5,
)

Unknown filter names are passed through as written. The full filter list lives in the API reference under WorksFilters.

Page through results

Crossref caps offset + rows at 10,000 and rows at 1,000. search(page=..., page_size=...) raises ConfigurationError before sending a request past that cap. Use iterate() for deep result sets:

n = 0
async for w in client.works.iterate(WorksFilters(prefix="10.5194"), limit=3):
    n += 1
    print("iter", n, w.doi)

total = await client.works.count(WorksFilters(prefix="10.5194"))
print("prefix 10.5194 total:", total)
iter 1 10.1007/s005850050006
iter 2 10.1007/s005850050009
iter 3 10.1007/s005850050011
prefix 10.5194 total: 587129

iterate() pages with cursor, defaults to 1,000 rows, and repeats every parameter on each page. It rejects the issued and published* sorts, which the API no longer allows with cursors. on_page(page_number, next_cursor) records checkpoints; pass a saved cursor back with cursor= to resume. collect(limit=100) gathers results into a list, and first() returns the first match or None. count() requests zero rows and returns the total. See Paging for the general rules.

Fetch many DOIs at once

works = await client.works.batch_get_by_doi(
    ["https://doi.org/10.1038/Nature12373", "10.1109/TIP.2009.2037465"]
)
for doi, w in sorted(works.items()):
    print(doi, "->", w.primary_title)
10.1038/nature12373 -> Nanometre-scale thermometry in a living cell
10.1109/tip.2009.2037465 -> Deform PF-MT: Particle Filter With Mode Tracker for Tracking Nonaffine Contour Deformations

The helper batches 50 DOIs per request through the repeated-key OR form, runs the batches concurrently, and returns a dict keyed by bare lowercase DOI. DOIs that return nothing are absent from the dict. A DOI without the 10.<prefix>/<suffix> shape raises ConfigurationError before any request, because Crossref rejects the whole batch over one malformed DOI. batch_get(ids, field=...) is the general form.

Check existence and registration agency

print("exists:", await client.works.exists("10.1038/nature12373"))
print("exists:", await client.works.exists("10.9999/missing-doi"))
print("agency:", (await client.works.agency("10.1038/nature12373")).agency.label)
exists: True
exists: False
agency: Crossref

exists() sends a HEAD request, so no record body is transferred, and returns False for unknown DOIs (404). agency() returns the DOI registration agency for the DOI.

Follow Crossmark versions

latest_version() resolves a DOI to the newest record in its Crossmark update chain:

notice = await client.works.first(WorksFilters(update_type="new_version"))
target = notice.update_to[0].doi
newest = await client.works.latest_version(target)
print("asked for:", target)
print("newest:", newest.doi)
asked for: 10.1002/14651858.cd000353
newest: 10.1002/14651858.cd000353.pub2

Older records of an update chain carry updated-by entries naming the works that updated them. By default only ("new_version", "new_edition") entries are followed, so retractions and corrections are not mistaken for newer versions. Pass update_types=None to follow all Crossmark update types, or your own collection of update-type names. A DOI without matching update data is returned unchanged.

Work with retractions

Crossref carries the Retraction Watch database since 2023. A retracted work lists its retraction notices in updated-by, each with a type and a source (publisher or retraction-watch). The entries are matched case-insensitively, so type="Retraction" counts too.

notice = await client.works.first(WorksFilters(update_type="retraction"))
print("notice:", notice.doi, "updates:", [(t.doi, t.type) for t in notice.update_to])
retracted = await client.works.get(notice.update_to[0].doi)
print("retracted:", retracted.doi, retracted.is_retracted)
print("retraction entries:", [(t.doi, t.source) for t in retracted.retractions])
notice: 10.1016/0014-5793(94)80593-8 updates: [('10.1016/0014-5793(92)81355-p', 'retraction')]
retracted: 10.1016/0014-5793(92)81355-p True
retraction entries: [('10.1016/0014-5793(94)80593-8', 'retraction-watch')]

Work.retractions lists the notice DOIs and Work.is_retracted reports whether the work is currently retracted. A Crossmark update chain can also carry a reinstatement entry, which means the publisher withdrew the retraction and reinstated the work. A reinstatement dated after the newest retraction cancels it, so is_retracted returns False for a work that was retracted and later reinstated; the notices stay listed in retractions. With no reinstatement entry, any retraction reports the work as retracted.

The retraction notices themselves are works with update-to entries. Search them with the update_type filter, as the example above does.

Facets and sample

facets = await client.works.facets(query="crispr", fields="type-name", count=5)
print("facets:", facets["type-name"])

sample = await client.works.sample(sample_size=3, select=["DOI", "title"])
print("sample:", [w.doi for w in sample.results])
facets: {'Journal Article': 31686, 'Dataset': 6604, 'Posted Content': 5754, 'Chapter': 2626, 'Component': 2316}
sample: ['10.1016/j.jvoice.2026.07.059', '10.18034/apjee.v4i2.519', '10.1038/sj.bdj.2009.315']

facets() returns {facet_name: {value: count}} and drops Crossref's value-count per facet. The count argument caps the values per facet (the API allows up to 1,000). sample(sample_size=n) sends sample=n without rows or offset, so the result is a random draw rather than the head of the result set. Crossref caps sample at 100, the sample_size default.

Scoped works

Every parent resource exposes a works() method that returns a scoped works client with the full works list method set (search, iterate, count, facets, sample, batch; single-work methods such as get, exists, agency, and latest_version are omitted because Crossref serves them only at /works/{doi}):

scoped = await client.journals.works("0028-0836").search(page_size=2)
print("journal works total:", scoped.total)
for w in scoped.results:
    print(" ", w.doi, w.primary_title)
journal works total: 447947
  10.1038/d41586-022-04447-0 Molecular engineering enables bright blue LEDs
  10.1038/245450a0 Nature of the Lower D Region of the Ionosphere

Identifiers are normalized: ISSNs are hyphenated, DOIs are lowercased with URL prefixes stripped, and integer member ids are accepted. See Identifiers for the full normalization rules. For the funder scope with descendants, see Funders.