1hub-api(1)                        hub manual                        hub-api(1)
2
3
4

NAME

6       hub-api - Low-level GitHub API request interface.
7

SYNOPSIS

9       hub api [-it] [-X METHOD] [-H HEADER] [--cache TTL] ENDPOINT [-F
10       FIELD|--input FILE]
11

OPTIONS

13       -X, --method METHOD
14           The HTTP method to use for the request (default: "GET"). The method
15           is automatically set to "POST" if --field, --raw-field, or --input
16           are used.
17
18           Use -XGET to force serializing fields into the query string for the
19           GET request instead of JSON body of the POST request.
20
21       -F, --field KEY=VALUE
22           Data to serialize with the request. VALUE has some magic handling;
23           use --raw-field for sending arbitrary string values.
24
25           If VALUE starts with "@", the rest of the value is interpreted as a
26           filename to read the value from. Use "@-" to read from standard
27           input.
28
29           If VALUE is "true", "false", "null", or looks like a number, an
30           appropriate JSON type is used instead of a string.
31
32           It is not possible to serialize VALUE as a nested JSON array or
33           hash.  Instead, construct the request payload externally and pass
34           it via --input.
35
36           Unless -XGET was used, all fields are sent serialized as JSON
37           within the request body. When ENDPOINT is "graphql", all fields
38           other than "query" are grouped under "variables". See
39https://graphql.org/learn/queries/#variables⟩
40
41       -f, --raw-field KEY=VALUE
42           Same as --field, except that it allows values starting with "@",
43           literal strings "true", "false", and "null", as well as strings
44           that look like numbers.
45
46       --input FILE
47           The filename to read the raw request body from. Use "-" to read
48           from standard input. Use this when you want to manually construct
49           the request payload.
50
51       -H, --header KEY:VALUE
52           Set an HTTP request header.
53
54       -i, --include
55           Include HTTP response headers in the output.
56
57       -t, --flat
58           Parse response JSON and output the data in a line-based key-value
59           format suitable for use in shell scripts.
60
61       --color[=WHEN]
62           Enable colored output even if stdout is not a terminal. WHEN can be
63           one of "always" (default for --color), "never", or "auto"
64           (default).
65
66       --cache TTL
67           Cache successful responses to GET requests for TTL seconds.
68
69           When using "graphql" as ENDPOINT, caching will apply to responses
70           to POST requests as well. Just make sure to not use --cache for any
71           GraphQL mutations.
72
73       ENDPOINT
74           The GitHub API endpoint to send the HTTP request to (default: "/").
75
76           To learn about available endpoints, see
77https://developer.github.com/v3/⟩.  To make GraphQL queries, use
78           "graphql" as ENDPOINT and pass -F query=QUERY.
79
80           If the literal strings "{owner}" or "{repo}" appear in ENDPOINT or
81           in the GraphQL "query" field, fill in those placeholders with
82           values read from the git remote configuration of the current git
83           repository.
84

EXAMPLES

86           # fetch information about the currently authenticated user as JSON
87           $ hub api user
88
89           # list user repositories as line-based output
90           $ hub api --flat users/octocat/repos
91
92           # post a comment to issue #23 of the current repository
93           $ hub api repos/{owner}/{repo}/issues/23/comments --raw-field "body=Nice job!"
94
95           # perform a GraphQL query read from a file
96           $ hub api graphql -F query=@path/to/myquery.graphql
97

SEE ALSO

99       hub(1)
100
101
102
103
104hub version 2.11.1                29 Mar 2019                       hub-api(1)
Impressum