1glab(1) glab(1)
2
3
4
6 glab-api - Make an authenticated request to GitLab API
7
8
9
11 glab api [flags]
12
13
14
16 Makes an authenticated HTTP request to the GitLab API and prints the
17 response. The endpoint argument should either be a path of a GitLab
18 API v4 endpoint, or "graphql" to access the GitLab GraphQL API.
19
20
21 • GitLab REST API Docs ⟨https://docs.gitlab.com/ee/api/in‐
22 dex.html⟩
23
24 • GitLab GraphQL Docs ⟨https://docs.gitlab.com/ee/api/graphql/⟩
25
26
27
28 If the current directory is a Git directory, the GitLab authenticated
29 host in the current directory will be used otherwise gitlab.com will be
30 used. Override the GitLab hostname with '--hostname'.
31
32
33 Placeholder values :fullpath or :id, :user or :username, :group, :name‐
34 space, :repo, and :branch in the endpoint argument will get replaced
35 with values from the repository of the current directory.
36
37
38 The default HTTP request method is "GET" normally and "POST" if any pa‐
39 rameters were added. Override the method with '--method'.
40
41
42 Pass one or more '--raw-field' values in "key=value" format to add
43 JSON-encoded string parameters to the POST body.
44
45
46 The '--field' flag behaves like '--raw-field' with magic type conver‐
47 sion based on the format of the value:
48
49
50 • literal values "true", "false", "null", and integer numbers
51 get converted to appropriate JSON types;
52
53 • placeholder values ":namespace", ":repo", and ":branch" get
54 populated with values from the repository of the current di‐
55 rectory;
56
57 • if the value starts with "@", the rest of the value is inter‐
58 preted as a filename to read the value from. Pass "-" to read
59 from standard input.
60
61
62
63 For GraphQL requests, all fields other than "query" and "operationName"
64 are interpreted as GraphQL variables.
65
66
67 Raw request body may be passed from the outside via a file specified by
68 '--input'. Pass "-" to read from standard input. In this mode, parame‐
69 ters specified via
70
71
72 In '--paginate' mode, all pages of results will sequentially be re‐
73 quested until there are no more pages of results. For GraphQL requests,
74 this requires that the original query accepts an '$endCursor: String'
75 variable and that it fetches the
76
77
78
80 -F, --field=[] Add a parameter of inferred type (changes default
81 HTTP method to "POST")
82
83
84 -H, --header=[] Add an additional HTTP request header
85
86
87 --hostname="" The GitLab hostname for the request (default is
88 "gitlab.com" or authenticated host in current git directory)
89
90
91 -i, --include[=false] Include HTTP response headers in the output
92
93
94 --input="" The file to use as body for the HTTP request
95
96
97 -X, --method="GET" The HTTP method for the request
98
99
100 --paginate[=false] Make additional HTTP requests to fetch all
101 pages of results
102
103
104 -f, --raw-field=[] Add a string parameter
105
106
107 --silent[=false] Do not print the response body
108
109
110
112 --help[=false] Show help for command
113
114
115
117 $ glab api projects/:fullpath/releases
118
119 $ glab api projects/gitlab-com%2Fwww-gitlab-com/issues
120
121 $ glab api issues --paginate
122
123 $ glab api graphql -f query='
124 query {
125 project(fullPath: "gitlab-org/gitlab-docs") {
126 name
127 forksCount
128 statistics {
129 wikiSize
130 }
131 issuesEnabled
132 boards {
133 nodes {
134 id
135 name
136 }
137 }
138 }
139 }
140
141 $ glab api graphql --paginate -f query='
142 query($endCursor: String) {
143 project(fullPath: "gitlab-org/graphql-sandbox") {
144 name
145 issues(first: 2, after: $endCursor) {
146 edges {
147 node {
148 title
149 }
150 }
151 pageInfo {
152 endCursor
153 hasNextPage
154 }
155 }
156 }
157 }'
158
159
160
161
162
164 glab(1)
165
166
167
168Auto generated by spf13/cobra Nov 2023 glab(1)