Back to articles
Gitlab Has a Free API — Manage Repos, Pipelines, and Issues Without the UI
How-ToDevOps

Gitlab Has a Free API — Manage Repos, Pipelines, and Issues Without the UI

via Dev.to DevOpsAlex Spinov

GitLab API Is More Powerful Than GitHub API GitLab free tier gives you 2000 API calls per hour, CI/CD pipelines, container registry, and package registry. All accessible via API. Setup import requests TOKEN = " your_personal_access_token " HEADERS = { " PRIVATE-TOKEN " : TOKEN } BASE = " https://gitlab.com/api/v4 " Create token at gitlab.com/-/user_settings/personal_access_tokens. List Your Projects def my_projects ( limit = 10 ): r = requests . get ( f " { BASE } /projects " , headers = HEADERS , params = { " owned " : True , " per_page " : limit , " order_by " : " last_activity_at " }) return [{ " name " : p [ " name " ], " stars " : p [ " star_count " ], " url " : p [ " web_url " ]} for p in r . json ()] for p in my_projects (): print ( f " { p [ name ] : 30 } { p [ stars ] } stars " ) Create a Project def create_project ( name , description , visibility = " public " ): r = requests . post ( f " { BASE } /projects " , headers = HEADERS , json = { " name " : name , " description " :

Continue reading on Dev.to DevOps

Opens in a new tab

Read Full Article
5 views

Related Articles