An example of retrieving and iterating over public gists on GitHub


In [1]:
import github3

In [3]:
for gist in github3.public_gists(number=50):
    print('Gist {0.id} was created by {0.owner} on {0.created_at} and can be viewed at {0.html_url}'.format(gist))


Gist ac738b75a14615b88477 was created by adilakhter on 2014-08-17 19:20:24+00:00 and can be viewed at https://gist.github.com/ac738b75a14615b88477
Gist 0a9a309a9abcc6b5c4bf was created by openpanzer on 2014-08-17 19:20:10+00:00 and can be viewed at https://gist.github.com/0a9a309a9abcc6b5c4bf
Gist 7683f4f65b38f845db77 was created by rodoard on 2014-08-17 19:19:36+00:00 and can be viewed at https://gist.github.com/7683f4f65b38f845db77
Gist 9e0c32c8a14be8f5d5a6 was created by alexdgarland on 2014-08-17 19:18:18+00:00 and can be viewed at https://gist.github.com/9e0c32c8a14be8f5d5a6
Gist 0e7360f80a7c3e1314b1 was created by netsmertia on 2014-08-17 19:17:25+00:00 and can be viewed at https://gist.github.com/0e7360f80a7c3e1314b1
Gist 9d4801fea0a79a64d65f was created by johnjohnsp1 on 2014-08-17 19:16:57+00:00 and can be viewed at https://gist.github.com/9d4801fea0a79a64d65f
Gist 697b7c19baef76a7e255 was created by francescoagati on 2014-08-17 19:14:52+00:00 and can be viewed at https://gist.github.com/697b7c19baef76a7e255
Gist 2b3654bcc548ea46fd5a was created by jkhosla on 2014-08-17 19:14:37+00:00 and can be viewed at https://gist.github.com/2b3654bcc548ea46fd5a
Gist 52aef973e8cd3814273d was created by netsmertia on 2014-08-17 19:14:35+00:00 and can be viewed at https://gist.github.com/52aef973e8cd3814273d
Gist 0ebb15e96051435a8495 was created by ivycheung1208 on 2014-08-17 19:14:07+00:00 and can be viewed at https://gist.github.com/0ebb15e96051435a8495
Gist 3e5e5344a8f4d7497ccd was created by mitsuhiko on 2014-08-17 19:13:32+00:00 and can be viewed at https://gist.github.com/3e5e5344a8f4d7497ccd
Gist a5619a2de7ab2c207977 was created by asez73 on 2014-08-17 19:13:24+00:00 and can be viewed at https://gist.github.com/a5619a2de7ab2c207977
Gist 2a0ef712770ed207f046 was created by 1992chenlu on 2014-08-17 19:13:15+00:00 and can be viewed at https://gist.github.com/2a0ef712770ed207f046
Gist 81f1ea72ec368b282e12 was created by jdehlin on 2014-08-17 19:13:08+00:00 and can be viewed at https://gist.github.com/81f1ea72ec368b282e12
Gist 6c864bdfced90b81d0a4 was created by rodoard on 2014-08-17 19:12:48+00:00 and can be viewed at https://gist.github.com/6c864bdfced90b81d0a4
Gist b38bcc0d9882507c918d was created by intothev01d on 2014-08-17 19:12:18+00:00 and can be viewed at https://gist.github.com/b38bcc0d9882507c918d
Gist 300f20f2705ccfff121f was created by sfujiwara on 2014-08-17 19:12:03+00:00 and can be viewed at https://gist.github.com/300f20f2705ccfff121f
Gist cf20734ce190c295bce0 was created by rodoard on 2014-08-17 19:10:04+00:00 and can be viewed at https://gist.github.com/cf20734ce190c295bce0
Gist 3ef046deac453abe5281 was created by dior001 on 2014-08-17 19:09:35+00:00 and can be viewed at https://gist.github.com/3ef046deac453abe5281
Gist 30e1572599d409ea60ce was created by wilbyang on 2014-08-17 19:09:15+00:00 and can be viewed at https://gist.github.com/30e1572599d409ea60ce
Gist 67e992f23aeb0c56c8a6 was created by rodoard on 2014-08-17 19:07:53+00:00 and can be viewed at https://gist.github.com/67e992f23aeb0c56c8a6
Gist 3c5aca83fc49137db35d was created by openpanzer on 2014-08-17 19:07:52+00:00 and can be viewed at https://gist.github.com/3c5aca83fc49137db35d
Gist 57099359cefcbbb4c07f was created by Arexxk on 2014-08-17 19:07:42+00:00 and can be viewed at https://gist.github.com/57099359cefcbbb4c07f
Gist b4ca18b8868485ada245 was created by krushd on 2014-08-17 19:07:15+00:00 and can be viewed at https://gist.github.com/b4ca18b8868485ada245
Gist 06b688f9857475215d88 was created by sanjuthomas on 2014-08-17 19:06:49+00:00 and can be viewed at https://gist.github.com/06b688f9857475215d88
Gist aa929546abe78aa2be81 was created by sanjuthomas on 2014-08-17 19:05:39+00:00 and can be viewed at https://gist.github.com/aa929546abe78aa2be81
Gist 593a3e39950d6ccf6d28 was created by CHLibrarian on 2014-08-17 19:05:36+00:00 and can be viewed at https://gist.github.com/593a3e39950d6ccf6d28
Gist 07bb9aa25f2dec34c353 was created by CHLibrarian on 2014-08-17 19:04:57+00:00 and can be viewed at https://gist.github.com/07bb9aa25f2dec34c353
Gist 77445b12dccddf898869 was created by sheolseol on 2014-08-17 19:04:42+00:00 and can be viewed at https://gist.github.com/77445b12dccddf898869
Gist 8fd26b4887231d2b6de7 was created by sackio on 2014-08-17 19:04:30+00:00 and can be viewed at https://gist.github.com/8fd26b4887231d2b6de7
Gist 03e46b12816e092a1f21 was created by CHLibrarian on 2014-08-17 19:04:17+00:00 and can be viewed at https://gist.github.com/03e46b12816e092a1f21
Gist faaa524186cd804fc059 was created by ramntry on 2014-08-17 19:03:47+00:00 and can be viewed at https://gist.github.com/faaa524186cd804fc059
Gist 4f8322e21803a97058fe was created by grondilu on 2014-08-17 19:03:34+00:00 and can be viewed at https://gist.github.com/4f8322e21803a97058fe
Gist 20cf25445e5ac9bf0028 was created by sanjuthomas on 2014-08-17 19:03:10+00:00 and can be viewed at https://gist.github.com/20cf25445e5ac9bf0028
Gist beb09796768d42ce9523 was created by CHLibrarian on 2014-08-17 19:03:08+00:00 and can be viewed at https://gist.github.com/beb09796768d42ce9523
Gist 0ed95c271587870feb5b was created by jakelodwick on 2014-08-17 19:02:38+00:00 and can be viewed at https://gist.github.com/0ed95c271587870feb5b
Gist e22429a340cd28f2f626 was created by sanjuthomas on 2014-08-17 19:02:14+00:00 and can be viewed at https://gist.github.com/e22429a340cd28f2f626
Gist 5a62eddbe67dca0a45e2 was created by jakelodwick on 2014-08-17 19:01:46+00:00 and can be viewed at https://gist.github.com/5a62eddbe67dca0a45e2
Gist 3cbc187e86e302016fd3 was created by synthtech on 2014-08-17 19:01:25+00:00 and can be viewed at https://gist.github.com/3cbc187e86e302016fd3
Gist ef40230b822a2207c95b was created by sackio on 2014-08-17 19:00:04+00:00 and can be viewed at https://gist.github.com/ef40230b822a2207c95b
Gist 77df801086743a8159e7 was created by CHLibrarian on 2014-08-17 18:59:12+00:00 and can be viewed at https://gist.github.com/77df801086743a8159e7
Gist 0de978159530abcbba98 was created by sackio on 2014-08-17 18:59:05+00:00 and can be viewed at https://gist.github.com/0de978159530abcbba98
Gist fbc99df944d2fd369d10 was created by cythux on 2014-08-17 18:58:42+00:00 and can be viewed at https://gist.github.com/fbc99df944d2fd369d10
Gist 9ae1fe82f8c335af5160 was created by santiblanko on 2014-08-17 18:58:37+00:00 and can be viewed at https://gist.github.com/9ae1fe82f8c335af5160
Gist c241cb84f28250a77232 was created by pudquick on 2014-08-17 18:55:26+00:00 and can be viewed at https://gist.github.com/c241cb84f28250a77232
Gist 187815899d6c3b4cb36e was created by sackio on 2014-08-17 18:55:19+00:00 and can be viewed at https://gist.github.com/187815899d6c3b4cb36e
Gist 798fa78c90642eebb3b4 was created by prakhar1989 on 2014-08-17 18:55:08+00:00 and can be viewed at https://gist.github.com/798fa78c90642eebb3b4
Gist 0042d48fbb469ce4bd4c was created by Softsapiens on 2014-08-17 18:54:50+00:00 and can be viewed at https://gist.github.com/0042d48fbb469ce4bd4c
Gist 91fd537b432b96979459 was created by georgkreimer on 2014-08-17 18:54:11+00:00 and can be viewed at https://gist.github.com/91fd537b432b96979459
Gist 3a43e1ee0ae57fd4a3d7 was created by yagudaev on 2014-08-17 18:54:07+00:00 and can be viewed at https://gist.github.com/3a43e1ee0ae57fd4a3d7

If you omit the number argument, github3.py will attempt to iterate over all public gists on GitHub. Unfortunately with a ratelimit of 60 unauthenticated requests per hour you will not be able to list them quickly. To increase your ratelimit you would have to do the following (or something similar).


In [4]:
gh = github3.login('username', 'password')

In [ ]:
for gist in gh.public_gists():
    print('Gist {0.id} was created by {0.owner} on {0.created_at} and can be viewed at {0.html_url}'.format(gist))