API-ФНС

Примеры обращений к API-ФНС

PHP:

$api_url = 'https://api-fns.ru/api/';
$api_method = 'egr';
$params = [
    'req' => '6663003127',
    'key' => '67ac454f6a3fa85355aee5e41b6d154efc589aab'
];
$url = $api_url . $api_method . '?' . http_build_query($params);
$result = file_get_contents($url);

// Вывод ответа API
echo($result);
    
Python:

import requests

api_url = 'https://api-fns.ru/api/'
api_method = 'egr'
params = {'req': '6663003127', 'key': '67ac454f6a3fa85355aee5e41b6d154efc589aab'}
resp = requests.get(api_url + api_method, params=params)

# Вывод ответа API
print(resp.text) # вывод строки
print(resp.json()) # вывод словаря
    
VBA:

Sub apiCall()
    Dim objRequest As Object
    Dim apiUrl As String
    Dim apiMethod As String
    Dim url As String
    Dim req As String
    Dim key As String
    Dim response As String

    Set objRequest = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    apiUrl = "https://api-fns.ru/api/"
    apiMethod = "egr"
    req = "6663003127"
    key = "67ac454f6a3fa85355aee5e41b6d154efc589aab"
    url = apiUrl & apiMethod & "?req=" & req & "&key=" & key

    With objRequest
        .Open "GET", url
        .SetRequestHeader "Content-Type", "application/json"
        .Send

        response = .ResponseText
    End With

    'Вывод ответа API
    Debug.Print response
End Sub
    
Пример использования API-ФНС: демонстрационный файл Excel
C++ / libcurl:

#include <curl/curl.h>
#include <string>
#include <iostream>

size_t writeFunction(void *ptr, size_t size, size_t nmemb, std::string* data) {
    data->append((char*)ptr, size * nmemb);
    return size * nmemb;
}

int main(){
    CURL *curl;
    CURLcode res;
    std::string api_url("https://api-fns.ru/api/");
    std::string api_method("egr");
    std::string key("67ac454f6a3fa85355aee5e41b6d154efc589aab");
    std::string url;
    std::string req;

    curl_global_init(CURL_GLOBAL_DEFAULT);

    curl = curl_easy_init();
    if (curl) {
        req = "6663003127";
        url = api_url + api_method + "?req=" + req + "&key=" + key;

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);

        std::string response;
        std::string headers;
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeFunction);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
        curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headers);

        res = curl_easy_perform(curl);

        // check for errors
        if (res == CURLE_OK) {
            std::cout << response << std::endl;
        } else {
            std::cout << "Failed: " << curl_easy_strerror(res) << std::endl;
        }

        curl_easy_cleanup(curl);
    }

    curl_global_cleanup();

    return 0;
}
    
C++ / Qt

#include <QtCore/QCoreApplication>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QDebug>

class Api : public QObject
{
    Q_OBJECT
public:
    QNetworkAccessManager* m_manager;
    QString m_response;
    Api(QObject *parent = 0) : QObject(parent) { m_manager = new QNetworkAccessManager(); }
    void get_contents(const QString &url) {
        QNetworkRequest request;
        QObject::connect(m_manager, &QNetworkAccessManager::finished, this, [=](QNetworkReply *reply) {
            m_response = !reply->error() ? reply->readAll() : reply->errorString();

            // print API response
            qInfo() << m_response;
        });

        request.setUrl(QUrl(url));
        m_manager->get(request);
    }
};

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QString api_url("https://api-fns.ru/api/");
    QString api_method("egr");
    QString key("67ac454f6a3fa85355aee5e41b6d154efc589aab");
    QString url;
    QString req;

    req = "6663003127";
    url = api_url + api_method + "?req=" + req + "&key=" + key;

    Api* api = new Api(&a);
    api->get_contents(url); // response will be stored to api->m_response

    return a.exec();
}
    
API-Росстат

Примеры обращений к API-Росстат

PHP:

