github_interface()
A class used to interact with the Github API.
The class can perform authenticated get, patch and post requests to the GitHub API using the requests library.
Source code in github_api_toolkit/__init__.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
__init__(token)
Creates the header attribute containing the Personal Access token to make auth'd API requests.
get(url, params={}, add_prefix=True)
Performs a get request using the passed url.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The url endpoint of the request. |
required |
params
|
dict
|
A Dictionary containing any Query Parameters. |
{}
|
add_prefix
|
bool
|
A Boolean determining whether to add the "https://api.github.com" prefix |
True
|
Returns:
| Type | Description |
|---|---|
Response | Exception
|
The response from the API endpoint. |
Response | Exception
|
If an error occurs, an Exception object is returned to be handled by the importing program. |
Source code in github_api_toolkit/__init__.py
handle_response(response)
Checks the passed response for errors and returns the response or an Exception object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
response
|
Response
|
The response to be checked for errors. |
required |
Returns:
| Type | Description |
|---|---|
Response | Exception
|
The response from the API endpoint. |
Response | Exception
|
If an error occurs, an Exception object is returned to be handled by the importing program. |
Source code in github_api_toolkit/__init__.py
patch(url, params={}, add_prefix=True)
Performs a patch request using the passed url.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The url endpoint of the request. |
required |
params
|
dict
|
A Dictionary containing any Query Parameters. |
{}
|
add_prefix
|
bool
|
A Boolean determining whether to add the "https://api.github.com" prefix |
True
|
Returns:
| Type | Description |
|---|---|
Response | Exception
|
The response from the API endpoint. |
Response | Exception
|
If an error occurs, an Exception object is returned to be handled by the importing program. |
Source code in github_api_toolkit/__init__.py
post(url, params={}, add_prefix=True)
Performs a post request using the passed url.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The url endpoint of the request. |
required |
params
|
dict
|
A Dictionary containing any Query Parameters. |
{}
|
add_prefix
|
bool
|
A Boolean determining whether to add the "https://api.github.com" prefix |
True
|
Returns:
| Type | Description |
|---|---|
Response | Exception
|
The response from the API endpoint. |
Response | Exception
|
If an error occurs, an Exception object is returned to be handled by the importing program. |