Руководство интегратора
API V-DAR позволяет интегрировать функционал подарочных кодов в вашу систему.
https://api.v-dar.ru/api/v1Требуется заголовок X-API-Key для всех запросов.
/codes/generate
Создает новый код, списывая средства с баланса.
{
"amount": 1000.00,
"currency_code": "RUB",
"name": "Подарок",
"expires_in_seconds": 15552000
}
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "ABC123XYZ789DEF456GH",
"amount": 1000.00,
"currency_code": "RUB",
"expires_at": "2025-07-20T12:00:00Z",
"name": "Подарок",
"status": "active",
"created_at": "2025-01-20T12:00:00Z"
}
curl -X POST "https://api.v-dar.ru/api/v1/codes/generate" \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": 1000, "name": "Gift"}'var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_KEY");
var content = new StringContent("{\"amount\":1000,\"name\":\"Gift\"}", Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.v-dar.ru/api/v1/codes/generate", content);$ch = curl_init("https://api.v-dar.ru/api/v1/codes/generate");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: KEY", "Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["amount"=>1000, "name"=>"Gift"]));
$res = curl_exec($ch);import requests
res = requests.post("https://api.v-dar.ru/api/v1/codes/generate",
headers={"X-API-Key": "KEY"},
json={"amount": 1000, "name": "Gift"})const res = await axios.post('https://api.v-dar.ru/api/v1/codes/generate',
{amount: 1000, name: 'Gift'},
{headers: {'X-API-Key': 'KEY'}});/codes/activate
Активирует код и зачисляет средства.
{
"code": "ABC123XYZ...",
"site_id": "UUID (optional)"
}
{
"success": true,
"message": "Код успешно активирован",
"activated_amount": 1000.00,
"currency_code": "RUB",
"operation_id": "550e8400-e29b-41d4-a716-446655440001",
"activated_at": "2025-01-20T12:05:00Z"
}
curl -X POST "https://api.v-dar.ru/api/v1/codes/activate" \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"code": "ABC..."}'var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-API-Key", "YOUR_KEY");
var content = new StringContent("{\"code\":\"ABC...\"}", Encoding.UTF8, "application/json");
var response = await client.PostAsync("https://api.v-dar.ru/api/v1/codes/activate", content);$ch = curl_init("https://api.v-dar.ru/api/v1/codes/activate");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: KEY", "Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(["code"=>"ABC..."]));
$res = curl_exec($ch);requests.post("https://api.v-dar.ru/api/v1/codes/activate",
headers={"X-API-Key": "KEY"},
json={"code": "ABC..."})axios.post('/codes/activate', {code: 'ABC...'}, {headers: {'X-API-Key': 'KEY'}})/codes/{code}
{
"exists": true,
"is_valid": true,
"amount": 1000.00,
"currency_code": "RUB",
"expires_at": "2025-07-20T12:00:00Z",
"status": "active"
}
curl "https://api.v-dar.ru/api/v1/codes/ABC..." -H "X-API-Key: KEY"var response = await client.GetAsync("https://api.v-dar.ru/api/v1/codes/ABC...");$ch = curl_init("https://api.v-dar.ru/api/v1/codes/ABC...");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: KEY"]);
$res = curl_exec($ch);requests.get("https://api.v-dar.ru/api/v1/codes/ABC...", headers={"X-API-Key": "KEY"})axios.get('/codes/ABC...', {headers: {'X-API-Key': 'KEY'}})/codes/
{
"items": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "ABC123XYZ...",
"amount": 1000.00,
"status": "active",
"created_at": "2025-01-20T12:00:00Z"
}
],
"total": 50,
"page": 1,
"size": 20,
"pages": 3
}
curl "https://api.v-dar.ru/api/v1/codes/?page=1&size=20" -H "X-API-Key: KEY"var response = await client.GetAsync("https://api.v-dar.ru/api/v1/codes/?page=1");$ch = curl_init("https://api.v-dar.ru/api/v1/codes/?page=1");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: KEY"]);
$res = curl_exec($ch);requests.get("https://api.v-dar.ru/api/v1/codes/", params={"page": 1}, headers={"X-API-Key": "KEY"})axios.get('/codes/', {params: {page: 1}, headers: {'X-API-Key': 'KEY'}})/merchants/balance/{site_id}
{
"site_id": "123e4567-e89b-12d3-a456-426614174000",
"site_login": "shop1",
"currency_code": "RUB",
"balance": 50000.00,
"frozen_balance": 0.00,
"total_balance": 50000.00
}
curl "https://api.v-dar.ru/api/v1/merchants/balance/UUID" -H "X-API-Key: KEY"var response = await client.GetAsync("https://api.v-dar.ru/api/v1/merchants/balance/UUID");$ch = curl_init("https://api.v-dar.ru/api/v1/merchants/balance/UUID");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: KEY"]);
$res = curl_exec($ch);requests.get("https://api.v-dar.ru/api/v1/merchants/balance/UUID", headers={"X-API-Key": "KEY"})axios.get('/merchants/balance/UUID', {headers: {'X-API-Key': 'KEY'}})/operations/
{
"items": [
{
"id": "550e8400-e29b-41d4-a716-446655440005",
"type": "code_activation",
"amount": 1000.00,
"currency_code": "RUB",
"status": "completed",
"created_at": "2025-01-20T12:00:00Z"
}
],
"total": 100,
"page": 1,
"size": 20
}
curl "https://api.v-dar.ru/api/v1/operations/?page=1" -H "X-API-Key: KEY"var response = await client.GetAsync("https://api.v-dar.ru/api/v1/operations/?page=1");$ch = curl_init("https://api.v-dar.ru/api/v1/operations/?page=1");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: KEY"]);
$res = curl_exec($ch);requests.get("https://api.v-dar.ru/api/v1/operations/", params={"page": 1}, headers={"X-API-Key": "KEY"})axios.get('/operations/', {params: {page: 1}, headers: {'X-API-Key': 'KEY'}})/codes/{code}
{
"success": true,
"message": "Код успешно деактивирован"
}
curl -X DELETE "https://api.v-dar.ru/api/v1/codes/ABC..." -H "X-API-Key: KEY"var response = await client.DeleteAsync("https://api.v-dar.ru/api/v1/codes/ABC...");$ch = curl_init("https://api.v-dar.ru/api/v1/codes/ABC...");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["X-API-Key: KEY"]);
$res = curl_exec($ch);requests.delete("https://api.v-dar.ru/api/v1/codes/ABC...", headers={"X-API-Key": "KEY"})axios.delete('/codes/ABC...', {headers: {'X-API-Key': 'KEY'}})