Skip to main content

Simple Python client for the United Nations Statistics Division SDG API

Project description

sdgdata

sdgdata is an unofficial Python client for SDG data from the UNSD SDG API.

It provides a simple client to retrieve Sustainable Development Goal metadata and data from Python, with models derived from the UNSD SDG API schema.

Features

  • Fetch SDG goals, targets, indicators, and series metadata.
  • Look up geographic areas and M49 area codes.
  • Retrieve paginated SDG series observations with simple Python calls.
  • Validate structured API responses with Pydantic models.
  • Load observation data into analysis tools such as pandas or Polars.

Installation

Install from PyPI:

uv add sdgdata

or:

pip install sdgdata

Quick Start

from sdgdata import SDGClient
from sdgdata.client import is_single_time_series

client = SDGClient()

# Find available geographic areas and SDG targets.
areas = client.get_geo_areas()
targets = client.get_targets()

# Find latest-release series codes for a target.
series = client.get_series_codes(target_code="3.8")
series_code = series[-1].code
area_code = areas[0].geoAreaCode

# Inspect available disaggregation dimensions for a series.
dimensions = client.get_series_dimensions(series_code)

# Fetch the coarsest available disaggregation by default.
data = client.get_series_data(
    series_codes=[series_code],
    area_code=area_code,
    start_period="2015",
    end_period="2026",
)

assert is_single_time_series(data)

# To fetch every disaggregation, opt into the unfiltered API response.
all_disaggregations = client.get_series_data(
    series_codes=[series_code],
    area_code=area_code,
    start_period="2015",
    end_period="2026",
    dimensions="all",
)

# Or request a specific disaggregation slice.
custom_slice = client.get_series_data(
    series_codes=[series_code],
    area_code=area_code,
    dimensions={"Reporting Type": "G"},
)

get_series_data() returns a list of dictionaries, making it straightforward to create a dataframe for analysis. It normalizes singleton goal, target, and indicator arrays to strings, and integral timePeriodStart values to integers. By default, it filters to the coarsest available disaggregation, such as all ages, both sexes, and total groups when those dimension values exist. For the upstream observation field descriptions, see the UNSD SDG API Swagger documentation.

Documentation

  • Development: setup, tests, fixture refreshes, builds, and CI behavior.
  • Model generation: generated models, stale checks, and OpenAPI source data.

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

sdgdata-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

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

sdgdata-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file sdgdata-0.1.0.tar.gz.

File metadata

  • Download URL: sdgdata-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sdgdata-0.1.0.tar.gz
Algorithm Hash digest
SHA256 afb46c94c7012a179f73b3e7579987f976b7efeead265f73bd08bd3323db20e0
MD5 c343ac8621220a7825a0b7fd8bb4672b
BLAKE2b-256 fd1a5744317bdf59eead9cea5118d82836c1e61533b54d08ffc26b7517877f92

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdgdata-0.1.0.tar.gz:

Publisher: release.yml on v-a-s-a/sdgdata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sdgdata-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sdgdata-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sdgdata-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efb6b58018260ab7765b0475b36c20362346884cb9fcbca783c8fd26ff93df4c
MD5 eb12c66e4c40ba8d4d43c5b79e858b31
BLAKE2b-256 f9d5ec824d9cb0765158c76d3f78be0409e0554d77755e2eede55fb9bb08c742

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdgdata-0.1.0-py3-none-any.whl:

Publisher: release.yml on v-a-s-a/sdgdata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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