Skip to main content

ya-wiki-api

Типизированный Python-клиент для Yandex Wiki API. Синхронный и асинхронный. Все 21 эндпоинт покрыты и протестированы на реальном API.

Установка

pip install ya-wiki-api

Быстрый старт

from ya_wiki_api import WikiClient

with WikiClient(token="your-oauth-token", org_id="your-org-id") as client:
    # Страницы
    page = client.pages.create(
        page_type="wysiwyg",
        title="Моя страница",
        slug="path/to/page",
        content="Привет!",
    )
    page = client.pages.get(slug="path/to/page")
    page = client.pages.get_by_id(page.id, fields="attributes,content")
    client.pages.update(page.id, content="Обновлённый текст")
    client.pages.append_content(page.id, content="\nЕщё текст", location="bottom")

    # Динамические таблицы
    grid = client.grids.create(title="Моя таблица", page_id=page.id)
    client.grids.columns.add(grid.id, columns=[
        {"slug": "name", "title": "Имя", "type": "string", "required": False},
        {"slug": "score", "title": "Баллы", "type": "number", "required": False},
    ])
    client.grids.rows.add(grid.id, rows=[
        {"name": "Алиса", "score": 95},
        {"name": "Боб", "score": 87},
    ])
    client.grids.cells.update(grid.id, cells=[
        {"row_id": 1, "column_slug": "score", "value": 100},
    ])

    # Очистка
    client.grids.delete(grid.id)
    client.pages.delete(page.id)

Async

from ya_wiki_api import AsyncWikiClient

async with AsyncWikiClient(token="...", org_id="...") as client:
    page = await client.pages.get(slug="my/page")
    grid = await client.grids.get("grid-uuid")

Аутентификация

OAuth 2.0 (Яндекс 360 для бизнеса):

client = WikiClient(token="oauth-token", org_id="org-id")

IAM-токен (Yandex Cloud):

client = WikiClient(token="iam-token", cloud_org_id="cloud-org-id", is_iam=True)

Получение OAuth-токена:

  1. Создайте приложение на https://oauth.yandex.ru/
  2. Выберите «Для доступа к API или отладки»
  3. Добавьте права: wiki:write (полный доступ) или wiki:read (только чтение)
  4. Получите токен: https://oauth.yandex.ru/authorize?response_type=token&client_id=<ClientID>

Покрытие API

Страницы (client.pages)

Метод Эндпоинт
get(slug) GET /v1/pages?slug=...
get_by_id(id) GET /v1/pages/{id}
create(...) POST /v1/pages
update(id, ...) POST /v1/pages/{id}
delete(id) DELETE /v1/pages/{id}
clone(id, target) POST /v1/pages/{id}/clone
append_content(id, content) POST /v1/pages/{id}/append-content
get_grids(id) GET /v1/pages/{id}/grids
get_resources(id) GET /v1/pages/{id}/resources

Таблицы (client.grids)

Метод Эндпоинт
get(id) GET /v1/grids/{id}
create(...) POST /v1/grids
update(id, ...) POST /v1/grids/{id}
delete(id) DELETE /v1/grids/{id}
clone(id, target) POST /v1/grids/{id}/clone
rows.add(id, rows) POST /v1/grids/{id}/rows
rows.delete(id, row_ids) DELETE /v1/grids/{id}/rows
rows.move(id, row_id) POST /v1/grids/{id}/rows/move
columns.add(id, columns) POST /v1/grids/{id}/columns
columns.delete(id, slugs) DELETE /v1/grids/{id}/columns
columns.move(id, slug) POST /v1/grids/{id}/columns/move
cells.update(id, cells) POST /v1/grids/{id}/cells

Обработка ошибок

from ya_wiki_api import WikiAPIError

try:
    client.pages.get(slug="nonexistent")
except WikiAPIError as e:
    print(e.status_code)  # 404
    print(e.detail)       # {"error_code": "...", "message": "..."}

Лицензия

MIT

Release files for ya-wiki-api 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ya-wiki-api 0.2.0
File Size Uploaded
ya_wiki_api-0.2.0.tar.gz 8.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ya-wiki-api 0.2.0
File Interpreter ABI Platform
ya_wiki_api-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.4 kB

Release files / ya_wiki_api-0.2.0.tar.gz

Download URL ya_wiki_api-0.2.0.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
764c25a73a981393b783d3cd1f4d49f4f937688cca811e89483e47815f71ce93
BLAKE2b-256 checksum
How to use checksums
b88c1fb4a47ef46e4828dca63a209f45665013edec6a5de8a6e9429255ccd13a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Release files / ya_wiki_api-0.2.0-py3-none-any.whl

Download URL ya_wiki_api-0.2.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
90efeef448c2516e129216a3a93b698116d3b1d1b4e3a30a59c05e798bcb1152
BLAKE2b-256 checksum
How to use checksums
2354b49ce96f81983d961b6a777cec4832ae1b45291017b1904b7f966179b400
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.13

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page