hub-api(1) | hub manual | hub-api(1) |
hub-api - Low-level GitHub API request interface.
hub api [-it] [-X METHOD] [-H HEADER] [--cache TTL] ENDPOINT [-F FIELD|--input FILE]
-X, --method METHOD
Use -XGET to force serializing fields into the query string for the GET request instead of JSON body of the POST request.
-F, --field KEY=VALUE
If VALUE starts with "@", the rest of the value is interpreted as a filename to read the value from. Use "@-" to read from standard input.
If VALUE is "true", "false", "null", or looks like a number, an appropriate JSON type is used instead of a string.
It is not possible to serialize VALUE as a nested JSON array or hash. Instead, construct the request payload externally and pass it via --input.
Unless -XGET was used, all fields are sent serialized as JSON within the request body. When ENDPOINT is "graphql", all fields other than "query" are grouped under "variables". See ⟨https://graphql.org/learn/queries/#variables⟩
-f, --raw-field KEY=VALUE
--input FILE
-H, --header KEY:VALUE
-i, --include
-t, --flat
--paginate
Note that multiple JSON documents will be output as a result. If the API rate limit has been reached, the final document that is output will be the HTTP 403 notice, and the process will exit with a non-zero status. One way this can be avoided is by enabling --obey-ratelimit.
--color[=WHEN]
--cache TTL
When using "graphql" as ENDPOINT, caching will apply to responses to POST requests as well. Just make sure to not use --cache for any GraphQL mutations.
--obey-ratelimit
ENDPOINT
To learn about available endpoints, see ⟨https://developer.github.com/v3/⟩. To make GraphQL queries, use "graphql" as ENDPOINT and pass -F query=QUERY.
If the literal strings "{owner}" or "{repo}" appear in ENDPOINT or in the GraphQL "query" field, fill in those placeholders with values read from the git remote configuration of the current git repository.
# fetch information about the currently authenticated user as JSON $ hub api user # list user repositories as line-based output $ hub api --flat users/octocat/repos # post a comment to issue #23 of the current repository $ hub api repos/{owner}/{repo}/issues/23/comments --raw-field ´body=Nice job!´ # perform a GraphQL query read from a file $ hub api graphql -F query=@path/to/myquery.graphql # perform pagination with GraphQL $ hub api --paginate graphql -f query=´
query($endCursor: String) {
repositoryOwner(login: "USER") {
repositories(first: 100, after: $endCursor) {
nodes {
nameWithOwner
}
pageInfo {
hasNextPage
endCursor
}
}
}
} ´
18 Jul 2021 | hub version 2.14.2 |