question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API calls counter

See original GitHub issue

It could be interesting to provide a real-time counter of the amount of GitHub API calls:

  • amount issued for the current query
  • amount left on the current token
  • approximated amount ?

The approximated amount would be displayed at some point before the query begins.

estimate = 1 + total_forks + (total_forks / 100) + (sub_forks_probability * total_forks)

A warning could be issued if that value exceeds the maximum amount of API calls that can be made within an hour with the current token.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
stdedoscommented, Feb 26, 2021

Also also … If you decide to start with conditional requests, keep in mind that you should count your requests post-flight instead of pre-flight:

https://github.com/useful-forks/useful-forks.github.io/blob/64d739f5a976f1f5cc146102a1d4a767b5dfb3f7/docs/src/queries-logic.js#L111-L116

  • 304s don’t count against the limit, and
  • “Maybe” a request will fail to fly. If it never reaches the API, it does not affect your limits 😉

https://docs.github.com/en/rest/guides/getting-started-with-the-rest-api#conditional-requests

1reaction
stdedoscommented, Feb 26, 2021

First things first: I am using a dedicated token, and did again the https://useful-forks.github.io/?repo=dbeaver%2Fdbeaver

image

$  curl -i -u usr   -H "Accept: application/vnd.github.v3+json"   https://api.github.com/rate_limit
Enter host password for user 'usr':
HTTP/2 200
server: GitHub.com
date: Fri, 26 Feb 2021 17:13:28 GMT
content-type: application/json; charset=utf-8
content-length: 827
x-ratelimit-limit: 5000
x-ratelimit-remaining: 3571
x-ratelimit-reset: 1614363065
x-ratelimit-used: 1429
cache-control: no-cache
x-oauth-scopes: public_repo
x-accepted-oauth-scopes:
x-github-media-type: github.v3; format=json
access-control-expose-headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
access-control-allow-origin: *
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'
vary: Accept-Encoding, Accept, X-Requested-With
x-github-request-id: DE23:13A33:1E5F1C:1EEACA:60392C38

{
  "resources": {
    "core": {
      "limit": 5000,
      "used": 1429,
      "remaining": 3571,
      "reset": 1614363065
    },
    "search": {
      "limit": 30,
      "used": 0,
      "remaining": 30,
      "reset": 1614359668
    },
    "graphql": {
      "limit": 5000,
      "used": 19,
      "remaining": 4981,
      "reset": 1614360272
    },
    "integration_manifest": {
      "limit": 5000,
      "used": 0,
      "remaining": 5000,
      "reset": 1614363208
    },
    "source_import": {
      "limit": 100,
      "used": 0,
      "remaining": 100,
      "reset": 1614359668
    },
    "code_scanning_upload": {
      "limit": 500,
      "used": 0,
      "remaining": 500,
      "reset": 1614363208
    }
  },
  "rate": {
    "limit": 5000,
    "used": 1429,
    "remaining": 3571,
    "reset": 1614363065
  }
}

It’s very honorable that you don’t exhaust my limit, but I am worried that maybe not everything is what it seems.

Also, you have an off-by-one error 😀

Read more comments on GitHub >

github_iconTop Results From Across the Web

Effective way to count the API calls in an API service
Key-value datastores (e.g. redis, rocksdb) can be used to count api calls of clients. You can then verify the number of total requests...
Read more >
CountAPI - Free counting API
CountAPI is a free counting service. You can use it to track page hits, and specific events among other things.
Read more >
How to Track Number of API Calls Made by Each Partner or ...
How to track how many API requests each partner or customer is hitting your API with.
Read more >
Counting total API calls for your Analytics service - IBM
Count the API calls for the IBM API Connect Analytics subsystem and return the total categorized by response status.
Read more >
What's an API Call and How Are They Counted? - Intrinio
This blog will tell you what an API and API call are, how API call limits work in Intrinio's data plans, and how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found