$api_url = 'https://damia.ru/api-rs/';
$api_method = 'balance';
$params = [
    'inn' => '6663003127',
    'key' => '67ac454f6a3fa85355aee5e41b6d154efc589aab'
];
$url = $api_url . $api_method . '?' . http_build_query($params);
$result = file_get_contents($url);

// Вывод ответа API
echo($result);
    
Python:

import requests

api_url = 'https://damia.ru/api-rs/'
api_method = 'balance'
params = {'inn': '6663003127', 'key': '67ac454f6a3fa85355aee5e41b6d154efc589aab'}
resp = requests.get(api_url + api_method, params=params)

# Вывод ответа API
print(resp.text) # вывод строки
print(resp.json()) # вывод словаря
    
VBA:

Sub apiCall()
    Dim objRequest As Object
    Dim apiUrl As String
    Dim apiMethod As String
    Dim url As String
    Dim inn As String
    Dim key As String
    Dim response As String

    Set objRequest = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    apiUrl = "https://damia.ru/api-rs/"
    apiMethod = "balance"
    inn = "6663003127"
    key = "67ac454f6a3fa85355aee5e41b6d154efc589aab"
    url = apiUrl & apiMethod & "?inn=" & inn & "&key=" & key

    With objRequest
        .Open "GET", url
        .SetRequestHeader "Content-Type", "application/json"
        .Send

        response = .ResponseText
    End With

    'Вывод ответа API
    Debug.Print response
End Sub
    
Пример использования API-Росстат: демонстрационный файл Excel
C++ / libcurl:

#include <curl/curl.h>
#include <string>
#include <iostream>

size_t writeFunction(void *ptr, size_t size, size_t nmemb, std::string* data) {
    data->append((char*)ptr, size * nmemb);
    return size * nmemb;
}

int main(){
    CURL *curl;
    CURLcode res;
    std::string api_url("https://damia.ru/api-rs/");
    std::string api_method("balance");
    std::string key("67ac454f6a3fa85355aee5e41b6d154efc589aab");
    std::string url;
    std::string inn;

    curl_global_init(CURL_GLOBAL_DEFAULT);

    curl = curl_easy_init();
    if (curl) {
        inn = "6663003127";
        url = api_url + api_method + "?inn=" + inn + "&key=" + key;

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);

        std::string response;
        std::string headers;
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeFunction);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
        curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headers);

        res = curl_easy_perform(curl);

        // check for errors
        if (res == CURLE_OK) {
            std::cout << response << std::endl;
        } else {
            std::cout << "Failed: " << curl_easy_strerror(res) << std::endl;
        }

        curl_easy_cleanup(curl);
    }

    curl_global_cleanup();

    return 0;
}
    
C++ / Qt

#include <QtCore/QCoreApplication>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QDebug>

class Api : public QObject
{
    Q_OBJECT
public:
    QNetworkAccessManager* m_manager;
    QString m_response;
    Api(QObject *parent = 0) : QObject(parent) { m_manager = new QNetworkAccessManager(); }
    void get_contents(const QString &url) {
        QNetworkRequest request;
        QObject::connect(m_manager, &QNetworkAccessManager::finished, this, [=](QNetworkReply *reply) {
            m_response = !reply->error() ? reply->readAll() : reply->errorString();

            // print API response
            qInfo() << m_response;
        });

        request.setUrl(QUrl(url));
        m_manager->get(request);
    }
};

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QString api_url("https://damia.ru/api-rs/");
    QString api_method("balance");
    QString key("67ac454f6a3fa85355aee5e41b6d154efc589aab");
    QString url;
    QString inn;

    inn = "6663003127";
    url = api_url + api_method + "?inn=" + inn + "&key=" + key;

    Api* api = new Api(&a);
    api->get_contents(url); // response will be stored to api->m_response

    return a.exec();
}
    
API-Скоринг

Примеры обращений к API-Скоринг

PHP:

