Skip to content

Instantly share code, notes, and snippets.

@bramp
Created June 9, 2016 03:24
Show Gist options
  • Save bramp/c17d7af7e173610164cc36bd0b48ee87 to your computer and use it in GitHub Desktop.
Save bramp/c17d7af7e173610164cc36bd0b48ee87 to your computer and use it in GitHub Desktop.
Prints a list of all owned repositories with pages.
#!/usr/bin/env python
# Prints a list of all owned repositories with pages.
# by Andrew Brampton 2016 https://bramp.net
#
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import requests
headers = {'Authorization': 'token XXXXX'} # Replace XXXX with a token from https://github.com/settings/tokens
params = {'type': 'owner', 'page': 1}
while True:
r = requests.get('https://api.github.com/user/repos', params=params, headers=headers)
repos = r.json()
if not repos:
break
for repo in repos:
if repo['has_pages']:
print "%32s %s/settings" %(repo['name'], repo['html_url'])
params['page'] += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment