Skip to main content

Python client for Copernicus Data Space Ecosystem (CDSE) - Drop-in replacement for sentinelsat

Project description

cdse-client

PyPI version Python License: MIT

Python client for Copernicus Data Space Ecosystem (CDSE) — a modern replacement for sentinelsat.

Requires Python >= 3.9.

Installation

pip install cdse-client              # Core
pip install cdse-client[geo]         # + shapely, geopandas, geopy
pip install cdse-client[dataframe]   # + pandas
pip install cdse-client[processing]  # + rasterio, numpy, pillow, matplotlib, shapely
pip install cdse-client[async]       # + aiohttp, aiofiles
pip install cdse-client[all]         # Everything

Setup

  1. Register at Copernicus Data Space
  2. Create OAuth2 credentials in Account Settings
  3. Configure credentials using one of the methods below:

Option A: Environment variables (recommended for production)

macOS/Linux (bash/zsh)

export CDSE_CLIENT_ID="your-client-id"
export CDSE_CLIENT_SECRET="your-client-secret"

Windows (PowerShell)

$env:CDSE_CLIENT_ID = "your-client-id"
$env:CDSE_CLIENT_SECRET = "your-client-secret"

Option B: .env file (recommended for development)

Copy the example file and fill in your credentials:

cp .env.example .env
# Edit .env with your credentials

The .env file format:

CDSE_CLIENT_ID=your-client-id
CDSE_CLIENT_SECRET=your-client-secret

Note: The .env file is automatically ignored by git. Never commit credentials.

Quick start

from cdse import CDSEClient

client = CDSEClient()  # Uses environment variables

# Search Sentinel-2 products
products = client.search(
    bbox=[9.0, 45.0, 9.5, 45.5],  # Milan area
    start_date="2024-01-01",
    end_date="2024-01-31",
    collection="sentinel-2-l2a",
    cloud_cover_max=20,
    limit=5
)

# Download
for product in products:
    client.download(product)

Search methods

# By bounding box
products = client.search(bbox=[lon_min, lat_min, lon_max, lat_max], ...)

# By geographic point
products = client.search_by_point(lon=9.19, lat=45.46, buffer_km=10, ...)

# By city name (requires [geo])
products = client.search_by_city(city_name="Milano, Italia", ...)

# By product name (OData catalogue)
products = client.search_by_name("S2A_MSIL2A_20240115T102351...", exact=True)

# By UUID (OData catalogue)
product = client.search_by_id("a1b2c3d4-e5f6...")

Note: search() returns STAC results; product identifiers there are not guaranteed to be OData UUIDs. If you need a UUID, use search_by_name(..., exact=True).

Collections: sentinel-1-grd, sentinel-2-l1c, sentinel-2-l2a, sentinel-3-olci, sentinel-3-slstr, sentinel-5p-l2

Download methods

# Single product
client.download(product, output_dir="./downloads")

# Multiple products (parallel)
client.download_all(products, parallel=True, max_workers=4)

# With checksum verification
client.download_with_checksum(product)

# Quicklook preview only
client.download_quicklook(product)
client.download_all_quicklooks(products)

Data export (sentinelsat compatible)

# DataFrame for sorting/filtering
df = client.to_dataframe(products)
df.sort_values('cloud_cover').to_csv("products.csv")

# GeoJSON footprints
geojson = client.to_geojson(products)

# GeoDataFrame for spatial analysis (requires [geo])
gdf = client.to_geodataframe(products)
gdf.plot()

# Total size
size_gb = client.get_products_size(products)

Geometry utilities

from cdse import read_geojson, geojson_to_wkt, bbox_to_geojson

geojson = read_geojson("area.geojson")
wkt = geojson_to_wkt(geojson)
geojson = bbox_to_geojson([9.0, 45.0, 9.5, 45.5])

Processing

pip install cdse-client[processing]
from cdse.processing import calculate_ndvi, crop_and_stack, preview_product

# Extract bands, crop to AOI, stack into GeoTIFF
result = crop_and_stack(
    safe_path="S2A_MSIL2A_20240115.zip",
    bbox=[9.15, 45.45, 9.25, 45.55],
    bands=["B04", "B03", "B02", "B08"],
    resolution=10
)

# Calculate NDVI
ndvi = calculate_ndvi(nir_path="B08.tif", red_path="B04.tif")

# Preview in Jupyter
preview_product(safe_path="...", bbox=[...], display=True)

Async support

pip install cdse-client[async]
import asyncio
from cdse import CDSEClientAsync

async def main():
    async with CDSEClientAsync(client_id, client_secret) as client:
        products = await client.search(...)
        paths = await client.download_all(products)

asyncio.run(main())

CLI

# Search
cdse search --bbox 9.0,45.0,9.5,45.5 -s 2024-01-01 -e 2024-01-31 -c 20 -l 5

# Download by name/UUID
cdse download --name S2A_MSIL2A_20240115T102351...
cdse download --uuid a1b2c3d4-... [--quicklook] [--checksum]

# List collections
cdse collections

# Help
cdse --help

Migration from sentinelsat

sentinelsat cdse-client
SentinelAPI(user, password) CDSEClient(client_id, client_secret)
api.query(area, date, ...) client.search(bbox, start_date, ...)
api.download(uuid) client.download(product)
api.download_all(products) client.download_all(products)
api.download_quicklook(uuid) client.download_quicklook(product)
api.to_dataframe(products) client.to_dataframe(products)
api.to_geojson(products) client.to_geojson(products)
read_geojson(path) read_geojson(path)
geojson_to_wkt(geojson) geojson_to_wkt(geojson)

Resources

Documentation (MkDocs)

Build and preview locally:

pip install -e ".[docs]"
mkdocs serve

Disclaimer

This is an unofficial client library and is not affiliated with, endorsed by, or connected to ESA, the European Commission, or the Copernicus Programme.

Copernicus Data Space Ecosystem and Sentinel data are provided by ESA and the European Commission. Users must:

  1. Register at dataspace.copernicus.eu
  2. Comply with the Terms and Conditions
  3. Respect API quotas and fair usage policies

Sentinel data is available under a free, full, and open data policy for any use, including commercial. See the Sentinel Data Legal Notice.

License

MIT License - see LICENSE

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

cdse_client-0.3.2.tar.gz (53.1 kB view details)

Uploaded Source

Built Distribution

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

cdse_client-0.3.2-py3-none-any.whl (44.9 kB view details)

Uploaded Python 3

File details

Details for the file cdse_client-0.3.2.tar.gz.

File metadata

  • Download URL: cdse_client-0.3.2.tar.gz
  • Upload date:
  • Size: 53.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cdse_client-0.3.2.tar.gz
Algorithm Hash digest
SHA256 176d6309855ffad1047aa231d2be361459b38c90d77a0d7f504fe474a8d48ff8
MD5 1dce443da77c5324eb624a2eb6c0755c
BLAKE2b-256 0c32eaea620f301820ee70e34ae09d20e17de0fde910300488caa2cc6e128932

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdse_client-0.3.2.tar.gz:

Publisher: publish.yml on VTvito/cdse-client

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

File details

Details for the file cdse_client-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: cdse_client-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 44.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cdse_client-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e064c42017a7b9f7de1eeff1b5621df9d04671b9f385b8e4aceacbbab7a2a13d
MD5 582ad9100449a167499838f2d6f35c43
BLAKE2b-256 3cb2ece32496a1d2508aeb35245a895321e9ce0f59f639e8f5d5acbd9c1da3c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdse_client-0.3.2-py3-none-any.whl:

Publisher: publish.yml on VTvito/cdse-client

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