$api_url = 'https://damia.ru/api-scoring/';
$api_method = 'score';
$params = [
    'model' => '_bankrots2016',
    'inn' => '6663003127',
    'key' => '67ac454f6a3fa85355aee5e41b6d154efc589aab'
];
$url = $api_url . $api_method . '?' . http_build_query($params);
$result = file_get_contents($url);

// Вывод ответа API
echo($result);
    
Python:

import requests

api_url = 'https://damia.ru/api-scoring/'
api_method = 'score'
params = {'model': '_bankrots2016', 'inn': '6663003127', 'key': '67ac454f6a3fa85355aee5e41b6d154efc589aab'}
resp = requests.get(api_url + api_method, params=params)

# Вывод ответа API
print(resp.text) # вывод строки
print(resp.json()) # вывод словаря
    
VBA:

Sub apiCall()
    Dim objRequest As Object
    Dim apiUrl As String
    Dim apiMethod As String
    Dim url As String
    Dim model As String
    Dim inn As String
    Dim key As String
    Dim response As String

    Set objRequest = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    apiUrl = "https://damia.ru/api-scoring/"
    apiMethod = "score"
    model = "_bankrots2016"
    inn = "6663003127"
    key = "67ac454f6a3fa85355aee5e41b6d154efc589aab"
    url = apiUrl & apiMethod & "?model=" & model & "&inn=" & inn & "&key=" & key

    With objRequest
        .Open "GET", url
        .SetRequestHeader "Content-Type", "application/json"
        .Send

        response = .ResponseText
    End With

    'Вывод ответа API
    Debug.Print response
End Sub
    
Пример использования API-Скоринг: демонстрационный файл Excel
C++ / libcurl:

#include <curl/curl.h>
#include <string>
#include <iostream>

size_t writeFunction(void *ptr, size_t size, size_t nmemb, std::string* data) {
    data->append((char*)ptr, size * nmemb);
    return size * nmemb;
}

int main(){
    CURL *curl;
    CURLcode res;
    std::string api_url("https://damia.ru/api-scoring/");
    std::string api_method("score");
    std::string key("67ac454f6a3fa85355aee5e41b6d154efc589aab");
    std::string url;
    std::string model;
    std::string inn;

    curl_global_init(CURL_GLOBAL_DEFAULT);

    curl = curl_easy_init();
    if (curl) {
        model = "_bankrots2016";
        inn = "6663003127";
        url = api_url + api_method + "?model=" + model + "&inn=" + inn + "&key=" + key;

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);

        std::string response;
        std::string headers;
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeFunction);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
        curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headers);

        res = curl_easy_perform(curl);

        // check for errors
        if (res == CURLE_OK) {
            std::cout << response << std::endl;
        } else {
            std::cout << "Failed: " << curl_easy_strerror(res) << std::endl;
        }

        curl_easy_cleanup(curl);
    }

    curl_global_cleanup();

    return 0;
}
    
C++ / Qt

#include <QtCore/QCoreApplication>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QDebug>

class Api : public QObject
{
    Q_OBJECT
public:
    QNetworkAccessManager* m_manager;
    QString m_response;
    Api(QObject *parent = 0) : QObject(parent) { m_manager = new QNetworkAccessManager(); }
    void get_contents(const QString &url) {
        QNetworkRequest request;
        QObject::connect(m_manager, &QNetworkAccessManager::finished, this, [=](QNetworkReply *reply) {
            m_response = !reply->error() ? reply->readAll() : reply->errorString();

            // print API response
            qInfo() << m_response;
        });

        request.setUrl(QUrl(url));
        m_manager->get(request);
    }
};

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QString api_url("https://damia.ru/api-scoring/");
    QString api_method("score");
    QString key("67ac454f6a3fa85355aee5e41b6d154efc589aab");
    QString url;
    QString model;
    QString inn;

    model = "_bankrots2016";
    inn = "6663003127";
    url = api_url + api_method + "?model=" + model + "&inn=" + inn + "&key=" + key;

    Api* api = new Api(&a);
    api->get_contents(url); // response will be stored to api->m_response

    return a.exec();
}
    
