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

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

https://zh.porti.ru/xapi/indices/index-history?code=imoex&token=⟨ТОКЕН⟩&format=json
curl --location "https://zh.porti.ru/xapi/indices/index-history?code=imoex&token=⟨ТОКЕН⟩&format=json"
import requests url = f'https://zh.porti.ru/xapi/indices/index-history?code=imoex&token=⟨ТОКЕН⟩&format=json' data = requests.get(url).json() print(data)
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://zh.porti.ru/xapi/indices/index-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://zh.porti.ru/xapi/indices/index-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: "IMOEX", time: "1738011600", price: "2919.1" }, { code: "IMOEX", time: "1737925200", price: "2916.91" }, { code: "IMOEX", time: "1737666000", price: "2947.94" }
Параметры:
  1. token (обязательный) - токен получаемый при оформлении подписки (подписка API)
  2. code (обязательный) - тикер индекса цены которого нужно получить. Допустимые значения: IMOEX, RTS, RGBI, SIP_500, NASDAQ, DOW
  3. format (не обязательный) - допустимые значения: json, csv. json - представление данных в формате json, csv - текстовый формат с разделителем.

Состав индекса

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

https://zh.porti.ru/xapi/indices/index-holders?code=imoex&token=⟨ТОКЕН⟩&format=json
curl --location "https://zh.porti.ru/xapi/indices/index-holders?code=imoex&token=⟨ТОКЕН⟩&format=json"
import requests url = f'https://zh.porti.ru/xapi/indices/index-holders?code=imoex&token=⟨ТОКЕН⟩&format=json' data = requests.get(url).json() print(data)
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'https://zh.porti.ru/xapi/indices/index-holders?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://zh.porti.ru/xapi/indices/index-holders?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:
{ common: { code: "IMOEX", title: "Индекс Мосбиржи" }, holders: [ { title: "Лукойл", code: "MOEX:LKOH", share: "13.65", is_pref: 0 }, { title: "Газпром", code: "MOEX:GAZP", share: "12.83", is_pref: 0 } ] }
Параметры:
  1. token (обязательный) - токен получаемый при оформлении подписки (подписка API)
  2. code (обязательный) - тикер индекса цены которого нужно получить. Допустимые значения: IMOEX, RTS, RGBI, SIP_500, NASDAQ, DOW
  3. format (не обязательный) - допустимые значения: json, csv. json - представление данных в формате json, csv - текстовый формат с разделителем.