Identifiers
Every client accepts the identifier spellings that people actually paste: get()
calls take resolver URLs, prefixed forms, and bare identifiers. The
bibliofabric package also exports normalizers, one function per identifier
type, so that you can canonicalize identifiers before you compare or key records.
This page shows each normalizer with its real result and lists which clients
accept which identifier in get().
Clean an identifier
A normalizer returns the one canonical spelling of an identifier, and every normalizer is imported from the package root.
from bibliofabric import (
is_doi,
normalize_arxiv,
normalize_doi,
normalize_issn,
normalize_isni,
normalize_orcid,
)
print("is_doi:", is_doi("doi:10.1234/x"), is_doi("not-a-doi"))
print("arxiv:", normalize_arxiv("https://arxiv.org/abs/1706.03762v7"))
print("doi:", normalize_doi("https://doi.org/10.1038/NATURE12373"))
print("issn:", normalize_issn("2049363x"))
print("isni:", normalize_isni("ISNI:0000 0001 2109 725x"))
print("orcid:", normalize_orcid("https://orcid.org/0000-0002-1825-0097"))
is_doi: True False
arxiv: 1706.03762v7
doi: 10.1038/nature12373
issn: 2049-363X
isni: 0000 0001 2109 725X
orcid: 0000-0002-1825-0097
Three functions change more than the spelling: normalize_isbn turns a
valid ISBN-10 into its 978-prefixed ISBN-13, an x check digit becomes
X for ORCID iDs, ISNIs, and GND ids, and trailing #fragment and
?query parts are dropped.
from bibliofabric import (
normalize_gnd,
normalize_isbn,
normalize_pmcid,
normalize_pmid,
normalize_ror,
normalize_viaf,
normalize_wikidata_qid,
)
print("gnd:", normalize_gnd("https://d-nb.info/gnd/4003233-9"))
print("isbn:", normalize_isbn("isbn:0-306-40615-2"))
print("pmcid:", normalize_pmcid("4221854"), normalize_pmcid("pmc:pmc1234567"))
print("pmid:", normalize_pmid("https://pubmed.ncbi.nlm.nih.gov/12345678/"))
print("ror:", normalize_ror("https://ror.org/0524b2x58"))
print("viaf:", normalize_viaf("https://viaf.org/viaf/0054153165"))
print(
"wikidata:",
normalize_wikidata_qid("https://www.wikidata.org/wiki/Q42#P3153"),
normalize_wikidata_qid("wd:p3153"),
)
gnd: 4003233-9
isbn: 9780306406157
pmcid: PMC4221854 PMC1234567
pmid: 12345678
ror: 0524b2x58
viaf: 54153165
wikidata: Q42 P3153
| Function | Accepts | Returns |
|---|---|---|
is_doi |
Bare DOI, doi.org and dx.doi.org URLs, doi: prefix |
True when the value looks like a DOI |
normalize_arxiv |
Bare id, arXiv: prefix, abstract-page URLs |
Bare id, lowercased |
normalize_doi |
Bare DOI, doi.org and dx.doi.org URLs, doi: prefix |
Bare DOI, lowercased |
normalize_gnd |
Bare id, gnd: prefix, d-nb.info URLs |
Bare id, X check digit kept |
normalize_isbn |
Bare ISBN, isbn: prefix, hyphens and spaces |
ISBN-13 without hyphens; ISBN-10 converts |
normalize_isni |
Bare ISNI, ISNI: prefix, hyphens and spaces |
Four groups of four characters |
normalize_issn |
Bare ISSN, compact digits, ISSN Portal URLs, urn:issn: |
Hyphenated uppercase ISSN |
normalize_orcid |
Bare iD in any spelling, orcid: prefix, orcid.org URLs |
Hyphenated 16-character iD |
normalize_pmcid |
Bare digits, PMC/pmc:/pmcid: forms, PubMed Central URLs |
PMC1234567 |
normalize_pmid |
Bare digits, PMID: prefix, PubMed URLs |
Bare PubMed id |
normalize_ror |
Bare id, ror: prefix, ror.org and www.ror.org URLs |
Bare lowercase id |
normalize_viaf |
Bare number with or without leading zeros, viaf: prefix, viaf.org URLs |
Cluster number without leading zeros |
normalize_wikidata_qid |
Q/P/lexeme ids, wd: prefix, wiki and entity URLs, Property: namespace |
Bare uppercase entity id |
strip_url_prefix |
A value and your own prefix list | The value without the first matching prefix |
When an API invents a spelling no normalizer covers, strip the prefix
yourself. strip_url_prefix takes your prefix list, matches
case-insensitively, and returns the rest:
from bibliofabric.ids import strip_url_prefix
print(strip_url_prefix("doi:10.1234/x", ("doi:", "https://doi.org/")))
10.1234/x
Pass an identifier straight to get()
You usually do not normalize before a call: every get() listed below
normalizes its id itself, so both the resolver URL and the bare form return
the same record.
import asyncio
from bibliofabric.crossref import CrossrefClient
async def main() -> None:
async with CrossrefClient() as client:
via_url = await client.works.get("https://doi.org/10.1038/nature12373")
bare = await client.works.get("10.1038/NATURE12373")
print(via_url.doi, "|", bare.doi, "|", via_url.primary_title)
asyncio.run(main())
10.1038/nature12373 | 10.1038/nature12373 | Nanometre-scale thermometry in a living cell
The same holds for ORCID iDs on the ORCID client and for arXiv ids on the
arXiv client: client.records.get("https://orcid.org/0000-0002-4189-3154")
and client.records.get("0000-0002-4189-3154") return the same record.
Which clients take which identifier
The table maps each identifier to the clients whose get() (or an
equivalent named method) accepts it. Links go to the client pages that
document the accepted spellings and the quirks.
| Identifier | Clients |
|---|---|
| DOI | Crossref works and funders, DataCite, DOI (handle, metadata, content negotiation), OpenAlex works, OpenAIRE research products, bioRxiv and medRxiv, Zenodo (Zenodo DOIs), Semantic Scholar papers, DOAJ articles, OpenCitations Index and Meta |
| ORCID iD | ORCID, OpenAlex authors, OpenAIRE persons, OpenCitations Meta authors and editors |
| ISSN | Crossref journals, ISSN Portal, DOAJ journals, OpenAlex sources (bare or issn: form), OpenCitations venue citation counts |
| ROR id | ROR organizations, OpenAlex institutions, funders, and publishers (ror: form) |
| arXiv id | arXiv (bare, arXiv:, abstract URL), Semantic Scholar papers (ARXIV: form) |
| PMID | Europe PMC articles (MED: form), OpenAlex works (bare digits or pmid:), Semantic Scholar papers (PMID: form) |
| PMCID | Europe PMC articles, OpenAlex works (pmcid:), Semantic Scholar papers (PMCID: form) |
| Wikidata id | Wikidata entities (Q42, P31, lexeme ids, wiki URLs) |
| Zenodo record id | Zenodo records (bare id, Zenodo DOI and URLs) |
| ISBN | No get() route; appears in OpenCitations Meta record identifiers |
| ISNI | No get() route; find_by_external_id on ROR |
| GND, VIAF | No client route; search Wikidata for the property that carries them |
The spelling that a client accepts is not always the full set that the
normalizer accepts. OpenAlex, for example, takes bare ISSNs and issn: values for
sources but not Portal URLs, so normalize once and pass the bare form when
you chain clients:
from bibliofabric import normalize_issn
print(normalize_issn("https://portal.issn.org/resource/ISSN/1932-6203"))
1932-6203
Combine pages for worked examples that pass identifiers between clients are in Use several clients together.