API-Банки

Примеры обращений к API-Банки

PHP:

$api_url = 'https://analizbankov.ru/api/';
$api_method = 'bankinfo';
$params = [
    'bankregn' => '1481',
    'key' => '67ac454f6a3fa85355aee5e41b6d154efc589aab'
];
$url = $api_url . $api_method . '?' . http_build_query($params);
$result = file_get_contents($url);

// Вывод ответа API
echo($result);
    
Python:

import requests

api_url = 'https://analizbankov.ru/api/'
api_method = 'bankinfo'
params = {'bankregn': '1481', 'key': '67ac454f6a3fa85355aee5e41b6d154efc589aab'}
resp = requests.get(api_url + api_method, params=params)

# Вывод ответа API
print(resp.text) # вывод строки
print(resp.json()) # вывод словаря
    
VBA:

Sub apiCall()
    Dim objRequest As Object
    Dim apiUrl As String
    Dim apiMethod As String
    Dim url As String
    Dim bankregn As String
    Dim key As String
    Dim response As String

    Set objRequest = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    apiUrl = "https://analizbankov.ru/api/"
    apiMethod = "bankinfo"
    bankregn = "1481"
    key = "67ac454f6a3fa85355aee5e41b6d154efc589aab"
    url = apiUrl & apiMethod & "?bankregn=" & bankregn & "&key=" & key

    With objRequest
        .Open "GET", url
        .SetRequestHeader "Content-Type", "application/json"
        .Send

        response = .ResponseText
    End With

    'Вывод ответа API
    Debug.Print response
End Sub
    
Пример использования API-Банки: демонстрационный файл Excel
C++ / libcurl:

#include <curl/curl.h>
#include <string>
#include <iostream>

size_t writeFunction(void *ptr, size_t size, size_t nmemb, std::string* data) {
    data->append((char*)ptr, size * nmemb);
    return size * nmemb;
}

int main(){
    CURL *curl;
    CURLcode res;
    std::string api_url("https://analizbankov.ru/api/");
    std::string api_method("bankinfo");
    std::string key("67ac454f6a3fa85355aee5e41b6d154efc589aab");
    std::string url;
    std::string bankregn;

    curl_global_init(CURL_GLOBAL_DEFAULT);

    curl = curl_easy_init();
    if (curl) {
        bankregn = "1481";
        url = api_url + api_method + "?bankregn=" + bankregn + "&key=" + key;

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);

        std::string response;
        std::string headers;
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeFunction);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
        curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headers);

        res = curl_easy_perform(curl);

        // check for errors
        if (res == CURLE_OK) {
            std::cout << response << std::endl;
        } else {
            std::cout << "Failed: " << curl_easy_strerror(res) << std::endl;
        }

        curl_easy_cleanup(curl);
    }

    curl_global_cleanup();

    return 0;
}
    
C++ / Qt

#include <QtCore/QCoreApplication>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QDebug>

class Api : public QObject
{
    Q_OBJECT
public:
    QNetworkAccessManager* m_manager;
    QString m_response;
    Api(QObject *parent = 0) : QObject(parent) { m_manager = new QNetworkAccessManager(); }
    void get_contents(const QString &url) {
        QNetworkRequest request;
        QObject::connect(m_manager, &QNetworkAccessManager::finished, this, [=](QNetworkReply *reply) {
            m_response = !reply->error() ? reply->readAll() : reply->errorString();

            // print API response
            qInfo() << m_response;
        });

        request.setUrl(QUrl(url));
        m_manager->get(request);
    }
};

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QString api_url("https://analizbankov.ru/api/");
    QString api_method("bankinfo");
    QString key("67ac454f6a3fa85355aee5e41b6d154efc589aab");
    QString url;
    QString bankregn;

    bankregn = "1481";
    url = api_url + api_method + "?bankregn=" + bankregn + "&key=" + key;

    Api* api = new Api(&a);
    api->get_contents(url); // response will be stored to api->m_response

    return a.exec();
}
    
