.nh .TH "glab" "1" "Mar 2026" "Auto generated by spf13/cobra" "" .SH NAME glab-api - Make an authenticated request to the GitLab API. .SH SYNOPSIS \fBglab api [flags]\fP .SH DESCRIPTION Makes an authenticated HTTP request to the GitLab API, and prints the response. The endpoint argument should either be a path of a GitLab API v4 endpoint, or \fBgraphql\fR to access the GitLab GraphQL API. .IP \(bu 2 GitLab REST API documentation \[la]https://docs.gitlab.com/api/\[ra] .IP \(bu 2 GitLab GraphQL documentation \[la]https://docs.gitlab.com/api/graphql/\[ra] .PP If the current directory is a Git directory, uses the GitLab authenticated host in the current directory. Otherwise, \fBgitlab.com\fR will be used. To override the GitLab hostname, use \fB--hostname\fR\&. .PP These placeholder values, when used in the endpoint argument, are replaced with values from the repository of the current directory: .IP \(bu 2 \fB:branch\fR .IP \(bu 2 \fB:fullpath\fR .IP \(bu 2 \fB:group\fR .IP \(bu 2 \fB:id\fR .IP \(bu 2 \fB:namespace\fR .IP \(bu 2 \fB:repo\fR .IP \(bu 2 \fB:user\fR .IP \(bu 2 \fB:username\fR .PP Methods: the default HTTP request method is \fBGET\fR, if no parameters are added, and \fBPOST\fR otherwise. Override the method with \fB--method\fR\&. .PP Pass one or more \fB--raw-field\fR values in \fBkey=value\fR format to add JSON-encoded string parameters to the \fBPOST\fR body. .PP The \fB--field\fR flag behaves like \fB--raw-field\fR with magic type conversion based on the format of the value: .IP \(bu 2 Literal values \fBtrue\fR, \fBfalse\fR, \fBnull\fR, and integer numbers are converted to appropriate JSON types. .IP \(bu 2 Placeholder values \fB:namespace\fR, \fB:repo\fR, and \fB:branch\fR are populated with values from the repository of the current directory. .IP \(bu 2 If the value starts with \fB@\fR, the rest of the value is interpreted as a filename to read the value from. Pass \fB-\fR to read from standard input. .PP For GraphQL requests, all fields other than \fBquery\fR and \fBoperationName\fR are interpreted as GraphQL variables. .PP Raw request body can be passed from the outside via a file specified by \fB--input\fR\&. Pass \fB-\fR to read from standard input. In this mode, parameters specified with \fB--field\fR flags are serialized into URL query parameters. .PP In \fB--paginate\fR mode, all pages of results are requested sequentially until no more pages of results remain. For GraphQL requests: .IP \(bu 2 The original query must accept an \fB$endCursor: String\fR variable. .IP \(bu 2 The query must fetch the \fBpageInfo{ hasNextPage, endCursor }\fR set of fields from a collection. .PP The \fB--output\fR flag controls the output format: .IP \(bu 2 \fBjson\fR (default): Pretty-printed JSON. Arrays are output as a single JSON array. .IP \(bu 2 \fBndjson\fR: Newline-delimited JSON (also known as JSONL or JSON Lines). Each array element or object is output on a separate line. This format is more memory-efficient for large datasets and works well with tools like \fBjq\fR\&. See https://github.com/ndjson/ndjson-spec and https://jsonlines.org/ for format specifications. .SH OPTIONS \fB-F\fP, \fB--field\fP=[] Add a parameter of inferred type. Changes the default HTTP method to "POST". .PP \fB-H\fP, \fB--header\fP=[] Add an additional HTTP request header. .PP \fB--hostname\fP="" The GitLab hostname for the request. Defaults to 'gitlab.com', or the authenticated host in the current Git directory. .PP \fB-i\fP, \fB--include\fP[=false] Include HTTP response headers in the output. .PP \fB--input\fP="" The file to use as the body for the HTTP request. .PP \fB-X\fP, \fB--method\fP="GET" The HTTP method for the request. .PP \fB--output\fP="json" Format output as: json, ndjson. .PP \fB--paginate\fP[=false] Make additional HTTP requests to fetch all pages of results. .PP \fB-f\fP, \fB--raw-field\fP=[] Add a string parameter. .PP \fB--silent\fP[=false] Do not print the response body. .SH OPTIONS INHERITED FROM PARENT COMMANDS \fB-h\fP, \fB--help\fP[=false] Show help for this command. .SH EXAMPLE .EX $ glab api projects/:fullpath/releases $ glab api projects/gitlab-com%2Fwww-gitlab-com/issues $ glab api issues --paginate $ glab api issues --paginate --output ndjson $ glab api issues --paginate --output ndjson | jq 'select(.state == "opened")' $ glab api graphql -f query="query { currentUser { username } }" $ glab api graphql -f query=' query { project(fullPath: "gitlab-org/gitlab-docs") { name forksCount statistics { wikiSize } issuesEnabled boards { nodes { id name } } } } \&' $ glab api graphql --paginate -f query=' query($endCursor: String) { project(fullPath: "gitlab-org/graphql-sandbox") { name issues(first: 2, after: $endCursor) { edges { node { title } } pageInfo { endCursor hasNextPage } } } }' .EE .SH SEE ALSO \fBglab(1)\fP