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-токена:
- Создайте приложение на https://oauth.yandex.ru/
- Выберите «Для доступа к API или отладки»
- Добавьте права:
wiki:write(полный доступ) илиwiki:read(только чтение) - Получите токен:
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
Metadata
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ya_wiki_api-0.2.0.tar.gz | 8.5 kB | Without provenance | Details for ya_wiki_api-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ya_wiki_api-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for ya_wiki_api-0.2.0-py3-none-any.whl |
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
|
Security for ya-wiki-api 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.