Complete API documentation - All classes, methods, and parameters
This section provides detailed documentation for all PyEuropePMC classes and methods. The API is organized around several core clients:
| Client | Purpose | Key Methods |
|---|---|---|
| SearchClient | Query Europe PMC database | search(), get_by_id() |
| FullTextClient | Download full-text content | download_pdf(), get_xml() |
| ArticleClient | Article-specific operations | get_citations(), get_references() |
| FullTextXMLParser | Parse XML documents | extract_metadata(), extract_tables() |
| FTPDownloader | Bulk downloads via FTP | download_bulk() |
from pyeuropepmc import QueryBuilder
qb = QueryBuilder(validate=True)
The advanced fluent API for building complex search queries with type safety and validation.
from pyeuropepmc import EuropePMC
client = EuropePMC()
The main client class for interacting with the Europe PMC API.
EuropePMC(
base_url: str = "https://www.ebi.ac.uk/europepmc/webservices/rest",
timeout: int = 30,
retries: int = 3,
rate_limit: float = 1.0
)
Parameters:
base_url: Base URL for the Europe PMC APItimeout: Request timeout in secondsretries: Number of retry attempts for failed requestsrate_limit: Minimum time between requests in secondsSearch for articles in the Europe PMC database.
search(
query: str,
source: str = "MED",
limit: int = 25,
offset: int = 0,
sort: str = "relevance",
format: str = "json",
**kwargs
) -> List[Article]
Parameters:
query: Search query stringsource: Data source (MED, PMC, AGR, CBA, CTX, ETH, HIR, PAT)limit: Maximum number of results to returnoffset: Number of results to skipsort: Sort order (relevance, date, cited)format: Response format (json, xml, dc)Returns: List of Article objects
Example:
results = client.search("cancer therapy", limit=10, sort="date", format="json")
Fetch a specific article by its ID.
fetch_by_id(
pmid: str = None,
pmcid: str = None,
doi: str = None,
format: str = "json"
) -> Article
Get citations for a specific article.
fetch_citations(
pmid: str = None,
pmcid: str = None,
limit: int = 25,
offset: int = 0
) -> List[Citation]
Get references cited by a specific article.
fetch_references(
pmid: str = None,
pmcid: str = None,
limit: int = 25,
offset: int = 0
) -> List[Reference]
Represents a scientific article from Europe PMC.
Attributes:
title: Article titleauthors: List of author namesjournal: Journal namepub_year: Publication yearpmid: PubMed IDpmcid: PMC IDdoi: DOIabstract: Article abstractkeywords: List of keywordsmesh_terms: List of MeSH termsRepresents a citation to an article.
Attributes:
pmid: PubMed ID of citing articletitle: Title of citing articleauthors: Authors of citing articlejournal: Journal of citing articlepub_year: Publication yearRepresents a reference cited by an article.
Attributes:
pmid: PubMed ID of referenced articletitle: Title of referenced articleauthors: Authors of referenced articlejournal: Journal of referenced articlepub_year: Publication yearEuropePMCError: Base exception classAPIError: API-related errorsAuthenticationError: Authentication failuresRateLimitError: Rate limiting exceededValidationError: Input validation errorsfrom pyeuropepmc import EuropePMC, APIError, RateLimitError
try:
client = EuropePMC()
results = client.search("invalid query")
except APIError as e:
print(f"API Error: {e}")
except RateLimitError as e:
print(f"Rate limit exceeded: {e}")
except Exception as e:
print(f"Unexpected error: {e}")
All public methods use type annotations and validate input parameters. Invalid arguments will raise exceptions with clear error messages.
EUROPEPMC_API_KEY: API key for authenticated requestsEUROPEPMC_BASE_URL: Custom base URLEUROPEPMC_TIMEOUT: Default timeout in secondsEUROPEPMC_RATE_LIMIT: Default rate limit in secondsCreate a .pyeuropepmc.conf file in your home directory:
[api]
base_url = https://www.ebi.ac.uk/europepmc/webservices/rest
timeout = 30
retries = 3
rate_limit = 1.0
[logging]
level = INFO
format = %(asctime)s - %(name)s - %(levelname)s - %(message)s
| Section | Why Visit? |
|---|---|
| Getting Started | Installation and basics |
| Features | What PyEuropePMC can do |
| Examples | Working code samples |
| Advanced | Power user features |