GithubHelp home page GithubHelp logo

liggth / cbrf-api-helper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from deniszhitnyakov/cbrf-api-helper

0.0 0.0 0.0 52 KB

The php wrapper component for Central Bank of Russian Federation API

License: Other

PHP 100.00%

cbrf-api-helper's Introduction

PHP обертка над API Центрального банка Российской Федерации.

PHP wrapper for API of Central Bank Of Russian Federation. Docs in English language

Build Status Coverage Status Latest Stable Version Total Downloads

Требования

  • php >=7.0
  • ext-mbstring
  • ext-simplexml
  • ext-libxml

Установка

Установка последней версии используя composer

$ composer require jekk0/cbrf-api-helper

Быстрый старт.

Подключение пакета и создание обьекта для работы с API

<?php
// Create instance
require_once __DIR__ . "/vendor/autoload.php";

$client = new \Jekk0\Cbrf\Client\Client();
// Получение котировок валют

// На текущую дату
$client->getCurrencyApi()->getAll();

// Получение котировок на указанный день
$client->getCurrencyApi()->getAll("05.12.2010");

// Результат запроса
// array (size=34)
//   0 =>
//     array (size=6)
//       'NumCode' => string '036' (length=3)
//       'CharCode' => string 'AUD' (length=3)
//       'Nominal' => string '1' (length=1)
//       'Name' => string 'Австралийский доллар' (length=39)
//       'Value' => string '44,3861' (length=7)
//       'ID' => string 'R01010' (length=6)
// ...

// Получение идентификаторов для валют:
$client->getCurrencyApi()->getIds();

// Результат запроса
// array (size=34)
//   'AUD' => string 'R01010' (length=6)
//   'AZN' => string 'R01020A' (length=7)
//   'GBP' => string 'R01035' (length=6)
//   'AMD' => string 'R01060' (length=6)
//   'BYN' => string 'R01090B' (length=7)
//   'BGN' => string 'R01100' (length=6)
//   'BRL' => string 'R01115' (length=6)
//   ...

// Получение данных по валюте по коду, текстовому коду и идентификатору

$client->getCurrencyApi()->getByNumCode(840);
$client->getCurrencyApi()->getByCharCode('USD');
$client->getCurrencyApi()->getById("R01235");

// Результат запроса
// array (size=6)
//   'NumCode' => string '840' (length=3)
//   'CharCode' => string 'USD' (length=3)
//   'Nominal' => string '1' (length=1)
//   'Name' => string 'Доллар США' (length=19)
//   'Value' => string '58,5182' (length=7)
//   'ID' => string 'R01235' (length=6)

// Получения динамики котировок, в примере для USD

// R01235 - идентификатор валюты
// 01.12.2017 - начальная дата
// 04.12.2017 - конечная дата
$client->getCurrencyApi()->getDynamics('R01235', "01.12.2017", "04.12.2017");

// Результат запроса
// array (size=2)
//   0 =>
//     array (size=4)
//       'Nominal' => string '1' (length=1)
//       'Value' => string '58,5814' (length=7)
//       'Date' => string '01.12.2017' (length=10)
//       'Id' => string 'R01235' (length=6)
//   1 =>
//     array (size=4)
//       'Nominal' => string '1' (length=1)
//       'Value' => string '58,5182' (length=7)
//       'Date' => string '02.12.2017' (length=10)
//       'Id' => string 'R01235' (length=6)
//   ...

// Получения изменения курса валют 
// Выходные дни не учитываются, если выбран выходной(суббота или воскресенье) день то изменение курса будет взято и посчитано для пятницы, так как на выходных курс не изменяется  
// Пример:
// 24.02.2018(суббота)
// Разница в курсах будет автоматически расчитана для пятницы
$client->getCurrencyApi()->getDifference('24.02.2018');

// Результат
// array:34 [
//   "AUD" => "-0.1543"
//   "AZN" => "0.0629"
//   "GBP" => "-0.1684"
//   "AMD" => "0.0174"
//   "BYN" => "0.0104"
//   "BGN" => "-0.0425"
//   ...
// ]

// Получения динамики котировок драгоценных металлов

// 25.11.2017 - начальная дата
// 04.12.2017 - конечная дата
$client->getPreciousMetalApi()->getDynamics("25.11.2017", "04.12.2017");

// Результат запроса
// array (size=8)
//   0 =>
//     array (size=4)
//       'Buy' => string '2414,85' (length=7)
//       'Sell' => string '2414,85' (length=7)
//       'Date' => string '01.12.2017' (length=10)
//       'Code' => string '1' (length=1)
//   1 =>
//     array (size=4)
//       'Buy' => string '31,82' (length=5)
//       'Sell' => string '31,82' (length=5)
//       'Date' => string '01.12.2017' (length=10)
//       'Code' => string '2' (length=1)
//   2 =>
//     array (size=4)
//       'Buy' => string '1772,31' (length=7)
//       'Sell' => string '1772,31' (length=7)
//       'Date' => string '01.12.2017' (length=10)
//       'Code' => string '3' (length=1)
//   3 =>
//     array (size=4)
//       'Buy' => string '1917,34' (length=7)
//       'Sell' => string '1917,34' (length=7)
//       'Date' => string '01.12.2017' (length=10)
//       'Code' => string '4' (length=1)
//   ....

cbrf-api-helper's People

Contributors

jekk0 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.