Plugin: Registry

Подключите Registry к вашему проекту для управления модулями, API-ключами и маршрутизацией.

1. Получите API-ключ

Зарегистрируйте проект и подключите модуль Registry через API:

POST https://registry.markbase.ru/api/registry/v1/connect
Content-Type: application/json

{"project_id": "ваш-project-uuid", "module_slug": "registry"}

Ответ содержит api_key и hmac_secret для авторизации запросов.

2. HMAC-подпись запросов

X-Project-Id: ваш-project-uuid
X-Api-Key: mk_xxxxxxxxxxxx
X-Timestamp: 1706000000
X-Signature: hmac_sha256(method + path + timestamp + body_sha256, secret)

3. Основные эндпоинты

МетодПутьОписание
GET/api/registry/v1/modulesСписок всех модулей
POST/api/registry/v1/connectПодключить модуль к проекту
GET/api/registry/v1/connectionsСписок подключений
GET/api/registry/v1/resolve?host=...Резолв домена → shop_id
POST/api/registry/v1/resolveЗарегистрировать домен

4. Пример на Python

import hashlib, hmac, time, requests

API_KEY = "mk_xxxxxxxxxxxx"
HMAC_SECRET = "your_hmac_secret"
BASE = "https://registry.markbase.ru"

ts = str(int(time.time()))
sig = hmac.new(HMAC_SECRET.encode(), f"GET\n/api/registry/v1/modules\n{ts}\n".encode(), hashlib.sha256).hexdigest()

resp = requests.get(f"{BASE}/api/registry/v1/modules", headers={"X-Api-Key": API_KEY, "X-Timestamp": ts, "X-Signature": sig})
print(resp.json())

5. Пример на JavaScript

const crypto = require('crypto');

const apiKey = 'mk_xxxxxxxxxxxx';
const secret = 'your_hmac_secret';
const ts = Math.floor(Date.now() / 1000).toString();
const sig = crypto.createHmac('sha256', secret).update(`GET\n/api/registry/v1/modules\n${ts}\n`).digest('hex');

fetch('https://registry.markbase.ru/api/registry/v1/modules', {
  headers: { 'X-Api-Key': apiKey, 'X-Timestamp': ts, 'X-Signature': sig }
}).then(r => r.json()).then(console.log);