snip.api.request¶
Make requests to the Snips API.
Functions
|
Parse a response from a request. |
|
Make a request to the given URL with the given method and authentication token. |
|
Fetch an image from the given URL and returns it as a PIL Image object. |
Module Functions
- snip.api.request.parse_response(response: Response, token: Token | None = None) dict | list | Image | None¶
Parse a response from a request.
- Parameters:
response (requests.Response) – The response object to parse.
token (Optional[Token]) – The authentication token used for the request. For better error messages.
- Returns:
The parsed response.
- Return type:
- Raises:
AuthenticationException – If the request was not successful due to an authentication problem.
BadRequestException – If the request was not successful due to a bad request.
HTTPError – If the request was not successful due to a server error or other problem.
- snip.api.request.request(method: str, url: str, token: Token | None = None, **kwargs) dict | list | Image | None¶
Make a request to the given URL with the given method and authentication token.
- Parameters:
- Returns:
The parsed response from the request.
- Return type:
ParseResponse
- Raises:
and see parse_response –