Skip to main content

A Python SDK for searching PubMed using the NCBI E-Utilities

Project description

pubmed-sdk

python SDK for searching PubMed

pubmed_sdk

PyPI version Python 3.6 Python 3.7 Python 3.8 Python 3.9 Build Status

Pubmed_SDK is a Python client library for searching PubMed using the NCBI E-Utilities.

About Pubmed_sdk

Pubmed_SDK is a Python SDK that facilitates searching PubMed and retrieving article details using the NCBI E-Utilities. It abstracts the process of making HTTP requests to the E-Utilities API and parsing the XML responses, making it easier to focus on the data itself.

Installation

pip install pubmed_sdk

Usage

Search PubMed

You can search PubMed by creating a PubMed object and calling the search method with your search term:

from pubmed_sdk import PubMed

pubmed = PubMed()
results = pubmed.search('COVID-19')

The search method supports the following parameters:

  • term: The search term.
  • db: The database to search (default is 'pubmed').
  • retmax: The maximum number of results to return (default is 20).
  • usehistory: Whether to use the NCBI history feature (default is 'y').

Fetch Article Details

After searching, you can fetch the details of the articles using the fetch_details method:

id_list = results['id_list']    # ['33725716', '33725717']
details = pubmed.fetch_details(id_list).get('PubmedArticle')

This method accepts a list of IDs and returns a list of dictionaries containing the details of each article.

Here's an example of how to iterate through the results and print some information about each article:

for detail in details:
    article = detail['MedlineCitation']['Article']
    print(article['ArticleTitle'])
    print(article['Abstract']['AbstractText'], '\n\n')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pubmed_sdk-0.4.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

pubmed_sdk-0.4-py3-none-any.whl (4.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page