Skip to content

Use several clients together

The clients share one idiom, so a record that one API returns becomes the identifier that the next API takes. Each section below is one complete script that chains three clients around one real identifier, with the output the run produced. Which identifier each get() accepts is listed in Identifiers.

Follow one DOI through three citation indexes

Crossref gives the published record, OpenAlex adds citation counts and open access flags, and OpenCitations reports what its citation index holds for the same paper. All three accept the DOI, and the resolver URL form works for all of them.

import asyncio

from bibliofabric.crossref import CrossrefClient
from bibliofabric.openalex import OpenAlexClient
from bibliofabric.opencitations import OpenCitationsClient

DOI = "https://doi.org/10.1038/nature12373"


async def main() -> None:
    async with CrossrefClient() as crossref:
        work = await crossref.works.get(DOI)
        print("Crossref:", work.primary_title, "-", work.container_title[0])

    async with OpenAlexClient() as openalex:
        work = await openalex.works.get(DOI)
        print(
            "OpenAlex:",
            work.cited_by_count,
            "citations,",
            "retracted:",
            work.is_retracted,
        )

    async with OpenCitationsClient() as opencitations:
        count = await opencitations.index.citation_count(DOI)
        records = await opencitations.meta.metadata(DOI)
        print(
            "OpenCitations:",
            count,
            "citations in the index;",
            "venue:",
            records[0].venue,
        )


asyncio.run(main())
Crossref: Nanometre-scale thermometry in a living cell - Nature
OpenAlex: 2198 citations, retracted: False
OpenCitations: 1806 citations in the index; venue: Nature [issn:0028-0836 issn:1465-7392 issn:1476-4679 issn:1476-4687 issn:1744-7933 omid:br/0626016512]

The two citation counts differ because the indexes cover different corpora; reading both is the point of the chain.

Find one person in three registries

An ORCID iD identifies a person across registries. The ORCID record gives the claimed profile, OpenAlex the author profile with its work count, and OpenAIRE the person record its graph uses.

import asyncio

from bibliofabric.openaire import OpenAireClient
from bibliofabric.openalex import OpenAlexClient
from bibliofabric.orcid import OrcidClient

ORCID = "0000-0002-4189-3154"


async def main() -> None:
    async with OrcidClient() as orcid:
        record = await orcid.records.get(ORCID)
        name = record.person.name
        print("ORCID:", name.given_names.value, name.family_name.value)

    async with OpenAlexClient() as openalex:
        author = await openalex.authors.get(f"https://orcid.org/{ORCID}")
        print(
            "OpenAlex:",
            author.id,
            "-",
            author.display_name,
            "| works:",
            author.works_count,
        )

    async with OpenAireClient() as openaire:
        person = await openaire.persons.get(ORCID)
        print("OpenAIRE:", person.id, "-", person.full_name)


asyncio.run(main())
ORCID: Georg Kucsko
OpenAlex: https://openalex.org/A5033043101 - Georg Kucsko | works: 23
OpenAIRE: orcid_______::824df532ee6600b5fbe4fcad9ff31d6e - Georg Kucsko

All three calls run without credentials. Semantic Scholar also takes DOI: and ARXIV: paper ids, but its anonymous pool answers 429 when busy, and the client then waits and retries on its own; see Semantic Scholar if you add that client to the chain.

Trace one journal from its ISSN

The ISSN Portal stores the title and its ISSN-L cluster, DOAJ says whether the journal is open access, and OpenAlex sources reports how many works it indexes. The Portal URL normalizes to the bare ISSN once, and the bare form works everywhere downstream, which is the form that OpenAlex sources accepts.

import asyncio

from bibliofabric import normalize_issn
from bibliofabric.doaj import DoajClient
from bibliofabric.issn import IssnClient
from bibliofabric.openalex import OpenAlexClient

ISSN = normalize_issn("https://portal.issn.org/resource/ISSN/1932-6203")


async def main() -> None:
    print("normalized:", ISSN)

    async with IssnClient() as portal:
        record = await portal.records.get(ISSN)
        print(
            "ISSN Portal:", record.title, "-", record.format, "- ISSN-L", record.issn_l
        )

    async with DoajClient() as doaj:
        journal = await doaj.journals.get(ISSN)
        print("DOAJ:", journal.title, "-", journal.publisher_name)

    async with OpenAlexClient() as openalex:
        source = await openalex.sources.get(ISSN)
        print("OpenAlex:", source.display_name, "- works:", source.works_count)


asyncio.run(main())
normalized: 1932-6203
ISSN Portal: PloS one. - medium:Online - ISSN-L 1932-6203
DOAJ: PLoS ONE - Public Library of Science (PLoS)
OpenAlex: PLoS ONE - works: 345216

Note the three titles differ: each registry stores its own spelling of the journal name, and the ISSN-L is the stable link between them.

What the chains cost

Each script above makes three or four requests and finishes in a few seconds, because every client paces itself against its API's limits. When a chain needs many identifiers, fetch ids with batch_get, keep long lists out of single requests, and see Errors, retries, and rate limits for what happens when a call still comes back 429.