S&P Global API Client
Project description
S&P Global API Package
A powerful Python package for accessing S&P Global (formerly IHS Markit) energy and climate data services. Specifically designed for CCUS (Carbon Capture, Utilization, and Storage), Upstream, and Climate Scenario analytics.
Description
This package provides a unified, high-level interface for interacting with various S&P Global API products. It abstracts the complexity of different API architectures (OData vs. standard REST) and provides automated tools for data retrieval, mapping, and standardized styling.
Key Features
- Unified API Client: A single
SPGlobalAPIClientclass that handles authentication and URL construction for multiple data clusters. - Auto-Pagination: Large datasets (1M+ rows) are automatically fetched in chunks using the
fetch_allmethod. - Smart Filtering: Supports complex dictionary-based filters and raw OData query strings.
- Mapping Utilities: Specialized tools for creating interactive geospatial visualizations with Folium and GeoPandas.
- S&P Global Styling: Apply consistent, publication-ready visualization styles for charts and presentations.
- Metadata Discovery: Built-in support for retrieving dataset schemas and view definitions.
Installation
Requirements
- Python >= 3.12
- Dependencies:
pandas,requests,matplotlib,geopandas,folium,python-dotenv
Install from PyPI
pip install spg_api
Configuration
Option 1: .env File
Create a .env file in your project root:
CONNECT_KEY=your_api_key
CONNECT_PW=your_api_password
Option 2: Manual Configuration
You can also set credentials directly in your code:
import spg_api
spg_api.username = "your_api_key"
spg_api.password = "your_api_password"
Usage
1. Unified API Client
The SPGlobalAPIClient is the primary entry point for all data retrieval.
import spg_api
# Initialize for Energy/Climate Scenarios
client = spg_api.SPGlobalAPIClient("energyandclimatescenarios")
# Fetch data
df = client.retrieve_data(
view_name="coal_markets",
filters={"Country": "China"},
select=["Year", "Value"]
)
2. Publication-Ready Styling
Apply standardized S&P Global styling to your Matplotlib charts.
import matplotlib.pyplot as plt
import spg_api.spg_style as spg_style
style = spg_style.SpglobalStyle(theme='light')
fig, ax = plt.subplots(figsize=spg_style.get_edp_figsize())
# ... plotting logic ...
style.add_footnotes(fig, source="S&P Global Market Intelligence")
Project Structure
spg_api/
├── spg_api/
│ ├── url_generator.py # Core Unified Client (SPGlobalAPIClient)
│ ├── analysis.py # Specialized scenario analysis classes
│ ├── spg_style.py # S&P Global visualization styling
│ ├── map.py # Geospatial mapping utilities
│ ├── utils.py # API request and response helpers
│ └── const.py # Constants and styling tokens
├── README.md # Documentation
└── pyproject.toml # Build configuration
Contact
For questions or support, contact the maintainer at kovkov@163.com.
Proprietary to S&P Global. Reproduction without permission is prohibited.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spg_api-0.1.1.tar.gz.
File metadata
- Download URL: spg_api-0.1.1.tar.gz
- Upload date:
- Size: 32.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.0 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7160ca74b996096cc1ebe3dd45906220fe84058e80df0de1a883d0728580bbec
|
|
| MD5 |
91b9e620f6585d9096f703278dada8a2
|
|
| BLAKE2b-256 |
85b36ea73f70d84279e9ccd9af733e8bb7acbe7537f88aa53f5967ae3327e492
|
File details
Details for the file spg_api-0.1.1-py3-none-any.whl.
File metadata
- Download URL: spg_api-0.1.1-py3-none-any.whl
- Upload date:
- Size: 33.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.12.0 Darwin/24.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2009df7a0e8eebbfb35d18a2378c50ba095cc31b0ebed89887d05df751ba62bc
|
|
| MD5 |
3bfa5e86589572865a51f619c9f25942
|
|
| BLAKE2b-256 |
d0fc2418dfcc1c7fc884360d4e8d4768b08b9ef7cee816b69c9059839220aa33
|