知道如何连接到这个API吗?

I tried to find any widget to show Tinkoof's bank currency rate, because it changes every 60sec., but nothing. Finally I found this API, but there is no any documentation for it.

I tried to find any articles about parsing, but I guess there's no use in that because of absence of any tag.

I need to show the currency rate on my website via this API. Any idea? Big thanks!

You just need to fetch the content You can use cURL or file_get_contents()

cURL version:

<?php

$url = "https://www.tinkoff.ru/api/v1/currency_rates";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$r = curl_exec($curl);
curl_close($curl);
$array = json_decode($r, true);

echo "<pre>";
print_r($array);
echo "</pre>";

?>

file_get_contents version:

<?php
$r = file_get_contents('https://www.tinkoff.ru/api/v1/currency_rates');

echo "<pre>";
echo print_r(json_decode($r, true));
echo "</pre>";
?>

Both of them will work unless the remote website requires you to be human (has extra verifications to stop robot requests). cURL would be a better way if that were the case because you can fake a user agent using a header array.

Once you have the array build it's just a matter of accessing the required data. using $r as an array result of the remote json structure.

It looks pretty straightforward to me. For someone with a decent knowledge of PHP will do this, provided the output is:

enter image description here

Now with the above information, I would:

  1. Get the result to PHP using file_get_contents().
  2. Parse the result as an array using json_decode($contents, $true).
  3. Using the above result, I would get display the value using: $output["payload"]["rates"][0]["buy"] or something similar.

At this time of writing, the above will get me 58:

enter image description here