Skip to content

Instantly share code, notes, and snippets.

@Wingless-Archangel
Created November 18, 2019 08:40
Show Gist options
  • Save Wingless-Archangel/78f26afbaaba07ff503b91888e9f14dd to your computer and use it in GitHub Desktop.
Save Wingless-Archangel/78f26afbaaba07ff503b91888e9f14dd to your computer and use it in GitHub Desktop.
Retreive repository in Gitlab via API
import json
import requests
URL = 'https://gitlab.com/api/v4/projects'
API_KEY = ''
payload = {'private_token' : API_KEY,'simple' : True}
def main():
''' make the connection to local gitlab '''
conn = requests.get(URL,params=payload)
dict_result = json.loads(conn.text)
for ele in dict_result:
repo = ele['path_with_namespace'].split("/")
print("Team name: " + repo[0] + "\t" + "Repo name:" + repo[1])
if __name__ == "__main__":
main()%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment