Skip to main content

S&P Global API Client

Project description

S&P Global API Package (Non-official)

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.

Disclaimer: This is NOT an official API package provided by S&P Global. It is a community-driven project created by analysts to simplify access to S&P Global data. Please reach out to support.energy@spglobal.com for official support, and more information on the use of S&P Global data.

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 SPGlobalAPIClient class that handles authentication and URL construction for multiple data clusters.
  • Auto-Pagination: Large datasets (1M+ rows) are automatically fetched in chunks using the fetch_all method.
  • 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


Download files

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

Source Distribution

spg_api-0.1.2.tar.gz (24.5 kB view details)

Uploaded Source

Built Distribution

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

spg_api-0.1.2-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file spg_api-0.1.2.tar.gz.

File metadata

  • Download URL: spg_api-0.1.2.tar.gz
  • Upload date:
  • Size: 24.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.0 Darwin/24.6.0

File hashes

Hashes for spg_api-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a9309d0ccfb156e88b3a5bc76aec945beecf6ff5190d5dbfc687ebdc6216737f
MD5 25f05919790577f4fe59ea853ceb4098
BLAKE2b-256 d29dd33a3d2a40eb26afcf73fd32041f06b592d3be4b7dad2a4503ccd19a9d19

See more details on using hashes here.

File details

Details for the file spg_api-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: spg_api-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 25.1 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

Hashes for spg_api-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e081702c23fa1cc90b15464ed7eec57ab17cd57b515545db22027815077feaff
MD5 1596233ec653df2628153f7b28f24481
BLAKE2b-256 fc78621671c2c04d407bdb4d4abad8fb0d9713ac4429227a3cc05a8598f72c29

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