DSS 429 Response

Query: "Hi

I'm trying to find an example of a DSS 429 (too many requests) response body & headers in your docs so that we can handle it correctly but I can't seem to find one. Can you provide one please?

Thanks"

Edit/Update with more information:

"

I'm not asking that you provide and example request I can make to see this error, I know that isn't possible.


In your API documentation there should be examples of what headers and body will be received for each kind of error, for example for a 400 error you have an example of the headers and body here https://selectapi.datascope.refinitiv.com/RestApi.Help/Home/KeyMechanisms?ctx=Extractions&opn=Extract&sce=Validation%20Error%20(400%20status%20code)&stp=1&tab=3&uid=Validation

I need a similar example for a 429 error. If you're going to rate limit clients, it's only fair that you provide examples that demonstrate how to handle that situation"

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @gareth.teage

    Thank you for reaching out to us.

    To get 429 (too many requests), you need to send a lot of requests concurrently that exceeds the

    Queued Extraction Request Limit defined in the DataScope Select Best Practices & Fair Usage Policy.

    For example the code could like this:

    import requests
    import concurrent.futures
    import time
    import json


    token = '<token>'


    def get_status(url):


        payload = json.dumps({
      "ExtractionRequest": {
        "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.HistoricalReferenceExtractionRequest",
        "ContentFieldNames": [
          "RIC",
          "ETH Expiry Date"
        ],
        "IdentifierList": {
          "@odata.type": "#DataScope.Select.Api.Extractions.ExtractionRequests.InstrumentIdentifierList",
          "InstrumentIdentifiers": [
            {
              "Identifier": "ESc1",
              "IdentifierType": "Ric"
            }
          ],
          "ValidationOptions": {
            "AllowHistoricalInstruments": True
          },
          "UseUserPreferencesForValidationOptions": False
        },
        "Condition": {
          "ReportDateRangeType": "Range",
          "QueryStartDate": "2000-01-01",
          "QueryEndDate": "2023-01-01"
        }
      }
    })
        headers = {
          'Prefer': 'respond-async',
          'Content-Type': 'application/json',
          'Authorization': 'Token '+token
        }    


        response = requests.request("POST", url, headers=headers, data=payload)


        return response.status_code
        
        


    url = "https://selectapi.datascope.refinitiv.com/RestApi/v1/Extractions/ExtractWithNotes"

    tm1 = time.perf_counter()
    with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor:

        futures = []
        for iter in range(1, 200):
            futures.append(executor.submit(get_status, url=url))

        for future in concurrent.futures.as_completed(futures):
            print(future.result())

    tm2 = time.perf_counter()
    print(f'Total time elapsed: {tm2-tm1:0.2f} seconds')

Answers