Metadata-Version: 2.4
Name: index-now-ru
Version: 1.0.0
Summary: Typed Python SDK for the Index-Now.ru URL indexing API
Project-URL: Homepage, https://index-now.ru/
Project-URL: Documentation, https://index-now.ru/api
Project-URL: Source, https://github.com/arseniigruzdev/index-now-ru-python
Project-URL: Issues, https://github.com/arseniigruzdev/index-now-ru-python/issues
Author-email: "Index-Now.ru" <support@index-now.ru>
Maintainer-email: "Index-Now.ru" <support@index-now.ru>
License-Expression: MIT
License-File: LICENSE
Keywords: bing,indexing,indexnow,search-engines,seo,sitemap,yandex
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Natural Language :: Russian
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.10
Provides-Extra: dev
Requires-Dist: build>=1.2.2; extra == 'dev'
Requires-Dist: mypy>=1.11; extra == 'dev'
Requires-Dist: pytest>=8.3; extra == 'dev'
Requires-Dist: ruff>=0.9; extra == 'dev'
Requires-Dist: twine>=6.0; extra == 'dev'
Description-Content-Type: text/markdown

# Index-Now.ru Python SDK

Официальный типизированный Python-клиент для REST API
[Index-Now.ru](https://index-now.ru/?utm_source=pypi&utm_medium=referral&utm_campaign=python_sdk).
SDK отправляет URL, получает статусы и статистику, запускает облачные аудиты и
управляет проверками sitemap. Работает без сторонних runtime-зависимостей.

> Отправка URL ускоряет обнаружение страниц поисковыми системами, но не
> гарантирует включение страницы в индекс или конкретный срок индексации.

## Требования

- Python 3.10–3.14;
- API-токен Index-Now.ru с префиксом `ib_`;
- настроенный сайт в личном кабинете.

## Установка

```bash
python -m pip install index-now-ru
```

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

```python
import os

from index_now_ru import IndexNowClient

client = IndexNowClient(os.environ["INDEX_NOW_RU_API_TOKEN"])

sites = client.list_sites()
site_id = sites[0]["id"]

result = client.submit(
    site_id=site_id,
    urls=[
        "https://example.com/new-page",
        "https://example.com/updated-page",
    ],
)

for item in result["data"]:
    print(item["id"], item["status"])
```

Токен передаётся только в заголовке `Authorization: Bearer …`. Не добавляйте
токены в исходный код, журналы, URL или систему контроля версий.

## Явный выбор каналов

```python
from index_now_ru import IndexNowClient

client = IndexNowClient("ib_...")
client.submit(
    site_id="00000000-0000-0000-0000-000000000000",
    urls=["https://example.com/article"],
    engines=["indexnow_org", "indexnow_bing", "ping", "jina"],
    submission_mode="normal",
)
```

Без параметра `engines` API использует безопасный базовый набор:
`indexnow_org`, `indexnow_bing`, `ping`. Некоторые каналы требуют отдельной
настройки сайта или проекта.

Поддерживаются:

- `indexnow_org`, `indexnow_bing`, `indexnow` (алиас обоих каналов);
- `ping`, `jina`;
- `google`;
- `yandex_webmaster`, `bing_webmaster`;
- `telegram`;
- совместимые алиасы `yandex`.

Режимы отправки: `normal`, `hard`, `tier`, `social`.

## Статус и история

```python
submission = client.get_status("submission-uuid")
history = client.get_history(site_id=site_id, limit=100)
dashboard = client.get_dashboard(site_id)
```

## Проекты, сайты и аккаунт

```python
account = client.get_account()
projects = client.list_projects()
sites = client.list_sites(project_id=projects[0]["id"])
```

## Sitemap

```python
sitemaps = client.list_sitemaps()
queued = client.check_sitemap(sitemaps[0]["id"])
```

Проверки sitemap зависят от тарифа. Сервер может вернуть `403`, если функция
недоступна.

## Облачные аудиты

```python
audit = client.start_crawl_audit(
    site_id,
    max_depth=20,
    exclude_patterns=["/cart", "/checkout"],
    respect_robots=True,
)

status = client.get_crawl_audit(site_id)
page = client.page_audit("https://example.com/article")
```

Сервер применяет тарифные лимиты, дневные квоты и интервал между повторными
запусками.

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

```python
from index_now_ru import (
    AuthenticationError,
    IndexNowClient,
    RateLimitError,
    ValidationError,
)

client = IndexNowClient("ib_...")

try:
    client.submit(site_id, ["https://example.com/page"])
except AuthenticationError:
    print("Проверьте API-токен")
except ValidationError as error:
    print(error.status_code, error.body)
except RateLimitError as error:
    print("Повторить через:", error.retry_after)
```

Иерархия исключений:

- `IndexNowError` — базовая ошибка SDK;
- `TransportError` — DNS, TLS, timeout или иная сетевая ошибка;
- `InvalidResponseError` — сервер вернул невалидный JSON/формат;
- `ValidationError` — HTTP 400;
- `AuthenticationError` — HTTP 401;
- `PermissionDeniedError` — HTTP 403;
- `NotFoundError` — HTTP 404;
- `ConflictError` — HTTP 409;
- `RateLimitError` — HTTP 429;
- `ServerError` — HTTP 5xx;
- `UnexpectedStatusError` — другой неожиданный HTTP-статус, включая редирект.

SDK намеренно не следует HTTP-редиректам, чтобы Bearer-токен не мог попасть на
другой origin.

## Таймаут и тестовый сервер

```python
client = IndexNowClient(
    "ib_...",
    timeout=20.0,
    base_url="https://index-now.ru/api/v1",
)
```

Меняйте `base_url` только для собственного совместимого тестового сервера.
Обычный production-клиент должен использовать адрес по умолчанию.

## Разработка и проверка

```bash
python -m venv .venv
.\.venv\Scripts\python -m pip install --upgrade pip
.\.venv\Scripts\python -m pip install -e ".[dev]"
.\.venv\Scripts\python -m ruff check .
.\.venv\Scripts\python -m mypy
.\.venv\Scripts\python -m pytest
.\.venv\Scripts\python -m build
.\.venv\Scripts\python -m twine check dist/*
```

## Ссылки

- [Index-Now.ru](https://index-now.ru/?utm_source=pypi&utm_medium=referral&utm_campaign=python_sdk)
- [Документация API](https://index-now.ru/api?utm_source=pypi&utm_medium=referral&utm_campaign=python_sdk)
- [Тарифы](https://index-now.ru/pricing?utm_source=pypi&utm_medium=referral&utm_campaign=python_sdk)
- [Политика конфиденциальности](https://index-now.ru/privacy)
- [Пользовательское соглашение](https://index-now.ru/terms)
- Поддержка: support@index-now.ru

## License

MIT © Index-Now.ru.

