API-справка¶
Эта страница собирается из docstring’ов и аннотаций типов.
Публичный интерфейс пакета¶
kwork
¶
KworkAPI
¶
request_multipart(endpoint: str, use_token: bool = False, _headers: dict[str, str] | None = None, _cookies: dict[str, str] | None = None, fields: dict[str, Any] | None = None, files: dict[str, Any] | None = None, *, retry: bool | None = None, timeout: aiohttp.ClientTimeout | float | None = None, max_attempts: int | None = None, **params: Any) -> dict[str, Any]
async
¶
POST multipart/form-data request.
fields - regular form fields.
files - mapping of field name to:
- path-like (str/Path)
- bytes
- file-like object opened in binary mode
- tuple (filename, data_or_fileobj[, content_type])
KworkBot
¶
Bases: KworkClient
message_handler(text: str | None = None, on_start: bool = False, text_contains: str | None = None) -> Callable[[Callable[..., Any]], Callable[..., Any]]
¶
Декоратор для регистрации обработчика сообщений.
text: Ответить на точное совпадение текста сообщения on_start: Ответить только на первое сообщение в диалоге text_contains: Ответить если сообщение содержит это слово
KworkClient
¶
Bases: KworkAPI, OpenAPIMethodsMixin, APKExtraMethodsMixin
web: KworkWebClient
property
¶
Web client for kwork.ru that uses the official mobile /getWebAuthToken flow.
get_dialog_with_user_page(username: str, *, page: int = 1) -> tuple[list[InboxMessage], dict[str, Any]]
async
¶
Получить одну страницу сообщений диалога с пользователем.
Возвращает (messages, paging), где paging обычно содержит ключ 'pages'.
get_projects(categories_ids: list[int | str], price_from: int | None = None, price_to: int | None = None, hiring_from: int | None = None, kworks_filter_from: int | None = None, kworks_filter_to: int | None = None, page: int | None = None, query: str | None = None) -> list[WantWorker]
async
¶
Получить список проектов.
ID рубрик через запятую или 'all' для всех рубрик.
Пустой список — выборка по любимым рубрикам.
price_from: Бюджет от (включительно) price_to: Бюджет до (включительно) hiring_from: Процент найма от kworks_filter_from: Количество предложений от (не включительно) kworks_filter_to: Количество предложений до (включительно) page: Страница выдачи query: Поисковая строка
web_login(*, url_to_redirect: str | None = '/', user_agent: str | None = None) -> WebLoginResult
async
¶
Establish a web session (kwork.ru cookies) using the official mobile app flow.
KworkWebClient
¶
Minimal web client that reuses the authenticated mobile API session.
How the official app works (per decompiled sources): 1) Call mobile API: POST /getWebAuthToken (api.kwork.ru) to get a one-time web login URL. 2) Open that URL in WebView (kwork.ru/login-by-token?...), which sets web cookies.
This class implements the same flow using aiohttp.
create_exchange_offer(*, want_id: int, offer_type: str = 'custom', description: str, kwork_duration: int, kwork_price: int, kwork_name: str, user_agent: str | None = None, extra_headers: dict[str, str] | None = None, raise_on_error: bool = True, referer: str | None = None) -> dict[str, Any]
async
¶
Create an exchange offer for a want/project via the web endpoint.
Mirrors the observed WebView XHR: POST https://kwork.ru/api/offer/createoffer?... (params in query string)
Prerequisite: call login_via_mobile_web_auth_token(...) first to establish web cookies.
login_via_mobile_web_auth_token(*, url_to_redirect: str | None = '/', user_agent: str | None = None, allow_redirects: bool = True, max_redirects: int = 10, timeout: aiohttp.ClientTimeout | float | None = None) -> WebLoginResult
async
¶
Establish a web session (kwork.ru cookies) using the official mobile API flow.
Notes: - url_to_redirect must be a relative URL that starts with "/". - This method does not perform any action on the web site besides "login-by-token".
request(method: str, path_or_url: str, *, params: dict[str, Any] | None = None, data: Any = None, json_data: Any | None = None, headers: dict[str, str] | None = None, allow_redirects: bool = True, timeout: aiohttp.ClientTimeout | float | None = None) -> dict[str, Any]
async
¶
Make a request to kwork.ru using the current aiohttp cookie jar.
Returns a dict with: - status: int - url: final URL - headers: response headers (stringified) - text: response body (decoded) - json: parsed JSON if response looks like JSON, else None
submit_exchange_offer(*, project_id: int, offer_type: str = 'custom', description: str, kwork_duration: int, kwork_price: int, kwork_name: str, user_agent: str | None = None, raise_on_error: bool = True) -> dict[str, Any]
async
¶
High-level helper that replicates the browser flow for /new_offer.
Observed steps (approx): - POST /quick-faq/init - POST /wants/create_offer_draft (multipart, includes csrftoken + draftKey) - POST /projects/check_is_template - POST /api/offer/createoffer (multipart)
Клиент¶
kwork.client.KworkClient
¶
Bases: KworkAPI, OpenAPIMethodsMixin, APKExtraMethodsMixin
web: KworkWebClient
property
¶
Web client for kwork.ru that uses the official mobile /getWebAuthToken flow.
get_dialog_with_user_page(username: str, *, page: int = 1) -> tuple[list[InboxMessage], dict[str, Any]]
async
¶
Получить одну страницу сообщений диалога с пользователем.
Возвращает (messages, paging), где paging обычно содержит ключ 'pages'.
get_projects(categories_ids: list[int | str], price_from: int | None = None, price_to: int | None = None, hiring_from: int | None = None, kworks_filter_from: int | None = None, kworks_filter_to: int | None = None, page: int | None = None, query: str | None = None) -> list[WantWorker]
async
¶
Получить список проектов.
ID рубрик через запятую или 'all' для всех рубрик.
Пустой список — выборка по любимым рубрикам.
price_from: Бюджет от (включительно) price_to: Бюджет до (включительно) hiring_from: Процент найма от kworks_filter_from: Количество предложений от (не включительно) kworks_filter_to: Количество предложений до (включительно) page: Страница выдачи query: Поисковая строка
web_login(*, url_to_redirect: str | None = '/', user_agent: str | None = None) -> WebLoginResult
async
¶
Establish a web session (kwork.ru cookies) using the official mobile app flow.
Web-клиент (kwork.ru)¶
kwork.web_client.KworkWebClient
¶
Minimal web client that reuses the authenticated mobile API session.
How the official app works (per decompiled sources): 1) Call mobile API: POST /getWebAuthToken (api.kwork.ru) to get a one-time web login URL. 2) Open that URL in WebView (kwork.ru/login-by-token?...), which sets web cookies.
This class implements the same flow using aiohttp.
create_exchange_offer(*, want_id: int, offer_type: str = 'custom', description: str, kwork_duration: int, kwork_price: int, kwork_name: str, user_agent: str | None = None, extra_headers: dict[str, str] | None = None, raise_on_error: bool = True, referer: str | None = None) -> dict[str, Any]
async
¶
Create an exchange offer for a want/project via the web endpoint.
Mirrors the observed WebView XHR: POST https://kwork.ru/api/offer/createoffer?... (params in query string)
Prerequisite: call login_via_mobile_web_auth_token(...) first to establish web cookies.
login_via_mobile_web_auth_token(*, url_to_redirect: str | None = '/', user_agent: str | None = None, allow_redirects: bool = True, max_redirects: int = 10, timeout: aiohttp.ClientTimeout | float | None = None) -> WebLoginResult
async
¶
Establish a web session (kwork.ru cookies) using the official mobile API flow.
Notes: - url_to_redirect must be a relative URL that starts with "/". - This method does not perform any action on the web site besides "login-by-token".
request(method: str, path_or_url: str, *, params: dict[str, Any] | None = None, data: Any = None, json_data: Any | None = None, headers: dict[str, str] | None = None, allow_redirects: bool = True, timeout: aiohttp.ClientTimeout | float | None = None) -> dict[str, Any]
async
¶
Make a request to kwork.ru using the current aiohttp cookie jar.
Returns a dict with: - status: int - url: final URL - headers: response headers (stringified) - text: response body (decoded) - json: parsed JSON if response looks like JSON, else None
submit_exchange_offer(*, project_id: int, offer_type: str = 'custom', description: str, kwork_duration: int, kwork_price: int, kwork_name: str, user_agent: str | None = None, raise_on_error: bool = True) -> dict[str, Any]
async
¶
High-level helper that replicates the browser flow for /new_offer.
Observed steps (approx): - POST /quick-faq/init - POST /wants/create_offer_draft (multipart, includes csrftoken + draftKey) - POST /projects/check_is_template - POST /api/offer/createoffer (multipart)
Бот¶
kwork.bot.KworkBot
¶
Bases: KworkClient
message_handler(text: str | None = None, on_start: bool = False, text_contains: str | None = None) -> Callable[[Callable[..., Any]], Callable[..., Any]]
¶
Декоратор для регистрации обработчика сообщений.
text: Ответить на точное совпадение текста сообщения on_start: Ответить только на первое сообщение в диалоге text_contains: Ответить если сообщение содержит это слово