Skip to content

Pagination doesn't work for Copernicus product catalogue #641

@Richienb

Description

@Richienb

First, initializing the client and creating the search over the Copernicus product catalogue:

from pystac_client import Client

catalog = Client.open("https://catalogue.dataspace.copernicus.eu/stac")

search = catalog.search(
    collections = ['SENTINEL-2'],
)

The following code doesn't automatically paginate:

for item in search.items():
    print(item)

However, the following code does automatically paginate:

from pystac import Item

url = search.url_with_parameters()

while True:
    async with session.get(url) as response:
        page = await response.json()

    if 'features' in page:
        # https://github.com/stac-utils/pystac-client/blob/1a1a2d65c736dc95fb0e16b21795a968100b00c6/pystac_client/item_search.py#L692-L694
        for item in page['features']:
            print(Item.from_dict(item, root=catalog, preserve_dict=False))

    # https://github.com/stac-utils/pystac-client/blob/1a1a2d65c736dc95fb0e16b21795a968100b00c6/pystac_client/stac_api_io.py#L310-L312
    if 'links' not in page:
        break

    for link in page['links']:
        if link['rel'] == 'next':
            url = link['href']
            break
    else:
        break

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions