Snippets and patents
Snippets and patents live on the graph base URL alongside papers and authors. Later blocks on this page reuse the client created here.
import asyncio
from bibliofabric.semanticscholar import SemanticScholarClient
client = SemanticScholarClient()
Snippet search
client.snippets.search() talks to /snippet/search. Snippets are excerpts of roughly 500 words drawn from a paper's title, abstract, and body text. The route needs an API key with snippet access; keyless requests answer 429 from the anonymous pool, so this page shows the call and no output:
result = await client.snippets.search("protein folding", select=["text"], page_size=10)
for match in result.data:
print(match.score, match.snippet.text[:60])
The default page size is 10 and the API maximum is 1000. Each SnippetMatch carries the score, the snippet (with snippet_kind and annotations such as sentences and ref_mentions), and a minimal paper record on match.paper. result.retrieval_version holds the API's retrieval version. params adds query parameters the method does not name, such as paperIds, authors, year, or venue.
Get one patent
client.patents.get() fetches one patent by its UCID. Without select the answer holds ucid and title; claims is served by this route only:
patent = await client.patents.get("US10296086B2", select=["title", "abstract"])
print(patent.ucid, "|", patent.title[:50])
US10296086B2 | Dynamic gloves to convey sense of touch and movement for vir
Search patents
search() searches patents by plain-text query, ranked by BM25 relevance. The query is the query= keyword and is required. A page holds at most 100 patents, and claims is not served here:
page = await client.patents.search(
query="neural network", select=["title"], page_size=5
)
print(page.total, len(page.results), page.results[0].title[:30])
191339 5 Neural modeler of audio systems
page.next_cursor is the next offset as a string, or None on the last page. batch_get is disabled on patents: the API has no patent batch route, and the method refuses with ConfigurationError before any request.
Patents that cite a paper
outbound_citations(paper_id) returns one Page of the patents that cite one paper; the id takes the paper id forms (DOI:, CorpusId:, a bare S2 id, and so on). A paper that no patent cites answers HTTP 404, which raises NotFoundError:
citations = await client.patents.outbound_citations(
"CorpusId:4314121", select=["title"], page_size=5
)
print(citations.total, [p.title[:30] for p in citations.results[:2]])
9 ['Nanometer scale quantum thermo', 'Systems, apparatuses, and meth']
page.meta carries the envelope's total, offset, and next state, and page.next_cursor is the next offset as a string.
The Patent model declares the documented fields (application_ucids, cpc_codes, claims, cited_ucids, filing_date, publication_date, and more), uses snake_case names, and keeps unknown fields in model_extra.
Where to go next
- Papers for the paper id forms.
- Upstream quirks for what the patent routes served keyless.