Skip to content

Instantly share code, notes, and snippets.

@gusugusu1018
Created November 16, 2020 11:24
Show Gist options
  • Save gusugusu1018/5a681da368ef8ea5c5713409fbb09082 to your computer and use it in GitHub Desktop.
Save gusugusu1018/5a681da368ef8ea5c5713409fbb09082 to your computer and use it in GitHub Desktop.
import requests
import json
GROUP_ID='4940528'
ACCESS_TOKEN='*************'
END_POINT_URL='https://gitlab.com/api/v4/'
HEADERS={
'Private-Token': ACCESS_TOKEN
}
projects_table = {}
api = '/groups/'+GROUP_ID+'/projects'
PER_PAGE=100
done = False
page=1
projNum=0
reqCounter=0
while not done:
ADDITIONAL_PARAM='?per_page='+str(PER_PAGE)+'&page='+str(page)
url = END_POINT_URL + api + ADDITIONAL_PARAM
response = requests.get(headers=HEADERS, url=url)
if len(response.json()) < PER_PAGE:
done = True
for p in response.json():
projNum = projNum + 1
print(projNum,'id:',p['id'], 'name:',p['name'])
projects_table[p['id']] = p['name']
page = page + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment