Camel.toolkits.pubmed toolkit
PubMedToolkit
A toolkit for interacting with PubMed’s E-utilities API to access MEDLINE data.
This toolkit provides functionality to search and retrieve papers from the PubMed database, including abstracts, citations, and other metadata.
Parameters:
- timeout (Optional[float]): The timeout for API requests in seconds. (default: :obj:
None
)
init
Initializes the PubMedToolkit.
_make_request
Makes a request to the PubMed/MEDLINE API with error handling and retries.
Parameters:
- endpoint (str): The API endpoint to call.
- params (Dict[str, Union[str, int]]): Query parameters.
- retries (int, optional): Number of retry attempts. (default: :obj:
3
)
Returns:
Optional[Dict[str, Any]]: JSON response if successful, else None.
search_papers
Search for biomedical papers in MEDLINE via PubMed with advanced filtering options.
Parameters:
- query (str): The search query string.
- max_results (int, optional): Maximum number of results to return. (default: :obj:
10
) - sort (str, optional): Sort order - ‘relevance’ or ‘date’. (default: :obj:
"relevance"
) - date_range (Optional[Dict[str, str]], optional): Date range filter with ‘from’ and ‘to’ dates in YYYY/MM/DD format. (default: :obj:
None
) - publication_type (Optional[List[str]], optional): Filter by publication types (e.g., [“Journal Article”, “Review”]). (default: :obj:
None
)
Returns:
List[Dict[str, str]]: List of papers with their metadata.
get_paper_details
Get detailed information about a specific biomedical paper from MEDLINE/PubMed.
Parameters:
- paper_id (Union[str, int]): PubMed ID of the paper.
- include_references (bool, optional): Whether to include referenced papers. (default: :obj:
False
)
Returns:
Optional[Dict[str, Any]]: Paper details including title, authors, abstract, etc., or None if retrieval fails.
get_abstract
Get the abstract of a specific biomedical paper from MEDLINE/ PubMed.
Parameters:
- paper_id (Union[str, int]): PubMed ID of the paper.
Returns:
str: The abstract text.
get_citation_count
Get the number of citations for a biomedical paper in MEDLINE/ PubMed.
Parameters:
- paper_id (Union[str, int]): PubMed ID of the paper.
Returns:
int: Number of citations, or 0 if retrieval fails.
get_related_papers
Get biomedical papers related to a specific paper in MEDLINE/ PubMed.
Parameters:
- paper_id (Union[str, int]): PubMed ID of the paper.
- max_results (int, optional): Maximum number of results to return. (default: :obj:
10
)
Returns:
List[Dict[str, Any]]: List of related papers with their metadata.
get_tools
Returns:
List[FunctionTool]: List of available tools.