INSPIRE-HEP
The InspireHep client (bibliofabric.inspirehep) reads the
INSPIRE-HEP REST API, the high-energy-physics
literature database: literature, authors, institutions, journals, jobs,
seminars, conferences, experiments, and data. It also reads the DOI, arXiv,
and ORCID identifier routes, the citation formats of a literature record,
and the records that cite it. Calls return typed Pydantic models through an
async client and a generated sync twin.
Credentials
The API needs no credentials. INSPIRE allows every IP 15 requests in a
5 second window, and a blocked request counts against the window, so the
client paces itself to 2 requests per second with 2 concurrent requests.
Tune both with INSPIREHEP_MAX_REQUESTS_PER_SECOND and
INSPIREHEP_MAX_CONCURRENCY; see the settings guide.
The constructor also takes a keyword-only mailto= contact address; it
overrides INSPIREHEP_MAILTO and appears in the User-Agent the client
sends.
Quick start
import asyncio
from bibliofabric.inspirehep import InspireHepClient
async def main() -> None:
async with InspireHepClient() as client:
record = await client.literature.get(451647)
print(record.control_number, record.title, record.metadata.citation_count)
page = await client.literature.search(
query="hep-th", sort="mostcited", page_size=5
)
for record in page.results[:3]:
print(" ", record.control_number, record.metadata.citation_count)
bibtex = await client.literature.formatted(451647, output_format="bibtex")
print(bibtex.splitlines()[0])
asyncio.run(main())
451647 The Large $N$ limit of superconformal field theories and supergravity 22883
2881 records cited 1000+ times; first pages:
2902314 DESI DR2 results. II. Measurements of baryon acoustic oscillations and cosmological constraints
2821840 Quantum error correction below the surface code threshold
2817040 Review of particle physics
@article{Maldacena:1997re,
Sync quick start
from bibliofabric.inspirehep import InspireHepSyncClient
with InspireHepSyncClient() as client:
author = client.authors.by_orcid("0000-0002-9079-593X")
print(author.display_name)
Stephen W. Hawking
What you can call
Every collection resource carries the generic operations get, search,
iterate, collect, first, count, exists, and batch_get:
page = await client.seminars.search(filters={"start_date": "upcoming"})
total = await client.conferences.count(query="workshop")
async for experiment in client.experiments.iterate(page_size=100, limit=200):
print(experiment.metadata.legacy_name)
batch = await client.literature.batch_get(["4328", "451647"], field="id")
The literature resource adds by_doi, by_arxiv, formatted, citations,
and iterate_citations; the authors resource adds by_orcid:
record = await client.literature.by_doi("10.1103/PhysRevLett.19.1264")
record = await client.literature.by_arxiv("1207.7214")
page = await client.literature.citations(451647, page=1, page_size=5)
author = await client.authors.by_orcid("0000-0002-9079-593X")
Search supports query= (INSPIRE's q syntax), sort=, select= (sent as
INSPIRE's fields= metadata filter), page, and page_size up to 1000:
page = await client.literature.search(
query="topcite 1000+", sort="mostrecent", select=["titles"], page_size=50
)
See upstream quirks for the search syntax, paging limits, and the author email restriction, and the API reference for the full surface.