tsd icon indicating copy to clipboard operation
tsd copied to clipboard

Proposal - inform about the Github API rate limit

Open Diullei opened this issue 9 years ago • 11 comments

Always a user execute a tsd command without an Github OAuth token, the tsd should display a warn message like this:

Warning: Your Github API rate limit is (30/60 -> 0:31:54). Go to http://a/shortened/url to see how to increase this rate.

NOTE: A http://a/shortened/url will pointing to a page on tsd wiki explaining the warning and how to increase the rate-limit.

Example:

$> tsd query jquery
================================================================
 Warning:     Your Github API rate limit is (30/60 -> 0:31:54). 
 Go to http://a/shortened/url to see how to increase this rate
================================================================

 - jquery / jquery

Diullei avatar Jun 23 '15 17:06 Diullei

@blakeembrey thoughts?

Diullei avatar Jun 23 '15 17:06 Diullei

This is a great idea, but the message is confusing. JSPM does a nice job with this. Check out https://github.com/jspm/github/commit/f7839615e3ef7f31e7046479c9c264f8ff1fb2a4

nycdotnet avatar Jun 23 '15 18:06 nycdotnet

Cool, JSPM seems to do an excellent job. I will take a look and improve this proposal. :+1:

Diullei avatar Jun 23 '15 18:06 Diullei

@nycdotnet What about this message:

Warning: GitHub credentials not provided so rate limits will apply. Go to http://a/shortened/url to see how to set this up (remaining 36).

Diullei avatar Jun 23 '15 19:06 Diullei

My suggestion:

Warning: GitHub limits unauthenticated API requests (36 remaining). See instructions to authenticate here: http://a/shortened/url .

nycdotnet avatar Jun 24 '15 17:06 nycdotnet

What's the time - when it will reset? If so, perhaps this:

Warning: GitHub limits unauthenticated API requests (36 of 60 remaining / resets at 0:31:54 UTC). See instructions to authenticate here: http://a/shortened/url .

I am assuming the timestamp is UTC - if not, putting "local" is fine to not have to deal with timezone stuff.

nycdotnet avatar Jun 24 '15 17:06 nycdotnet

Thanks! It is much better. I have difficulties to write in English.

English is not my native language :)

This is a time to reset, I think is worth to be shown.

Now one more point:

Show this message always a user execute a command without the api token? or show when we have few requests remaining (without the api token)? < 25 remaining requests, for example.

Diullei avatar Jun 24 '15 17:06 Diullei

Dude you are fine. You certainly don't want to hear my Portuguese!!

It's nice that people can use tsd without doing this extra step if they only need a few files each time. Since the standard workflow is "query" and then "install", and assuming that only 1 API request is consumed per run, perhaps show if there are 7 or more used API requests and the user is unauthenticated?

Also perhaps show anytime someone is reinstalling from their tsd.json if the count of packages is > 3?

Just some ideas. This is a really nice feature for the users.

nycdotnet avatar Jun 24 '15 18:06 nycdotnet

Cool! thanks for the suggestions! :smile: :+1:

Diullei avatar Jun 24 '15 20:06 Diullei

Sorry for the late response, was busy travelling. I think this looks great :smile: We probably don't need to provide a shortened URL though, or if we do, we can just link to a section on our README. Which reminds me we need to make it a heading about authenticating to make it linkable.

blakeembrey avatar Jun 25 '15 19:06 blakeembrey

Thanks @blakeembrey. I'll get some time to implement it and test.

Diullei avatar Jun 26 '15 03:06 Diullei