Получение дампа
⚠️
Размер дампа может превышать 2 ГБ.
Запросите дамп
Вызовите один из методов:
- Retrieve hotel dump (B2B, Affiliate).
- Retrieve hotel custom dump (B2B, Affiliate).
- Retrieve hotel incremental dump (B2B, Affiliate).
- Retrieve hotel reviews’ dump (B2B, Affiliate).
- Retrieve regions’ dump (B2B, Affiliate).
- Retrieve hotel reviews’ incremental dump (B2B, Affiliate).
Извлеките значение поля url из ответа
В поле url лежит ссылка для скачивания дампа.
Полный код
1import fetch from 'node-fetch';
2
3// keyId — ID API-ключа
4// apiKey — access-токен API-ключа
5async function retrieveDump(keyId, apiKey) {
6 let dumpResponse = await fetch('https://api.ostrovok.ru/api/b2b/v3/hotel/info/dump/', {
7 method: 'POST',
8 headers: {
9 'Content-Type': 'application/json',
10 'Authorization': 'Basic ' + Buffer.from(keyId + ':' + apiKey).toString('base64')
11 },
12 body: JSON.stringify({
13 'inventory': 'all',
14 'language': 'en'
15 })
16 });
17 const json = await dumpResponse.json();
18 return json.data.url;
19}
20
21await retrieveDump(keyId, apiKey); 1import base64
2import json
3import requests
4
5# keyId — ID API-ключа
6# apiKey — access-токен API-ключа
7def retrieve_dump(key_id, api_key):
8 encoded_credentials = base64.b64encode(f"{key_id}:{api_key}".encode("ascii")).decode("ascii")
9 r = requests.post(
10 url="https://api.ostrovok.ru/api/b2b/v3/hotel/info/dump/",
11 json={"inventory": "all", "language": "en"},
12 headers={
13 "Content-Type": "application/json",
14 "Authorization": f"Basic {encoded_credentials}"
15 }
16 )
17 return r.json()["data"]["url"]
18
19if __name__ == "__main__":
20 url = retrieve_dump(key_id, api_key)