Skip to content

Return the RateLimiting headers in metadata #27

Closed

Description

@pcothenet

AFAIK, the response from this SDK does not return the rate limiting info, right?

Would be great to add it in the response (along with pagination):

  [
    [
        'results'
    ], 
        {
        pagination: {
            start: 0,
            limit: 500,
            more_items_in_collection: true,
            next_start: 500
        },
        rate_limit: {
            limit: x,
            remaining: xx,
            reset: xxx,
        }
    }
  ]

Activity

  1. martintajur commented on Jan 5, 2017

    @martintajur
    Contributor

    You will be able to access request headers in the metadata with the 3.x version of the API client. The 3.x release is currently in review and will likely get merged in the next week or so. #36

    However the rate limiting data will be added not to the response additionalData block (as you gave the example) but instead it will be accessible from the callback's third argument, as in:

    pipedrive.SearchResults.getAll(reqParams, function(err, searchResults, additionalData, meta) {
    	console.log(meta.response.headers);
    });
    
  2. martintajur commented on Jan 5, 2017

    @martintajur
    Contributor

    Furthermore I have added a linear backoff strategy to the client itself, which honours the rate limiting headers given by the API server. That means you could rely on this logic and not worry about rate limiting on your own — or, alternatively, you can feel free to review the code in the pull request #36 and improve it as you like, then submit a pull request to us for review.

  3. pcothenet commented on Jan 5, 2017

    @pcothenet
    Author

    Awesome, that should work for me, thanks!

  4. martintajur commented on Jan 10, 2017

    @martintajur
    Contributor

    Closing the issue for now, hoping to get 3.0 out soon.

  5. siirimangus commented on Oct 21, 2026

    @siirimangus
    Contributor

    Hey, it's been long here, but following up that starting from v36.1.0 every API method now has a WithHttpInfo variant (e.g. getDealWithHttpInfo) that resolves with { data, status, headers }, so the HTTP status and response headers, such as rate limit headers, can be read. The existing methods are unchanged and still return only the response body. The new methods can be used like this:

    const { data, status, headers } = await api.getDealWithHttpInfo({ id: 1 });
    console.log(headers['x-ratelimit-remaining']);
    

    Check the CHANGELOG here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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