API-Закупки

Примеры обращений к API-Закупки

PHP:

$api_url = 'https://damia.ru/api-zakupki/';
$api_method = 'contracts';
$params = [
    'inn' => '7803046541',
    'key' => '67ac454f6a3fa85355aee5e41b6d154efc589aab'
];
$url = $api_url . $api_method . '?' . http_build_query($params);
$result = file_get_contents($url);

// Вывод ответа API
echo($result);
    
Python:

import requests

api_url = 'https://damia.ru/api-zakupki/'
api_method = 'contracts'
params = {'inn': '7803046541', 'key': '67ac454f6a3fa85355aee5e41b6d154efc589aab'}
resp = requests.get(api_url + api_method, params=params)

# Вывод ответа API
print(resp.text) # вывод строки
print(resp.json()) # вывод словаря
    
VBA:

Sub apiCall()
    Dim objRequest As Object
    Dim apiUrl As String
    Dim apiMethod As String
    Dim url As String
    Dim inn As String
    Dim key As String
    Dim response As String

    Set objRequest = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    apiUrl = "https://damia.ru/api-zakupki/"
    apiMethod = "contracts"
    inn = "7803046541"
    key = "67ac454f6a3fa85355aee5e41b6d154efc589aab"
    url = apiUrl & apiMethod & "?inn=" & inn & "&key=" & key

    With objRequest
        .Open "GET", url
        .SetRequestHeader "Content-Type", "application/json"
        .Send

        response = .ResponseText
    End With

    'Вывод ответа API
    Debug.Print response
End Sub
    
C++ / libcurl:

#include <curl/curl.h>
#include <string>
#include <iostream>

size_t writeFunction(void *ptr, size_t size, size_t nmemb, std::string* data) {
    data->append((char*)ptr, size * nmemb);
    return size * nmemb;
}

int main(){
    CURL *curl;
    CURLcode res;
    std::string api_url("https://damia.ru/api-zakupki/");
    std::string api_method("contracts");
    std::string key("67ac454f6a3fa85355aee5e41b6d154efc589aab");
    std::string url;
    std::string inn;

    curl_global_init(CURL_GLOBAL_DEFAULT);

    curl = curl_easy_init();
    if (curl) {
        inn = "7803046541";
        url = api_url + api_method + "?inn=" + inn + "&key=" + key;

        curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
        curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);

        std::string response;
        std::string headers;
        curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeFunction);
        curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response);
        curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headers);

        res = curl_easy_perform(curl);

        // check for errors
        if (res == CURLE_OK) {
            std::cout << response << std::endl;
        } else {
            std::cout << "Failed: " << curl_easy_strerror(res) << std::endl;
        }

        curl_easy_cleanup(curl);
    }

    curl_global_cleanup();

    return 0;
}
    
C++ / Qt

#include <QtCore/QCoreApplication>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QDebug>

class Api : public QObject
{
    Q_OBJECT
public:
    QNetworkAccessManager* m_manager;
    QString m_response;
    Api(QObject *parent = 0) : QObject(parent) { m_manager = new QNetworkAccessManager(); }
    void get_contents(const QString &url) {
        QNetworkRequest request;
        QObject::connect(m_manager, &QNetworkAccessManager::finished, this, [=](QNetworkReply *reply) {
            m_response = !reply->error() ? reply->readAll() : reply->errorString();

            // print API response
            qInfo() << m_response;
        });

        request.setUrl(QUrl(url));
        m_manager->get(request);
    }
};

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QString api_url("https://damia.ru/api-zakupki/");
    QString api_method("contracts");
    QString key("67ac454f6a3fa85355aee5e41b6d154efc589aab");
    QString url;
    QString inn;

    inn = "7803046541";
    url = api_url + api_method + "?inn=" + inn + "&key=" + key;

    Api* api = new Api(&a);
    api->get_contents(url); // response will be stored to api->m_response

    return a.exec();
}