Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use GitHub public api to fetch usernames - #581

Closed
ramlmn wants to merge 2 commits into
refined-github:masterfrom
ramlmn:patch-1
Closed

Use GitHub public api to fetch usernames#581
ramlmn wants to merge 2 commits into
refined-github:masterfrom
ramlmn:patch-1

Conversation

@ramlmn

@ramlmn ramlmn commented Jul 6, 2017

Copy link
Copy Markdown

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

Ram Lmn and others added 2 commits July 6, 2017 18:22
Use GitHubs public api to fetch usernames instead of scraping a whole page for it.
Comment thread src/libs/show-names.js
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}`)

@busches busches Jul 6, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be dynamic to support GHE.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the APIs may not be available on GHE, or we might not know their hostname

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, confirming that api.<GHE-URL> and <GHE-URL>/api don't work here.

@sindresorhus

Copy link
Copy Markdown
Member

We intentionally didn't do this as the API is rate limited.

@ramlmn

ramlmn commented Jul 6, 2017

Copy link
Copy Markdown
Author

Err! My bad. GitHub has a mere 60 public requests per hour limit. Closing this.

@ramlmn ramlmn closed this Jul 6, 2017
@fregante

fregante commented Jul 6, 2017

Copy link
Copy Markdown
Member

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 /api: https://developer.github.com/v3/enterprise/

@ramlmn

ramlmn commented Jul 6, 2017

Copy link
Copy Markdown
Author

@bfred-it That would work. With a personal access token, limit extends to 5000 per hour.
The way I think about it is:

  • If a token is available through settings then use it
    • If location points to GitHub use api.github.com endpoint else
    • use the location to get the GHE API endpoint
  • If token is not available then use the scraping method.

Seems fair to me.
@sindresorhus What do you think?

@ramlmn ramlmn reopened this Jul 6, 2017
@jgierer12

Copy link
Copy Markdown
Contributor

If we use an API I token anyways, I suggest using the new Graph API instead

@sindresorhus

Copy link
Copy Markdown
Member

@bfred-it Why complicate and change something that already works fine? 5000 can easily be used up too if you browse many long discussions.

@hkdobrev

hkdobrev commented Jul 6, 2017

Copy link
Copy Markdown
Contributor

If we want to go all nuts with that we can just fetch ~10 usernames and only get more when you scroll :)

@fregante

fregante commented Jul 6, 2017

Copy link
Copy Markdown
Member

Why complicate and change something that already works fine?

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)

5000 can easily be used up too if you browse many long discussions.

Caching avoids that. 5000/hour is a lot, worst thing that can happen is that you have to wait for the next round.

@ramlmn

ramlmn commented Jul 6, 2017

Copy link
Copy Markdown
Author

I would be happy if @bfred-it s webext-option-sync had support for text fields.

@fregante

fregante commented Jul 6, 2017

Copy link
Copy Markdown
Member

It does. It supports any field that has a value property.

@sindresorhus

sindresorhus commented Jul 6, 2017

Copy link
Copy Markdown
Member

but new features could take advantage of faster speeds

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

ramlmn commented Jul 7, 2017

Copy link
Copy Markdown
Author

Is any one having issues with loading real user names on a fresh install of plugin?

image

I see issues with the cached names (which for a fresh install the cached names object is undefined).

@fregante

fregante commented Jul 7, 2017

Copy link
Copy Markdown
Member

@ramlmn off topic.

@ramlmn

ramlmn commented Jul 7, 2017

Copy link
Copy Markdown
Author

off topic

@bfred-it Sorry, didn't know where to ask.

@ramlmn

ramlmn commented Jul 7, 2017

Copy link
Copy Markdown
Author

Closing and moving discussion to #585.

@ramlmn ramlmn closed this Jul 7, 2017
@ramlmn
ramlmn deleted the patch-1 branch July 7, 2017 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants