Async client
cdse.async_client.CDSEClientAsync
Async client for Copernicus Data Space Ecosystem.
This client provides async methods for downloading products, enabling concurrent downloads for better performance.
Example
async with CDSEClientAsync(client_id, client_secret) as client: ... products = await client.search(...) ... paths = await client.download_all(products)
__init__(client_id: Optional[str] = None, client_secret: Optional[str] = None, output_dir: str = '.', max_concurrent: int = 4)
Initialize the async client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client_id
|
Optional[str]
|
OAuth2 client ID |
None
|
client_secret
|
Optional[str]
|
OAuth2 client secret |
None
|
output_dir
|
str
|
Default output directory for downloads |
'.'
|
max_concurrent
|
int
|
Maximum concurrent downloads |
4
|
__aenter__() -> CDSEClientAsync
async
Async context manager entry.
__aexit__(exc_type: Any, exc_val: Any, exc_tb: Any) -> None
async
Async context manager exit.
close() -> None
async
Close the session.
search(bbox: list[float], start_date: str, end_date: str, collection: str = 'sentinel-2-l2a', cloud_cover_max: float = 100.0, limit: int = 10, **kwargs: Any) -> list[Product]
async
Search for products asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bbox
|
list[float]
|
Bounding box [min_lon, min_lat, max_lon, max_lat] |
required |
start_date
|
str
|
Start date (YYYY-MM-DD) |
required |
end_date
|
str
|
End date (YYYY-MM-DD) |
required |
collection
|
str
|
Collection name |
'sentinel-2-l2a'
|
cloud_cover_max
|
float
|
Maximum cloud cover percentage |
100.0
|
limit
|
int
|
Maximum results |
10
|
**kwargs
|
Any
|
Additional STAC parameters |
{}
|
Returns:
| Type | Description |
|---|---|
list[Product]
|
List of products matching criteria |
download(product: Product, output_dir: Optional[str] = None) -> Path
async
Download a single product asynchronously.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
product
|
Product
|
Product to download |
required |
output_dir
|
Optional[str]
|
Override output directory |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path to downloaded file |
download_all(products: list[Product], output_dir: Optional[str] = None) -> list[Path]
async
Download multiple products concurrently.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
products
|
list[Product]
|
List of products to download |
required |
output_dir
|
Optional[str]
|
Override output directory |
None
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
List of paths to downloaded files |
cdse.async_client.download_products_async(client_id: str, client_secret: str, products: list[Product], output_dir: str = '.', max_concurrent: int = 4) -> list[Path]
async
Convenience function for async downloads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client_id
|
str
|
OAuth2 client ID |
required |
client_secret
|
str
|
OAuth2 client secret |
required |
products
|
list[Product]
|
List of products to download |
required |
output_dir
|
str
|
Output directory |
'.'
|
max_concurrent
|
int
|
Maximum concurrent downloads |
4
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
List of downloaded file paths |
Example
from cdse import CDSEClient from cdse.async_client import download_products_async
First search with sync client
client = CDSEClient(client_id, client_secret) products = client.search(...)
Then download asynchronously
import asyncio paths = asyncio.run(download_products_async( ... client_id, client_secret, products, max_concurrent=8 ... ))