Use GitHub public api to fetch usernames - #581
Conversation
Use GitHubs public api to fetch usernames instead of scraping a whole page for it.
| const pageHTML = await fetch(`${location.origin}/${username}/following`) | ||
| .then(res => res.text()); | ||
| // Use GitHub public api to get username | ||
| const userData = await fetch(`https://api.github.com/users/${username}`) |
There was a problem hiding this comment.
This needs to be dynamic to support GHE.
There was a problem hiding this comment.
But the APIs may not be available on GHE, or we might not know their hostname
There was a problem hiding this comment.
Good call, confirming that api.<GHE-URL> and <GHE-URL>/api don't work here.
|
We intentionally didn't do this as the API is rate limited. |
|
Err! My bad. GitHub has a mere 60 public requests per hour limit. Closing this. |
|
I wouldn't mind getting a token and pasting it the extension's options. OctoLinker and others do it. GHE seems to support it under |
|
@bfred-it That would work. With a personal access token, limit extends to 5000 per hour.
Seems fair to me. |
|
If we use an API I token anyways, I suggest using the new Graph API instead |
|
@bfred-it Why complicate and change something that already works fine? 5000 can easily be used up too if you browse many long discussions. |
|
If we want to go all nuts with that we can just fetch ~10 usernames and only get more when you scroll :) |
We don't necessarily need to change old things, but new features could take advantage of faster speeds. But if GHE ends up being a problem it may not be worth it. Also definitely against having both methods in as described in #581 (comment)
Caching avoids that. 5000/hour is a lot, worst thing that can happen is that you have to wait for the next round. |
|
I would be happy if @bfred-it s webext-option-sync had support for text fields. |
|
It does. It supports any field that has a |
But the speed is not currently an issue. Nobody has complained about it. I just don't see the downsides being worth the slight, but pretty unnoticeable upsides. We'll probably want to use the API in the future for other things, and I don't want to waste our rate limit tokens with this. |
|
@ramlmn off topic. |
@bfred-it Sorry, didn't know where to ask. |
|
Closing and moving discussion to #585. |

Use GitHubs public api to fetch usernames instead of scraping a whole page for it.