TSD & Travis CI: “GitHub rate limit reached”

If you are using Travis CI to automate the build of a TypeScript, that’s a problem you probably encountered. As Travis CI can allow you to automatically build in various environment, TSD is hitting hard on the GitHub API, which can cause the “GitHub rate limit reached” message to appear.


The solution is quite simple, you’ll have to create a GitHub token and add it in Travis as an environment variable. This tutorial will also work with any build automation system that support environment variables.

Creating a token

Login to GitHub and create a token on this page: https://github.com/settings/tokens/new

TSD does not require any scope to function properly, so uncheck all the scope checkboxes:

github_token Then, after submitting the form, you will be able to copy your token:


Adding the token in Travis CI

Now, let’s go to the setting page of the failing build:


Add an environment variable named TSD_GITHUB_TOKEN and paste the token you got from GitHub (and don’t forget to click the Add button).

Happy end

Now let’s rebuild, and………. github_tsd_happy_end !

You can now use this token for all your automated builds that involve TSD (or you can also generate more tokens if you have a large number of projects 😉 ).

End note: it would also have been possible to add the token as a parameter of the tsd command, but as that would expose your token to anyone that has access to the repository…


TSD & Travis CI: “GitHub rate limit reached” was last modified: September 1st, 2015 by Tom Guillermin

5 thoughts on TSD & Travis CI: “GitHub rate limit reached”

  1. I think it is important to underline the fact that you are creating “a useless token” because you uncheck all boxes when you created it. It is a security matter.
    Moreover, are you sure that your Travis CI’s environment varibales are not public ?
    If so, no need to hide your token on your screenshots 😉

    • Even if this token does not allow access to any of my GitHub account data, it is still a way to authenticate as me through the GitHub API, which not something I want!
      Any use of this token will be linked to my GitHub account, and I have no idea what some people are up to, that’s why I hid it :p
      Moreover, the goal is to avoid hitting the API usage limit, so if everyone reading this post is using it, it might cause the same problem!
      About Travis CI, you can’t access the settings of a build if you’re not the owner. And even if you are, the token are hidden, so I can’t even steal it myself! 😉

      • Ok, thanks for tips 😉
        My point in my previous comment was to underline the fact that the reader *has to uncheck all boxes* in order to create a “useless” token.
        In fact, I think it will be usefull to add the content of your previous comment in the article !

  2. Also, add “tsd rate” command into your .travis.yml file to display how many “Get” tsd has done, and how many “Get” are left.
    This helped me, first of all to see that was a TSD issue, and now to check if build failed because of that.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.