How to scroll all the documents in the Master Data v1, dataentities apis?

How is the right way to scroll up all the documents from dataentities apis, using CL and NL acronym

I’ve already tried to use many configurations for the following endpoint:

curl --location --globoff ‘https://{{vtexAccount}}.vtexcommercestable.com.br/api/dataentities/{{acronym}}/scroll?_fields=all&_schema=clients&_size=1000’
–header ‘Accept: application/vnd.vtex.ds.v10+json’
–header ‘Content-Type: application/json’
–header ‘X-VTEX-API-AppKey: {{key}}
–header ‘X-VTEX-API-AppToken: {{token}}
–header ‘X-VTEX-MD-TOKEN: {{md-token}}’

Yet the result is always the same 3 pages of documents, and it goes until I receive an error about: “Message”: “Maximum simultaneous scrolls rate exceeded (10)”

I tried both, pass the same X-VTEX-MD-TOKEN at each 10 calls and the new ones that the api returns at each iteration, but the result was the same “Maximum simultaneous scrolls rate exceeded (10)”

Are you performing simultaneous or sequential requests? According to the documentation, Only one operation is allowed at a time.

Well, my goal is to scroll all the documents, so that I’m doing the following actions:

1° I’m calling the /scroll without the X-VTEX-MD-TOKEN
So I undestand that the result is the first page of documents
Then
2° My implementation looks for the token in the response headers and prepare the next call passing the token, and it continous until the 10th request, which ends with Maximum simultaneous scrolls rate exceeded (10)
So, I also tried to keep the same token across all requests, and I got the same result

What I’m doing wrong ?
Why this operation is counting as 10 operations simultaneously and not as a single one?
Why over the 10 requests I just see the same pages of results ? Is there something else that I need to send to the api, into the headers or path ?

If you’re not doing > 10 simultaneous requests (multi-threading) my guess is you are hitting rate limit.

I would attempt to scroll a bit slower – perhaps by adding a delay of 6 seconds so that you perform at most 10 requests/min.

Ok, I tried calling apis 10 times in the following intervals of 1, 3, 5 minutes. And I had the same result, passing the same token or rolling the new one but, the same result

Is it impossible to scroll all documents? So can you guide me on how to get all documents created on a specific date? And how

curl --location ‘https://amobeleza.vtexcommercestable.com.br/api/dataentities/CL/scroll?null=null&_fields=_all&_createdIn=2024-08-30’ \

I tried many date formats in _createdIn=2024-08-30’ and the result is always the same…

To scroll all documents, you should pass the X-VTEX-MD-TOKEN header value as the _token query parameter in subsequent requests to retrieve the next page.

Example initial request:
GET /api/dataentities/{data_entity}/scroll?_size={page_size}

Subsequent requests to retrieve additional pages:
GET /api/dataentities/{data_entity}/scroll?_token={X-VTEX-MD-TOKEN}

The REST-Content-Total response header informs the total number of documents that match your query, allowing you to calculate the number of pages available based on the _size parameter.

As for date filters, the format you are trying should work, or you can try a date range like this example: /dataentities/CL/search?_where=createdIn between 2001-01-01 AND 2016-01-01

Master Data API v1 - Scroll documents - API Reference

2 Likes

Thanks for your help Julia, your suggestion was great!

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.