Исторические данные для фьючерса

Чтобы получить все исторические цены для выбранного фьючерса, нужно использовать входную точку "futures-history":

https://tr.porti.ru/xapi/futures/futures-history?code=imoex&token=⟨ТОКЕН⟩&format=json
curl --location "https://tr.porti.ru/xapi/futures/futures-history?code=imoex&token=⟨ТОКЕН⟩&format=json"
import requests url = f'https://tr.porti.ru/xapi/futures/futures-history?code=imoex&token=⟨ТОКЕН⟩&format=json' data = requests.get(url).json() print(data)
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://tr.porti.ru/xapi/futures/futures-history?code=imoex&token=⟨ТОКЕН⟩&format=json', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', )); $data = curl_exec($curl); curl_close($curl); try { $data = json_decode($data, true, 512, JSON_THROW_ON_ERROR); var_dump($data); } catch (Exception $e) { echo 'Error. '.$e->getMessage(); }
library(httr) library(jsonlite) url <- 'https://tr.porti.ru/xapi/futures/futures-history?code=imoex&token=⟨ТОКЕН⟩&format=json' response <- GET(url) if (http_type(response) == "application/json") { content <- content(response, "text", encoding = "UTF-8") cat(content) } else { cat("Error while receiving data\n") }
Пример полученных данных с использованием этого API:
[ { code: "USDRUBF", time: "1721941200", price: "86.11" }, { code: "USDRUBF", time: "1719781200", price: "87.8" }, { code: "USDRUBF", time: "1719522000", price: "87.29" } ]
Параметры:
  1. token (обязательный) - токен получаемый при оформлении подписки (подписка API)
  2. code (обязательный) - тикер фьючерса, например USDRUBF
  3. format (не обязательный) - допустимые значения: json, csv. json - представление данных в формате json, csv - текстовый формат с разделителем.