Copy for LLM[View as Markdown](https://docs.planet.com/develop/apis/zarr/examples/) # Zarr Import API Examples The following API requests are written in Python. To execute them, you need to create an OAuth client as is explained [here](https://docs.planet.com/develop/authentication.md#sentinel-hub-authentication). The client is named `oauth` in these examples. The examples are structured in a way to be as separable as possible, however in many cases doing all the steps in each chapter makes sense. ### Creating a Collection To create a collection with the name `My Collection` and S3 bucket `my-bucket` using Zarr data that resides inside `s3://my-bucket/path-to-zarr.zarr/`: * Python SDK ``` collection = { 'name': 'My Collection', 's3Bucket': 'my-bucket', 'path': 'path-to-zarr.zarr/', "crs":"http://www.opengis.net/def/crs/EPSG/0/4326" } response = oauth.post('https://services.sentinel-hub.com/zarr/v1/collections', json=collection) response.raise_for_status() ``` Extracting the collection id and status from the response: * Python SDK ``` collection = response.json()['data'] collection_id = collection['id'] collection_status = collection['status'] # if the ingestion failed, you can access the error as follows: # collection_errors = collection['ingestionErrors'] ``` To update the name of your Zarr collection: * Python SDK ``` # Update name of the collection new_col_name = { name: 'My modified collection name' } response = oauth.put(f'https://services.sentinel-hub.com/zarr/v1/collections/{collection_id}', json=new_col_name) response.raise_for_status() ``` To delete the collection: * Python SDK ``` # Delete the collection response = oauth.delete(f'https://services.sentinel-hub.com/zarr/v1/collections/{collection_id}') response.raise_for_status() ``` ### Listing arrays If the ingestion was successful, you can query all ingested arrays and their properties. Arrays are paginated, that is, if there are more than 100 arrays you will only get the first 100 by default. All pages can be traversed in the same way as with other paged endpoints (see the example under [listing tiles](https://docs.planet.com/develop/apis/byoc/examples.md#listing-tiles) on BYOC). Retrieving the first page is shown in the following snippet: * Python SDK ``` response = oauth.get(f'https://services.sentinel-hub.com/zarr/v1/collections/{collection_id}/arrays') response.raise_for_status() arrays = response.json()['data'] ``` You can also get a single array by adding the array name to the URL path. For example, to get the array named `B1` of the above collection: * Python SDK ``` b1_array_response = oauth.get(f'https://services.sentinel-hub.com/zarr/v1/collections/{collection_id}/arrays/B1') b1_array_response.raise_for_status() b1_array = b1_array_response.json()['data'] ```