Список индексов
Чтобы получить список индексов, нужно использовать входную точку "indices":
https://hi.porti.ru/xapi/indices/indices?token=〈ТОКЕН〉&format=json
curl --location "https://hi.porti.ru/xapi/indices/indices?token=〈ТОКЕН〉&format=json"
import requests
url = f'https://hi.porti.ru/xapi/indices/indices?token=〈ТОКЕН〉&format=json'
data = requests.get(url).json()
print(data)
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://hi.porti.ru/xapi/indices/indices?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://hi.porti.ru/xapi/indices/indices?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:
[
{
title: "Индекс Мосбиржи",
price: "2803.6",
code: "IMOEX",
logo: "https://porti.ru/resource/img/index/logo/1.png"
},
{
title: "Индекс РТС",
price: "1063.16",
code: "RTSI",
logo: "https://porti.ru/resource/img/index/logo/2.png"
}
]
Параметры:
token (обязательный) - токен получаемый при оформлении подписки (подписка API )
format (не обязательный) - допустимые значения: json, csv, excel. json - представление данных в формате json, csv - текстовый формат с разделителем, excel - файл в формате Excel.
Исторические данные для индекса
Чтобы получить все исторические цены для выбранного индекса, нужно использовать входную точку "index-history":
https://hi.porti.ru/xapi/indices/index-history?code=imoex&token=〈ТОКЕН〉&format=json
curl --location "https://hi.porti.ru/xapi/indices/index-history?code=imoex&token=〈ТОКЕН〉&format=json"
import requests
url = f'https://hi.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://hi.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://hi.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"
}
Параметры:
token (обязательный) - токен получаемый при оформлении подписки (подписка API )
code (обязательный) - тикер индекса цены которого нужно получить. Допустимые значения: IMOEX, RTS, RGBI, SIP_500, NASDAQ, DOW
format (не обязательный) - допустимые значения: json, csv, excel. json - представление данных в формате json, csv - текстовый формат с разделителем, excel - файл в формате Excel.
Состав индекса
Чтобы получить состав для выбранного индекса, нужно использовать входную точку "index-holders":
https://hi.porti.ru/xapi/indices/index-holders?code=imoex&token=〈ТОКЕН〉&format=json
curl --location "https://hi.porti.ru/xapi/indices/index-holders?code=imoex&token=〈ТОКЕН〉&format=json"
import requests
url = f'https://hi.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://hi.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://hi.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
}
]
}
Параметры:
token (обязательный) - токен получаемый при оформлении подписки (подписка API )
code (обязательный) - тикер индекса цены которого нужно получить. Допустимые значения: IMOEX, RTS, RGBI, SIP_500, NASDAQ, DOW
format (не обязательный) - допустимые значения: json, csv, excel. json - представление данных в формате json, csv - текстовый формат с разделителем, excel - файл в формате Excel.