Authors
client.authors talks to the /author routes and returns Author models. Later blocks on this page reuse the client created here.
import asyncio
from bibliofabric.semanticscholar import SemanticScholarClient
client = SemanticScholarClient()
author = await client.authors.get("1741101", select=["name", "hIndex", "paperCount"])
print(author.author_id, author.name, author.h_index, author.paper_count)
1741101 Oren Etzioni 89 262
Get one author
get() takes the bare Semantic Scholar author id. Without select the API answers with authorId only, and externalIds and papers are key-gated upstream. A keyless request that asks for them answers HTTP 400. An unknown id raises NotFoundError; exists() returns False for one:
print(await client.authors.exists("1741101"))
True
The Author model uses snake_case field names (author_id, paper_count, h_index) and also accepts the API's camelCase wire names. Fields the API adds later land in model_extra.
Search authors
search() returns one Page. search(), iterate(), collect(), first(), and count() come from the resource base; paging uses offset and limit like the paper search:
page = await client.authors.search(
query="adam smith", select=["name", "affiliations"], page_size=5
)
print(page.total, page.results[0].name)
512 Adam M. Smith
A search page holds up to 1000 authors, and the client refuses a page whose offset + page_size reaches the 10,000-record cap with ConfigurationError.
List the papers of one author
papers(id) returns one page of Paper records. The route serves at most the most recent 10,000 papers of an author:
page = await client.authors.papers(
"1741101", select=["title", "year", "citationCount"], page_size=5
)
print(len(page.results), page.results[0].title[:50])
5 Beyond Model Alignment: The Case for Bounded Auton
Fetch many authors at once
batch_get() sends POST /author/batch calls of up to 1000 ids each and returns a dict keyed by the requested author id. The API answers null for unknown ids and the client drops those entries; the POST is a read and is sent with retries:
authors = await client.authors.batch_get(
["1741101", "1780531", "99999999"], select=["name", "hIndex"]
)
print(len(authors), [a.name for a in authors.values()])
2 ['Oren Etzioni', 'Daniel S. Weld']
Blank ids raise ConfigurationError before any request, and lists longer than 1000 are chunked into consecutive POSTs.
Where to go next
- Papers for the paper routes and the id forms.
- Upstream quirks for the key-gated author fields.