Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
how fetch a GitHub user's stars
[
{
owner: 'bcoe',
repo: 'top-npm-users',
description: ':star: Generate a list of top npm users by based on monthly downloads.',
language: 'JavaScript',
isFork: false,
stargazers: 27,
watchers: 27
}
// …
]
'use strict'
const got = require('got')
const stars = (user) =>
got(`https://api.github.com/users/${user}/starred`)
.then((res) => JSON.parse(res.body))
.then((starred) => starred.map((s) => ({
owner: s.owner.login
, repo: s.name
, description: s.description
, language: s.language
, isFork: false
, stargazers: s.stargazers_count
, watchers: s.watchers_count
})))
stars('jonschlinkert').then(console.log)
@cryptid11

This comment has been minimized.

Copy link

@cryptid11 cryptid11 commented Oct 25, 2018

https://api.github.com/users/${user}/starred

gives me the list, how do I get the total number of starred repo so I can run request using that api for the list in parallel?

@prxg22

This comment has been minimized.

Copy link

@prxg22 prxg22 commented Aug 27, 2020

https://api.github.com/users/${user}/starred

gives me the list, how do I get the total number of starred repo so I can run request using that api for the list in parallel?

you can use this trick:
https://github.community/t/how-can-i-know-the-number-of-repository-by-user-name/13767/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.