bibliofabric.semanticscholar
The SemanticScholar client (bibliofabric.semanticscholar) is a Python client for the Semantic Scholar Academic Graph API, the Recommendations API, and the Datasets API. It types papers, authors, citations, patents, snippets, recommendations, and dataset releases with Pydantic models, paces itself at 1 request per second by default, and works with or without an API key. It ships an async client and a generated sync twin with the same API.
Install
uv add bibliofabric
Requires Python 3.12 or newer.
The SemanticScholar client ships in bibliofabric 0.9.0 and newer.
Authentication
The API key is optional. Set SEMANTICSCHOLAR_API_KEY (or pass
api_key to SemanticScholarSettings) and the client sends it as the
x-api-key header on every request, which moves you from the shared
anonymous pool to your own 1 request per second allocation. A value that
is blank after trimming counts as no key. Without a key the client runs
on the shared pool, where any request can answer HTTP 429.
Some fields (embedding, openAccessDoi) and some routes (dataset file
listings, diffs, snippet search) need a key regardless; the API answers
400 or 401 without one.
Quick start
import asyncio
from bibliofabric.semanticscholar import SemanticScholarClient
async def main():
async with SemanticScholarClient() as client:
paper = await client.papers.get("DOI:10.1038/nature12373")
print(paper.title, paper.year, paper.citationCount)
page = await client.papers.search(
query="photosynthesis", fields=["title", "year"], page_size=10
)
print(page.total, [paper.title for paper in page.results])
papers = await client.papers.batch(
["DOI:10.1038/nature12373", "ARXIV:1304.1068"], fields=["title"]
)
print(len(papers))
asyncio.run(main())
client.papers exposes get(), exists(), search(), iterate(),
collect(), first(), count(), batch(), bulk_search(),
bulk_iterate(), citations(), references(), authors(),
autocomplete(), and search_match(). client.authors exposes get(),
search(), iterate(), papers(), and batch(). client.recommendations
exposes for_paper() and for_list(). client.datasets exposes
releases(), latest(), release(), dataset(), and diffs(). client.snippets
and client.patents expose search() and get() respectively. Start with
papers and authors.
Sync usage
SemanticScholarSyncClient is generated from the async source and
behaves the same. The sync client uses plain httpx.Client and never
starts or touches an event loop, so it works in scripts, in Jupyter, in
threads, and when called from inside a running event loop.
from bibliofabric.semanticscholar import SemanticScholarSyncClient
with SemanticScholarSyncClient() as client:
paper = client.papers.get("DOI:10.1038/nature12373")
print(paper.title)
Examples
Runnable scripts live in
packages/bibliofabric/examples/semanticscholar:
quickstart.py for get, search, and bounded iteration,
batch_and_citations.py for batch lookup and the citation graph,
sync_quickstart.py for the sync twin, and snippet_search.py for
snippet search (needs a key with snippet access).
Rate limits
Semantic Scholar publishes 1000 requests per second for the whole
unauthenticated pool and 1 request per second for an API key. The pool is
contended, so keyless callers see HTTP 429 often. The client defaults to 1
request per second and concurrency 1, which is safe in both modes. Raise
SEMANTICSCHOLAR_MAX_REQUESTS_PER_SECOND only if you know your key's
tier. See upstream quirks for what the live API
actually did on 2026-11-27.
Links
- Papers
- Authors
- Recommendations
- Datasets
- Other routes (snippets, patents)
- Upstream quirks
- API reference