Промокоды
Получение списка промокодов. Создание, изменение или удаление промокодов. Всё покажем с примерами на нашем сайте
get
https://api.lpmotor.ru
/v1/promo
Получение списка промокодов
CURL
PHP CURL
PHP Guzzle
JavaScript
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/promo?site_id=11111"
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->get(
'/v1/promo',
[
'query' => [
'site_id' => $siteId,
]
]
);
$statusCode = $response->getStatusCode();
$promoCodes = json_decode((string) $response->getBody(), true);
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.get("/v1/promo", {
params: {
site_id: 11111,
},
});
post
https://api.lpmotor.ru
/v1/promo
Создание промокода
CURL
PHP CURL
PHP Guzzle
JavaScript
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X POST "https://api.lpmotor.ru/v1/promo" \
-d '{"user_id":123,"site_id":11111,"code":"mypromocode"}'
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->post(
'/v1/promo',
[
'json' => [
'user_id' => $userId,
'site_id' => $siteId,
'code' => 'mypromocode',
],
]
);
$statusCode = $response->getStatusCode();
$promoCode = json_decode((string) $response->getBody(), true);
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.post('/v1/promo', {
user_id: 123,
site_id: 11111,
code: 'mypromocode',
});
get
https://api.lpmotor.ru
/v1/promo/{promo_id}
Получение промокода по ID
CURL
PHP CURL
PHP Guzzle
JavaScript
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/promo/1"
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->get(
'/v1/promo/' . $promoId
);
$statusCode = $response->getStatusCode();
$promoCode = json_decode((string) $response->getBody(), true);
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.get("/v1/promo/" + promoId);
put
https://api.lpmotor.ru
/v1/promo/{promo_id}
Изменение промокода
CURL
PHP CURL
PHP Guzzle
JavaScript
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X PUT "https://api.lpmotor.ru/v1/promo/1" \
-d '{"code":"newpromocode"}'
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->put(
'/v1/promo/1',
[
'json' => [
'code' => 'newpromocode',
],
]
);
$statusCode = $response->getStatusCode();
$promoCode = json_decode((string) $response->getBody(), true);
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.post('/v1/promo/1', {
code: 'newpromocode',
});
delete
https://api.lpmotor.ru
/v1/promo/{promo_id}
Удаление промокода
CURL
PHP CURL
PHP Guzzle
JavaScript
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X DELETE "https://api.lpmotor.ru/v1/promo/1"
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->delete(
'/v1/promo/1'
);
$statusCode = $response->getStatusCode();
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.delete("/v1/promo/1");
get
https://api.lpmotor.ru
/v1/promo/{promo_id}/statistics
Получение статистики использования промокода
CURL
PHP CURL
PHP Guzzle
JavaScript
curl \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-Api-User-Id: <<Your-user-id>>" \
-H "Authorization: Bearer <<Your-API-token>>" \
-X GET "https://api.lpmotor.ru/v1/promo/1/statistics"
<?php
$client = new GuzzleHttp\Client([
'base_uri' => 'https://api.lpmotor.ru',
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Api-User-Id' => $userId,
'Authorization' => 'Bearer ' . $apiKey,
],
]);
$response = $client->get(
'/v1/promo/1/statistics'
);
$statusCode = $response->getStatusCode();
$statistics = json_decode((string) $response->getBody(), true);
http = Axios.create({
baseURL: "https://api.lpmotor.ru",
timeout: 60000,
headers: {
"Content-Type" : "application/json",
"Accept" : "application/json",
"Cache-Control": "no-cache, no-store, must-revalidate",
"X-Api-User-Id": userId,
"Authorization": "Bearer " + myApiKey,
}
});
http.get("/v1/promo/1/statistics");
Last modified 10mo ago