saucelabs / node-saucelabs

A wrapper around Sauce Labs API
Apache License 2.0
93 stars 45 forks source link

SauceLabs module should provide RateLimit headers to downstream libraries #31

Open kennydrobnack opened 8 years ago

kennydrobnack commented 8 years ago

As part of a project, I'm using SauceLabs to test some code. SauceLabs recently announced they are rate limiting the number of API calls to their services.

http://sauceio.com/index.php/2016/02/announcing-new-rest-api-usage-limits/

One thing we wanted to do was to monitor the usage of the API calls and throw a warning if we are coming close to hitting the limits. However the SauceLabs library only provides the parsed JSON, not any of the headers (including the Rate Limit data).

The function that seems to be impacted by this is makeRequest in SauceLabs.js. Is there any easy way to provide the X-Ratelimit header data along with the JSON parsed response?

danjenkins commented 8 years ago

We could add a third argument in the returned callback with the HTTP response which would include the code and headers etc? Then people could use any of that data? That would be easy to implement...

@unindented @OniOni what are your thoughts?

unindented commented 8 years ago

@danjenkins Yup, that solution sounds reasonable.

danjenkins commented 8 years ago

OK, feel free to send in a PR @kennydrobnack or I'll tackle this once I'm back from my honeymoon! :)

PhearZero commented 8 years ago

@danjenkins Congratulations!

kennydrobnack commented 8 years ago

Congrats @danjenkins! I've actually been pulled into another project at work and found that we're a ways off from hitting our rate limit. That may change in the next few months, but it's not urgent right now.

I'll keep myself subscribed to this and let the guys doing the SauceLabs tests know once this fix is available.