Skip to main content

Springer Nature API Wrapper

Project description

SpringerNature API Wrapper

PyPI Version Python Version License

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


🚀 Installation

Install Python

Ensure you have Python installed (version 3.7+ 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

Create a Virtual Environment (Recommended)

It's best to install the package inside a virtual environment to avoid conflicts.

# Create a virtual environment (venv)
python -m venv venv

# Activate the virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate

# Upgrade pip
pip install --upgrade pip

Install the Package

pip install springernature_api_client

🔑 Setup

Before using the package, obtain an API key from SpringerNature 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")
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)

SpringerNature 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.

👨‍💻 Contributing

We welcome contributions! Open an issue or submit a pull request. 🚀

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.2.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

springernature_api_client-0.0.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for springernature_api_client-0.0.2.tar.gz
Algorithm Hash digest
SHA256 29e9c51eccf82dae80759810a342c146f636c1c36705d36340af077b42ecbc1a
MD5 0c671bc36af6056566e864b591157ff3
BLAKE2b-256 be0d21e561ef0c2d04fb1737d9845727930e8612b5b0f9b48498ea7e0cf5266b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for springernature_api_client-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 12a048b7ca3a75b24eef10c7f5f8894f55d4dc5ae1741f920f706d979470e40d
MD5 e0ebd0694be89b047320ad60170978ce
BLAKE2b-256 689bc02dcd52dc23c6876a6e4da62244c023399b0b975e8bf266b386f5b11127

See more details on using hashes here.

Supported by

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