Skip to main content

Springer Nature API Client

Project description

Springer Nature API Client

PyPI Version Python Version License

A Python package to interact with the Springer Nature API for fetching metadata, open access articles, and text & data mining (TDM) content.


🚀 Installation

Install Python

Ensure you have Python installed (version 3.9+ recommended).

Windows: Download from python.org and install.

macOS: Install via Homebrew:

brew install python

Linux: Install using package manager (e.g., apt for Debian/Ubuntu):

sudo apt update && sudo apt install python3 python3-venv python3-pip

For Users

To install the package from PyPI(If you just want to use the package in your project):

pip install springernature_api_client

For Developers

If you're planning to contribute to the project:

  1. Install Poetry (dependency management tool) This project uses Poetry for dependency management. Install Poetry if you haven't already:
curl -sSL https://install.python-poetry.org | python3 -
  1. Clone the repository and install dependencies
   git clone https://github.com/springernature/springernature_api_client.git
   cd springernature_api_client
   poetry install --with dev
  1. Activate the virtual environment using Poetry:
poetry env use python
poetry shell
# or 
poetry env activate

See CONTRIBUTING.md for more details on the development workflow.

🔑 Setup

Before using the package, obtain an API key from Springer Nature Developer Portal.

Set the API key in your environment:

export SPRINGER_API_KEY="your_api_key_here"

Or pass it directly in Python:

api_key = "your_api_key_here"

📌 Basic Usage

Fetch Metadata and Export to Excel

import springernature_api_client.metadata as metadata
from springernature_api_client.utils import results_to_dataframe

# Initialize API Client
metadata_client = metadata.MetadataAPI(api_key="your_api_key")

# Fetch results (pagination enabled, stops at `s=200`)
response = metadata_client.search(q='keyword:"cancer"', p=20, s=1, fetch_all=False, is_premium=False)

# Convert API response to DataFrame & export to Excel
df = results_to_dataframe(response, export_to_excel=True, filename="articles.xlsx")

print(df.head())  # Display first few rows

📚 API Modules

1️⃣ Meta API

import springernature_api_client.meta as meta
from springernature_api_client.utils import results_to_dataframe

meta_client = meta.MetaAPI(api_key="your_api_key")
response = meta_client.search(q='keyword:"cancer"', p=20, s=1, fetch_all=False, is_premium=False)
df = results_to_dataframe(response, export_to_excel=True)
print(df.head())

2️⃣ Metadata API

import springernature_api_client.metadata as metadata
from springernature_api_client.utils import results_to_dataframe

metadata_client = metadata.MetadataAPI(api_key="your_api_key")
response = metadata_client.search(q='keyword:"cancer"', p=20, s=1, fetch_all=False, is_premium=False)
df = results_to_dataframe(response, export_to_excel=True)
print(df.head())

3️⃣ Open Access API

import springernature_api_client.openaccess as openaccess
from springernature_api_client.utils import results_to_dataframe

openaccess_client = openaccess.OpenAccessAPI(api_key="your_api_key")
response = openaccess_client.search(q='keyword:"cancer"', p=20, s=1, fetch_all=False, is_premium=False)
df = results_to_dataframe(response, export_to_excel=True)
print(df.head())

4️⃣ TDM (Text & Data Mining) API

import springernature_api_client.tdm as tdm
from springernature_api_client.utils import results_to_dataframe

tdm_client = tdm.TDMAPI(api_key="your_api_key/your_api_metric")
response = tdm_client.search(q='keyword:"cancer"', p=20, s=1, fetch_all=False, is_premium=False)
df = results_to_dataframe(response, export_to_excel=True)
print(df.head())

🔄 Pagination Handling (fetch_all=True)

If fetch_all=True, the API will automatically paginate through results.

response = metadata_client.search(q='keyword:"cancer"', p=20, s=1, fetch_all=False, is_premium=False)

📤 Exporting to Excel

By default, results_to_dataframe() saves the results as an Excel file:

df = results_to_dataframe(response, export_to_excel=True, filename="output.xlsx")

🛠 Troubleshooting

1️⃣ Invalid API Key

Ensure you pass the correct API key. Try setting the API key as an environment variable.

2️⃣ Rate Limit Exceeded (Error 429)

Springer Nature API limits requests per minute. If you hit the limit, wait or request a higher quota.

3️⃣ Connection Timeout

If requests timeout, check your internet connection. Try increasing the timeout value in the request.

📄 License

This project is licensed under the MIT License. See LICENSE for details.

👨‍💻 Contributing

We welcome contributions! See CONTRIBUTING.md for details. 🚀

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

springernature_api_client-0.0.7.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

springernature_api_client-0.0.7-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file springernature_api_client-0.0.7.tar.gz.

File metadata

File hashes

Hashes for springernature_api_client-0.0.7.tar.gz
Algorithm Hash digest
SHA256 3b461b53294822b788e4d0725acfe71b1f14caed5738f4c5a67c532897ca80a0
MD5 ae6ac0145e1980a2ab96bbc57d86d6fe
BLAKE2b-256 68e4388aae628c74488d6986e161430af330ab0b392b4a2b4165652bdda748b9

See more details on using hashes here.

File details

Details for the file springernature_api_client-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for springernature_api_client-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 94d4e5df17e9a91cd21e61c84ee13b89c8063297cd7cb5a711d889656fc6a8cf
MD5 e6b851ac7a5e5d981d42010119ad20f0
BLAKE2b-256 0faa94f88dcef4c27d60ec2f155b9e502bf2429e1e9906d4cff5f0fb870789ea

See more details on using hashes here.

Supported by

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