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, **kwargs)
Overcharges a DELETE request.
- Parameters:
endpoint (
UrlLike) – The endpoint to map to.base_url (Optional[
UrlType]) – The root URL to use.
- Returns:
The HTTP response.
- Return type:
- async get(endpoint, params=None, base_url=UrlType.API, **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.
- Returns:
The HTTP response.
- Return type:
- async post(endpoint, data=None, json=None, base_url=UrlType.API, **kwargs)
Overcharges a POST request.
- 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.
- Returns:
The HTTP response.
- Return type:
- async request(method, endpoint, base_url=UrlType.API, **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.
- 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: