0

I'm using the weather API from https://developer.forecast.io/docs/v2#forecast_call. In the 'Response Headers' section, they say I can use the X-Forecast-API-Calls to get information about my API usage.

I would like to use it to count how many calls have been made to the API dynamically, and start/stop the functionality of the API accordingly in my website.

So far online I haven't been able to find any explanation to the usage of this API, so I tried looking to what 'response headers' are and how to use them.

Unfortunately, I didn't find any examples or explanations clear enough that show where to place headers in Javascript code, or in Jquery or HTML... Just as an example, the site http://code.tutsplus.com/tutorials/http-headers-for-dummies--net-8039 explains what headers are and about the Response side of it, but not how to use something like X-Forecast-API-Calls AS a response header, or where it's included precisely.

Many sites provide wrappers/plugins/libraries that help deal with this, but I'm sure there is a way to do this without all that hassle..

Thanks.

Yafim Simanovsky
  • 531
  • 7
  • 26
  • See: http://stackoverflow.com/a/4236041/831645 use "X-Forecast-API-Calls" instead of "some_header" – beardhatcode Jul 29 '16 at 13:38
  • I am communicating with the API through a KEY in my server, in which file can I insert the code? `$.ajax({ url:'https://api.forecast.io/forecast/APIKEY', data: formData, success: function(data, textStatus, request){ alert(request.getResponseHeader('X-Forecast-API-Calls')); }, error: function (request, textStatus, errorThrown) { alert(request.getResponseHeader('Error Occured')); } });` If I place this code in my server, how can I check the value of 'X-Forecast-API-Calls'? It should be a number value but how can I manipulation it in my HTML? – Yafim Simanovsky Jul 29 '16 at 16:13

0 Answers0