### Available Format Conversions Response (HTTP) Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md Example JSON response listing format conversions that can be requested. Keys represent target formats, and boolean values indicate if a conversion to that format is available. ```http HTTP/1.1 200 OK Content-Type: application/json { "GeoTIFF": true, "NetCDF": true, "CSV": false, "Shapefile": true } ``` -------------------------------- ### Full EEA Dataset Download Response (HTTP) Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md Example response received after successfully requesting a download for an EEA dataset. It confirms the request was accepted and provides a `task_id` which can be used to monitor the background download process. ```http HTTP/1.1 202 Accepted Content-Type: application/json { "task_id": "unique-task-identifier", "status": "accepted", "message": "Download request accepted. You will be notified by email when it is ready." } ``` -------------------------------- ### Available Projections Response (HTTP) Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md Example response containing a list of projection codes (e.g., EPSG codes) that are available as output formats for the specified dataset. ```http HTTP/1.1 200 OK Content-Type: application/json [ "EPSG:4326", "EPSG:3035", "EPSG:32632" ] ``` -------------------------------- ### Search Datasets Response (HTTP) Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md Example of a JSON response from the `@search` endpoint when querying for datasets. It includes details like the dataset's `@id`, `UID`, `dataset_full_format`, and `dataset_download_information`, along with pagination details in the `batching` key. ```http HTTP/1.1 200 OK Content-Type: application/json { "@context": "...", "@id": "https://clms.example.com/api/@search", "items": [ { "@id": "https://clms.example.com/api/dataset1", "UID": "unique-id-dataset1", "dataset_full_format": "GeoTIFF", "dataset_download_information": [ { "@id": "https://clms.example.com/api/dataset1/file1", "full_format": "GeoTIFF", "layers": ["band1", "band2"] } ], "title": "Example Dataset 1" }, { "@id": "https://clms.example.com/api/dataset2", "UID": "unique-id-dataset2", "dataset_full_format": "NetCDF", "dataset_download_information": [ { "@id": "https://clms.example.com/api/dataset2/fileA", "full_format": "NetCDF" } ], "title": "Example Dataset 2" } ], "batching": { "@id": "https://clms.example.com/api/@search?fullobjects=1&metadata_fields=UID%2Cdataset_full_format%2Cdataset_download_information", "first": null, "last": "https://clms.example.com/api/@search?b_size=25&fullobjects=1&metadata_fields=UID%2Cdataset_full_format%2Cdataset_download_information&b_start=25", "next": "https://clms.example.com/api/@search?b_size=25&fullobjects=1&metadata_fields=UID%2Cdataset_full_format%2Cdataset_download_information&b_start=25", "prev": null }, "items_total": 50 } ``` -------------------------------- ### HTTP Response: Prepackaged File Search Results Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md This snippet shows an example HTTP response from the dataset search endpoint when querying specifically for information about available prepackaged files. It illustrates the structure, particularly the inclusion of the `downloadable_files` attribute which contains metadata and identifiers for each available prepackaged file. ```http HTTP/1.1 200 OK Content-Type: application/json { "downloadable_files": [ { "@id": "prepackaged-file-1", "title": "File 1", "size": "10MB", "format": "GeoTIFF" }, { "@id": "prepackaged-file-2", "title": "File 2", "size": "25MB", "format": "CSV" } ], "count": 2 } ``` -------------------------------- ### Example API Token Record Structure Source: https://github.com/eea/clms-api-docs/blob/master/source/authentication.md Displays an example JSON structure representing a stored API token record as seen in the CLMS website profile page. This specific example shows a revoked token and includes metadata like ID, name, client ID, user ID, token URI, issue date, and revocation date. Note that the sensitive private key is typically not stored in such records and must be saved separately upon token creation for use in JWT generation. ```json { "id": "some-unique-token-id", "name": "My Revoked API Token", "client_id": "clms-api-user-xyz123", "user_id": "user.name@ec.europa.eu", "token_uri": "https://clms.api.copernicus.eu/@@oauth2-token", "issued": "2023-10-26T10:00:00Z", "revoked": "2023-10-27T11:00:00Z" } ``` -------------------------------- ### Requesting Full EEA Dataset Download CLMS API (cURL, Wget, Python) Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md Demonstrates how to request a download for a dataset. This example shows a request for a full EEA dataset, which is processed in the background. The response includes a task ID. ```curl curl -X POST "https://clms.example.com/api/@download-request" \ -H "Content-Type: application/json" \ -d '{ "uid": "eea-dataset-uid", "file_id": "https://clms.example.com/api/eea-dataset-uid/file-id", "download_format": "GeoTIFF", "full_dataset": true }' ``` ```wget wget --method=POST --header='Content-Type: application/json' --body-data='{ "uid": "eea-dataset-uid", "file_id": "https://clms.example.com/api/eea-dataset-uid/file-id", "download_format": "GeoTIFF", "full_dataset": true }' "https://clms.example.com/api/@download-request" -O - ``` ```python import requests url = "https://clms.example.com/api/@download-request" data = { "uid": "eea-dataset-uid", "file_id": "https://clms.example.com/api/eea-dataset-uid/file-id", "download_format": "GeoTIFF", "full_dataset": True } response = requests.post(url, json=data) print(response.json()) ``` -------------------------------- ### HTTP Response: Combined Download Request Confirmation Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md This snippet shows an example HTTP response for a download request that includes both regular datasets and prepackaged files. Similar to single download requests, the response contains identifiers (like `task_id`) to track the progress of the download preparation process, which the system internally splits into separate packages for efficiency. ```http HTTP/1.1 202 Accepted Content-Type: application/json { "task_id": "fedcba98-7654-3210-dcba-9876543210fe", "status": "accepted", "message": "Combined download request accepted. Processing split into multiple packages." } ``` -------------------------------- ### Checking Available Format Conversions CLMS API (cURL, Wget, Python) Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md Queries the API to get a list of possible format conversions available for downloads. The response is a JSON object where keys are format names and values are booleans indicating availability. It is recommended to download in the original format if possible. ```curl curl -X GET "https://clms.example.com/api/@available-conversions" ``` ```wget wget -O - "https://clms.example.com/api/@available-conversions" ``` ```python import requests url = "https://clms.example.com/api/@available-conversions" response = requests.get(url) print(response.json()) ``` -------------------------------- ### Full Non-EEA Dataset Download Error Response (HTTP) Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md Example error response when a full download of a non-EEA dataset is requested via this endpoint. The response explains that full downloads for such datasets require using an alternative API endpoint that provides direct links. ```http HTTP/1.1 400 Bad Request Content-Type: application/json { "error": { "type": "Bad Request", "message": "Full downloads of external datasets are not supported on this endpoint. Please use the alternative API endpoint for direct links." } } ``` -------------------------------- ### Searching Datasets CLMS API (cURL, Wget, Python) Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md Demonstrates how to search for datasets using the `@search` endpoint. The query requests specific fields like `UID`, `dataset_full_format`, and `dataset_download_information` necessary for initiating a download request. Pagination (`batching` key or `b_size` parameter) might be needed for large result sets. ```curl curl -X GET "https://clms.example.com/api/@search?fullobjects=1&metadata_fields=UID%2Cdataset_full_format%2Cdataset_download_information" ``` ```wget wget -O - "https://clms.example.com/api/@search?fullobjects=1&metadata_fields=UID%2Cdataset_full_format%2Cdataset_download_information" ``` ```python import requests url = "https://clms.example.com/api/@search" params = {"fullobjects": 1, "metadata_fields": "UID,dataset_full_format,dataset_download_information"} response = requests.get(url, params=params) print(response.json()) ``` -------------------------------- ### HTTP Response: Prepackaged File Download Request Confirmation Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md This snippet illustrates the typical HTTP response received after successfully submitting a request to download one or more prepackaged files using their `@id`. The response confirms acceptance of the request and includes a `task_id` which is essential for monitoring the download processing status. ```http HTTP/1.1 202 Accepted Content-Type: application/json { "task_id": "abcdef12-3456-7890-abcd-ef1234567890", "status": "accepted" } ``` -------------------------------- ### Generating JWT Grant - Python Source: https://github.com/eea/clms-api-docs/blob/master/build/html/_sources/authentication.md.txt This Python snippet demonstrates how to load a saved service key from a file, extract the private key, and use it along with other details from the service key to construct and sign a JWT authorization grant. This grant is required to obtain an access token. Dependencies include `json`, `jwt`, and `time`. ```python import json import jwt import time # Load saved key from filesystem service_key = json.load(open('my_saved_key.json', 'rb')) private_key = service_key['private_key'].encode('utf-8') claim_set = { "iss": service_key['client_id'], "sub": service_key['user_id'], "aud": service_key['token_uri'], "iat": int(time.time()), "exp": int(time.time() + (60 * 60)), } grant = jwt.encode(claim_set, private_key, algorithm='RS256') ``` -------------------------------- ### Checking Available Projections CLMS API (cURL, Wget, Python) Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md Retrieves the list of supported output projections for a specific dataset. The request requires the UID of the dataset as a parameter to tailor the response. ```curl curl -X GET "https://clms.example.com/api/@available-projections?uid=unique-dataset-uid" ``` ```wget wget -O - "https://clms.example.com/api/@available-projections?uid=unique-dataset-uid" ``` ```python import requests url = "https://clms.example.com/api/@available-projections" params = {"uid": "unique-dataset-uid"} response = requests.get(url, params=params) print(response.json()) ``` -------------------------------- ### Requesting Full Non-EEA Dataset Download (Error) CLMS API (cURL, Wget, Python) Source: https://github.com/eea/clms-api-docs/blob/master/source/download.md Attempting to request a full download for a dataset that is not stored on CLMS infrastructure (e.g., external datasets). This endpoint is not designed for direct full downloads of such data, and the API will return an error. ```curl curl -X POST "https://clms.example.com/api/@download-request" \ -H "Content-Type: application/json" \ -d '{ "uid": "non-eea-dataset-uid", "file_id": "https://clms.example.com/api/non-eea-dataset-uid/file-id", "download_format": "GeoTIFF", "full_dataset": true }' ``` ```wget wget --method=POST --header='Content-Type: application/json' --body-data='{ "uid": "non-eea-dataset-uid", "file_id": "https://clms.example.com/api/non-eea-dataset-uid/file-id", "download_format": "GeoTIFF", "full_dataset": true }' "https://clms.example.com/api/@download-request" -O - ``` ```python import requests url = "https://clms.example.com/api/@download-request" data = { "uid": "non-eea-dataset-uid", "file_id": "https://clms.example.com/api/non-eea-dataset-uid/file-id", "download_format": "GeoTIFF", "full_dataset": True } response = requests.post(url, json=data) print(response.json()) ``` -------------------------------- ### Generate JWT Authorization Grant using Python Source: https://github.com/eea/clms-api-docs/blob/master/source/authentication.md Provides a Python script demonstrating how to load a service key (containing the private key, client ID, user ID, and token URI) from a JSON file and use its components to construct and sign a JWT (JSON Web Token) grant. This grant is required for exchanging it for a short-lived access token at the specified token_uri. Requires the 'PyJWT' library. ```python import json import jwt import time # Load saved key from filesystem service_key = json.load(open('my_saved_key.json', 'rb')) private_key = service_key['private_key'].encode('utf-8') claim_set = { "iss": service_key['client_id'], "sub": service_key['user_id'], "aud": service_key['token_uri'], "iat": int(time.time()), "exp": int(time.time() + (60 * 60)), } grant = jwt.encode(claim_set, private_key, algorithm='RS256') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.