Description
Avito n8n Custom Node
> ✨ Update: The project was migrated to the current src/ layout, @n8n/node-cli, and recommended runtime n8n >= 2.19.2.
>
> Compatibility: v2.0.0 may be incompatible with n8n versions earlier than 2.12.0 because OAuth2 credential handling was fundamentally changed. Recommended runtime is n8n >= 2.19.2; starting from this line, the Authorization Code scope issue from #1 is presumed to be fixed. If authentication fails after updating, recreate Avito OAuth2 credentials.
>
> Совместимость: v2.0.0 может быть несовместима с n8n ранее 2.12.0 из-за фундаментального изменения OAuth2 credentials. Рекомендуется n8n >= 2.19.2: начиная с этой ветки, проблема Authorization Code scopes из #1 предположительно исправлена. Если после обновления авторизация не работает, пересоздайте Avito OAuth2 credentials.
—
English
🚀 Overview
Avito n8n Custom Node is a community node for n8n that integrates with Avito API for Business. It provides ready-to-use Avito resources in the n8n UI, including items, promotion, messenger, ratings, autoload, CPA, CallTracking, user finance, tariffs, and special offers.
✨ Key Features
- 🔧 Convenient API Integration: Direct access to Avito API functionality from n8n workflows
- 🔑 OAuth2 Token Management: Avito
403 Forbiddentoken expiry is handled through credential-level refresh - 📊 Broad API Coverage: Items, User, Promotion v1, CPXPromo Legacy, Messenger, CPA, CallTracking, Ratings & Reviews, Autoload, Tariff, and Special Offers
- 🧩 Current n8n Layout: Source code lives in
src/and builds through@n8n/node-cli - 🛡️ Validation & Error Handling: Local validation for documented limits and clearer Avito API errors
🎯 Problem Solved
Avito returns 403 Forbidden when an access token expires. Earlier n8n setups required awkward custom logic to refresh tokens on 403. In current n8n versions this is much simpler: the credential defines hidden tokenExpiredStatusCode: 403, so refresh is handled at credential level.
Authorization Code scopes are entered as comma-separated values:
items:info,stats:read,user:read
Client Credentials usually does not require scope. If a specific Avito API explicitly requires one, for example Special Offers, use the documented scope when the connection flow supports it.
Version 2.0.0 may be incompatible with n8n versions earlier than 2.12.0 because the OAuth2 credential implementation changed significantly. Use n8n >= 2.19.2 where possible; this is the recommended line because the Authorization Code scope handling issue reported in #1 is presumed to be resolved there. Existing Avito OAuth2 credentials may need to be recreated after upgrading.
🗂️ Current Project Structure
The old root-level nodes/ and credentials/ layout was refactored into src/.
src/credentials/avitoOAuth2Api.credentials.ts – OAuth2 credentialsrc/nodes/Avito/Avito.node.ts – main Avito nodesrc/nodes/Avito/AvitoMessengerTrigger.node.ts – Messenger webhook triggersrc/nodes/Avito/Descriptions/* – node UI fieldssrc/nodes/Avito/router/RouterUtils.ts – operation routingsrc/nodes/Avito//* – API operation implementationsThe package configuration points n8n to built files under dist/src/....
📋 Supported Avito API Methods
#### 🏠 Items (Объявления)
POST /stats/v2/accounts/{user_id}/spendings#### 👤 User (Пользователь)
GET /core/v1/accounts/self – authorized user informationGET /core/v1/accounts/{user_id}/balance/ – wallet balancePOST /core/v1/accounts/operations_history/ – wallet operations historydateTimeFrom <= dateTimeTo#### 🎯 Promotion v1 (Продвижение)
POST /promotion/v1/items/services/dict - service type dictionaryPOST /promotion/v1/items/services/get - active services by item IDsPOST /promotion/v1/items/services/orders/get - orders listPOST /promotion/v1/items/services/orders/status - order statusPOST /promotion/v1/items/services/bbip/suggests/get - BBIP budget suggestionsPOST /promotion/v1/items/services/bbip/forecasts/get - BBIP forecastPUT /promotion/v1/items/services/bbip/orders/create - create BBIP order#### 🎯 CPXPromo Legacy
/cpxpromo/1/* operations are available in a separate CPXPromo Legacy resource#### 💬 Messenger
Avito Messenger Trigger for incoming webhook V3 events#### 📤 Autoload (Автозагрузка)
#### 📞 CPA
POST /cpa/v3/balanceInfoactionIdactionIdX-Source header is exposed in the UI#### ☎️ CallTracking
audio/mpeg#### ⭐ Ratings & Reviews (Рейтинги и отзывы)
message#### 💼 Tariff (Тарифы)
GET /tariff/info/1 - current and scheduled Transport tariff info#### 💌 Special Offers (Рассылка скидок и спецпредложений)
Beta API:
POST /special-offers/v1/availablePOST /special-offers/v1/multiCreatePOST /special-offers/v1/multiConfirmPOST /special-offers/v1/statsPOST /special-offers/v1/tariffInfoScope: special_offers:sending.
🛠️ Installation
1. Install the package as an n8n community node or place the built package in your custom nodes directory.
2. Restart n8n.
3. The Avito node and Avito Messenger Trigger will appear in n8n.
⚙️ Configuration
1. Create Avito OAuth2 Credentials:
- Go to n8n Settings → Credentials
- Add Avito OAuth2 API
- Choose Client Credentials or Authorization Code
- Enter clientid and clientsecret from Avito
2. Configure the Node:
- Select resource
- Choose operation
- Fill in required parameters
- The node handles authentication automatically
🧪 Development
npm run build
npm run lint
npm run dev
npm run format
Minimum verification before release:
npx tsc -p tsconfig.json --noEmit
npm run lint
npm run build
n8n-node may print Node.js [DEP0190]; this is not a node code error.
💡 Development Note
This project was built with extensive AI assistance from Claude and Codex (GPT-5.5), plus manual review against Avito API documentation.
⚠️ Disclaimer
📄 License
MIT.
🤝 Contributing
Issues and pull requests are welcome.
---
Русский
🚀 Обзор
Avito n8n Custom Node — community-нода для n8n, которая интегрируется с Avito API for Business. Она добавляет готовые ресурсы Авито прямо в интерфейс n8n: объявления, продвижение, мессенджер, отзывы, автозагрузка, CPA, CallTracking, пользовательские финансы, тарифы и рассылки спецпредложений.
✨ Ключевые особенности
403 Forbidden обрабатывается на уровне credentialsrc/, сборка идет через @n8n/node-cli🎯 Решаемая Проблема
Avito возвращает 403 Forbidden, когда access token истек. Раньше для refresh по 403 приходилось отдельно прописывать неудобную логику. В актуальных версиях n8n это намного проще: credential содержит скрытый tokenExpiredStatusCode: 403, поэтому refresh обрабатывается на уровне credential.
Authorization Code scopes задаются через запятую:
items:info,stats:read,user:read
Для Client Credentials scope обычно не нужен. Если конкретный API Авито явно требует scope, например Special Offers, используйте документированный scope, когда сценарий подключения это поддерживает.
Версия 2.0.0 может быть несовместима с n8n ранее 2.12.0, потому что реализация OAuth2 credential была существенно изменена. По возможности используйте n8n >= 2.19.2: начиная с этой ветки, предположительно закрыта проблема с Authorization Code scopes из #1. После обновления может потребоваться пересоздать Avito OAuth2 credentials.
🗂️ Текущая Структура Проекта
Старая корневая структура nodes/ и credentials/ перенесена в src/.
src/credentials/avitoOAuth2Api.credentials.ts - OAuth2 credentialsrc/nodes/Avito/Avito.node.ts - основная нода Avitosrc/nodes/Avito/AvitoMessengerTrigger.node.ts - Messenger webhook triggersrc/nodes/Avito/Descriptions/* - UI-поля нодыsrc/nodes/Avito/router/RouterUtils.ts - роутинг операцийsrc/nodes/Avito//* - реализации API-методовВ package.json n8n указывает на собранные файлы в dist/src/....
📋 Поддерживаемые Методы API Авито
#### 🏠 Объявления (Items)
POST /stats/v2/accounts/{user_id}/spendings#### 👤 Пользователь (User)
GET /core/v1/accounts/self - информация об авторизованном пользователеGET /core/v1/accounts/{user_id}/balance/ - баланс кошелькаPOST /core/v1/accounts/operations_history/ - история операций кошелькаdateTimeFrom <= dateTimeTo#### 🎯 Продвижение (Promotion v1)
POST /promotion/v1/items/services/dict - словарь типов услугPOST /promotion/v1/items/services/get - активные услуги по объявлениямPOST /promotion/v1/items/services/orders/get - список заявокPOST /promotion/v1/items/services/orders/status - статус заявкиPOST /promotion/v1/items/services/bbip/suggests/get - варианты бюджета BBIPPOST /promotion/v1/items/services/bbip/forecasts/get - прогноз BBIPPUT /promotion/v1/items/services/bbip/orders/create - создание BBIP-заявки#### 🎯 CPXPromo Legacy
/cpxpromo/1/* доступны в отдельном ресурсе CPXPromo Legacy#### 💬 Мессенджер
Avito Messenger Trigger для входящих webhook V3 событий#### 📤 Автозагрузка (Autoload)
#### 📞 CPA
POST /cpa/v3/balanceInfoactionIdactionIdX-Source вынесен в UI#### ☎️ CallTracking
audio/mpeg#### ⭐ Рейтинги И Отзывы (Ratings & Reviews)
message#### 💼 Тарифы (Tariff)
GET /tariff/info/1 - информация о текущем и запланированном тарифе в категории Транспорт#### 💌 Рассылка Скидок И Спецпредложений (Special Offers)
Beta API:
POST /special-offers/v1/availablePOST /special-offers/v1/multiCreatePOST /special-offers/v1/multiConfirmPOST /special-offers/v1/statsPOST /special-offers/v1/tariffInfoScope: special_offers:sending.
🛠️ Установка
1. Установите пакет как n8n community node или поместите собранный пакет в директорию custom nodes.
2. Перезапустите n8n.
3. В n8n появятся Avito и Avito Messenger Trigger.
⚙️ Настройка
1. Создайте Avito OAuth2 Credentials:
- Перейдите в n8n Settings → Credentials
- Добавьте Avito OAuth2 API
- Выберите Client Credentials или Authorization Code
- Укажите clientid и clientsecret из Авито
2. Настройте ноду:
- Выберите ресурс
- Выберите операцию
- Заполните обязательные параметры
- Нода автоматически обрабатывает авторизацию
🧪 Разработка
npm run build
npm run lint
npm run dev
npm run format
Минимальная проверка перед релизом:
npx tsc -p tsconfig.json --noEmit
npm run lint
npm run build
n8n-node может выводить предупреждение Node.js [DEP0190]; это не ошибка кода ноды.
💡 Заметка О Разработке
Проект разрабатывался с активной помощью Claude и Codex (GPT-5.5), а также ручной сверкой с документацией Avito API.
⚠️ Отказ От Ответственности
📄 Лицензия
MIT.
📝 Примечание О Верификации n8n
Нода намеренно использует русский язык в интерфейсе, потому что ориентирована на пользователей Авито. Если n8n добавит полноценную локализацию, интерфейс можно будет адаптировать под многоязычный формат.
🤝 Вклад В Проект
Issues и pull requests приветствуются.
---