base
zocrates.discovery.providers.base ¶
Base interfaces and utilities for scholarly search providers.
DEFAULT_USER_AGENT
module-attribute
¶
CandidatePaper
dataclass
¶
CandidatePaper(candidate_id, title, authors=list(), year=None, venue=None, doi=None, arxiv_id=None, openalex_id='', abstract=None, tldr=None, is_oa=False, oa_pdf_url=None, oa_pdf_urls=list(), citation_count=0, primary_topic=None, keywords=list(), in_library=False)
Represents a discovered scholarly paper candidate.
from_dict
classmethod
¶
Deserialize CandidatePaper from a dictionary.
Source code in zocrates/discovery/models.py
to_dict ¶
Serialize CandidatePaper to a plain dictionary.
Source code in zocrates/discovery/models.py
SearchProvider ¶
Bases: ABC
Abstract base class for scholarly literature search providers.
resolve_identifier
abstractmethod
async
¶
Resolve a single scholarly paper by DOI, arXiv ID, or provider-specific ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
identifier
|
str
|
DOI, arXiv ID, or provider ID string. |
required |
Returns:
| Type | Description |
|---|---|
CandidatePaper | None
|
CandidatePaper if resolved, or None if not found. |
Source code in zocrates/discovery/providers/base.py
search
abstractmethod
async
¶
Search for scholarly literature matching the query and filters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
query
|
str
|
Free-text search terms or conceptual query. |
required |
limit
|
int
|
Maximum number of candidate papers to return. |
10
|
year_from
|
int | None
|
Optional minimum publication year (inclusive). |
None
|
year_to
|
int | None
|
Optional maximum publication year (inclusive). |
None
|
is_oa_only
|
bool
|
When True, restrict results to open-access works. |
False
|
Returns:
| Type | Description |
|---|---|
list[CandidatePaper]
|
List of CandidatePaper instances. |
Source code in zocrates/discovery/providers/base.py
TokenBucketRateLimiter ¶
Token-bucket rate limiter for respectful, throttled API consumption. Thread/asyncio safe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rate
|
float
|
Refill rate in tokens per second. |
10.0
|
capacity
|
float
|
Maximum burst capacity in tokens. |
10.0
|
Source code in zocrates/discovery/providers/base.py
acquire
async
¶
Acquire tokens from the bucket, sleeping if necessary until replenished.
Source code in zocrates/discovery/providers/base.py
make_user_agent ¶
Build a respectful User-Agent header string adhering to API etiquette.