kwork-api/docs/index.md
root 13ef256b3d feat: публичный доступ к токену и credentials
Добавлены property для доступа к учётным данным:

- client.token — web auth token (публичный, не _token)
- client.cookies — session cookies (копия, не оригинал)
- client.credentials — dict с token и cookies для сохранения

Пример использования:
    # Сохранение
    client = await KworkClient.login('user', 'pass')
    token = client.token  # или client.credentials

    # Восстановление
    client = KworkClient(token=token)

Обновлена документация в docs/index.md с примерами.
2026-03-23 04:44:55 +00:00

2.3 KiB

Kwork API — Python Client

Unofficial Python client for Kwork.ru API.

Installation

pip install kwork-api

Or with UV:

uv add kwork-api

Quick Start

Login with credentials

from kwork_api import KworkClient

# Authenticate
client = await KworkClient.login("username", "password")

# Get catalog
catalog = await client.catalog.get_list(page=1)

# Get projects
projects = await client.projects.get_list(page=1)

# Close when done
await client.close()

Using context manager

async with await KworkClient.login("username", "password") as client:
    catalog = await client.catalog.get_list(page=1)
    # Client automatically closes

Save and restore session

# Save credentials after login
client = await KworkClient.login("username", "password")

# Option 1: Save token only
token = client.token

# Option 2: Save full credentials (token + cookies)
creds = client.credentials
import json
with open("session.json", "w") as f:
    json.dump(creds, f)

# Later, restore session
client = KworkClient(token=token)
# or
client = KworkClient(**creds)

user_info = await client.user.get_info()

API Overview

Catalog API

  • client.catalog.get_list() — Get kworks catalog
  • client.catalog.get_details(kwork_id) — Get kwork details

Projects API

  • client.projects.get_list() — Get freelance projects
  • client.projects.get_payer_orders() — Your orders as customer
  • client.projects.get_worker_orders() — Your orders as performer

User API

  • client.user.get_info() — Get user profile
  • client.user.get_reviews() — Get user reviews
  • client.user.get_favorite_kworks() — Get favorite kworks

Settings & Preferences

  • client.get_wants() — User preferences
  • client.get_kworks_status() — Kworks status
  • client.update_settings() — Update settings
  • client.go_offline() — Set offline status

See API Reference for full documentation.

Error Handling

from kwork_api import KworkError, KworkAuthError, KworkApiError

try:
    await client.catalog.get_list()
except KworkAuthError:
    print("Invalid credentials")
except KworkApiError as e:
    print(f"API error: {e.status_code}")
except KworkError as e:
    print(f"General error: {e.message}")