Sessions Reference
Structures to make several calls to the Kemono API with persistent cookies and pooling connections.
Session
- class pykemo.sessions.session.KemoSession
Kemono HTTP session.
- async close()
A wrapper for closing the async session.
- Return type:
None
- async delete(endpoint, *, base_url=UrlType.API, api_version=APIVersion.V1, data_sv=3, **kwargs)
Overcharges a DELETE request.
- Parameters:
endpoint (
UrlLike) – The endpoint to map to.base_url (Optional[
UrlType]) – The root URL to use.api_version (Optional[
APIVersion]) – The internal version of the API to use for the endpoints, defaults toAPIVersion.V1data_sv (
int, optional) – The server number to format the base URL with, in case it is of typeUrlType.DATA
- Returns:
The HTTP response.
- Return type:
- async get(endpoint, *, params=None, base_url=UrlType.API, api_version=APIVersion.V1, data_sv=3, **kwargs)
Overcharges a GET request.
- Parameters:
endpoint (
UrlLike) – The endpoint to map to.params (Optional[
dict]) – Adictwith the parameters of the request. Usually of typedict[str, int | str | None]base_url (Optional[
UrlType]) – The root URL to use.api_version (Optional[
APIVersion]) – The internal version of the API to use for the endpoints, defaults toAPIVersion.V1data_sv (
int, optional) – The server number to format the base URL with, in case it is of typeUrlType.DATA
- Returns:
The HTTP response.
- Return type:
- async head(endpoint, *, base_url=UrlType.API, api_version=APIVersion.V1, data_sv=3, **kwargs)
Overcharges a HEAD request.
- Parameters:
endpoint (
UrlLike) – The endpoint to map to.base_url (Optional[
UrlType]) – The root URL to use.api_version (Optional[
APIVersion]) – The internal version of the API to use for the endpoints, defaults toAPIVersion.V1data_sv (
int, optional) – The server number to format the base URL with, in case it is of typeUrlType.DATA
- Returns:
The HTTP response.
- Return type:
- async options(endpoint, *, base_url=UrlType.API, api_version=APIVersion.V1, data_sv=3, **kwargs)
Overcharges an OPTIONS request.
- Parameters:
endpoint (
UrlLike) – The endpoint to map to.base_url (Optional[
UrlType]) – The root URL to use.api_version (Optional[
APIVersion]) – The internal version of the API to use for the endpoints, defaults toAPIVersion.V1data_sv (
int, optional) – The server number to format the base URL with, in case it is of typeUrlType.DATA
- Returns:
The HTTP response.
- Return type:
- async patch(endpoint, *, data=None, json=None, base_url=UrlType.API, api_version=APIVersion.V1, data_sv=3, **kwargs)
Overcharges a PATCH request.
Warning
dataandjsoncannot be used both at once.- Parameters:
endpoint (
UrlLike) – The endpoint to map to.data (Optional[
Any]) – Dictionary, list of file-like object to send in the body of the request, defaults toNonejson (Optional[
dict]) – JSON-like to send in the body of the request, defaults toNone.base_url (Optional[
UrlType]) – The root URL to use.api_version (Optional[
APIVersion]) – The internal version of the API to use for the endpoints, defaults toAPIVersion.V1data_sv (
int, optional) – The server number to format the base URL with, in case it is of typeUrlType.DATA
- Returns:
The HTTP response.
- Return type:
- async post(endpoint, *, data=None, json=None, base_url=UrlType.API, api_version=APIVersion.V1, data_sv=3, **kwargs)
Overcharges a POST request.
Warning
dataandjsoncannot be used both at once.- Parameters:
endpoint (
UrlLike) – The endpoint to map to.data (Optional[
Any]) – Dictionary, list of file-like object to send in the body of the request.json (Optional[
dict]) – JSON-like to send in the body of the request.base_url (Optional[
UrlType]) – The root URL to use.api_version (Optional[
APIVersion]) – The internal version of the API to use for the endpoints, defaults toAPIVersion.V1data_sv (
int, optional) – The server number to format the base URL with, in case it is of typeUrlType.DATA
- Returns:
The HTTP response.
- Return type:
- async put(endpoint, *, data=None, json=None, base_url=UrlType.API, api_version=APIVersion.V1, data_sv=3, **kwargs)
Overcharges a PUT request.
Warning
dataandjsoncannot be used both at once.- Parameters:
endpoint (
UrlLike) – The endpoint to map to.data (Optional[
Any]) – Dictionary, list of file-like object to send in the body of the request, defaults toNonejson (Optional[
dict]) – JSON-like to send in the body of the request, defaults toNone.base_url (Optional[
UrlType]) – The root URL to use.api_version (Optional[
APIVersion]) – The internal version of the API to use for the endpoints, defaults toAPIVersion.V1data_sv (
int, optional) – The server number to format the base URL with, in case it is of typeUrlType.DATA
- Returns:
The HTTP response.
- Return type:
- async request(method, endpoint, *, base_url=UrlType.API, api_version=APIVersion.V1, data_sv=3, **kwargs)
Overcharges the request to include the session cookie.
- Parameters:
method (
str) – The HTTP method to use.endpoint (
UrlLike) – The endpoint to map to.base_url (Optional[
UrlType]) – The root URL to use.api_version (Optional[
APIVersion]) – The internal version of the API to use for the endpoints, defaults toAPIVersion.V1data_sv (
int, optional) – The server number to format the base URL with, in case it is of typeUrlType.DATA
- Returns:
The HTTP response.
- Return type:
- set_session_cookie(cookie_auth)
- Parameters:
cookie_auth (
TokenValue) – The new session cookie.- Return type:
None
- classmethod with_token(cookie_auth)
Creates a session instace, with the session cookie set.
- Parameters:
cookie_auth (
TokenValue) – The session cookie that can be found after a successful login. Pykemo cannot find this on its own, the user must provide it.- Returns:
An instance of the session.
- Return type: