The list-user-repositories API (V3) doesn't return all the repositories

I’m trying to use /v3/repos/#list-user-repositories in one of my open source projects, prahladyeri/gh_announce. The problem is that this API doesn’t seem to return all the repos a user has, but only the first 30! And I couldn’t find this behavior documented anywhere.

Here is the offending part of the code:

def do_refresh_tags():
		# GET /repos/:owner/:repo/topics
		url = "" % config['github_username']
		#print("URL: ",url)
		resp = requests.get(url) #headers={'Accept':'application/vnd.github.mercy-preview+json'}
		data = json.loads(resp.text)
		print("%d repos fetched" % len(data))
		#print("data: ",data)
		if not 'topics' in config: config['topics'] = {}
		for repo in data:
			print("refreshing tags for %s..." % repo['full_name'])
			if not dry_run:
				topics = fetch_topics(repo['full_name'])
				print("%d tags fetched" % len(topics))
				config['topics'][repo['full_name']] = topics, config)
	except Exception as ex:
		print("Error occurred: " + str(ex))

The API URL I’m trying to fetch data from is<username>/repos which is exactly as documented here. Why then, the above call returns only 30 repos when I try with my own user as example, when I have 34 repositories in total? Is this a limitation of the API?

1 Like

Hi @prahladyeri,

Thanks for being here! It’s most likely that you are not seeing all your repositories due to pagination. Most calls only return 30 records at a time, this can be increased to 100 via a per_page attribute, but if you have more than 100 you will need to request every page and store the whole list.

Give a read through and see if retrieving subsequent pages works out. I hope this helps!

1 Like