### Geocoding API .NET Client Example
Source: https://dadata.ru/api/geocode
Example of using the dadata-csharp library to geocode an address. Ensure you have the library installed and replace placeholders with your API and secret keys.
```csharp
// https://github.com/hflabs/dadata-csharp
var token = "${API_KEY}";
var secret = "${SECRET_KEY}";
var api = new CleanClientAsync(token, secret);
var result = await api.Clean
("москва сухонская 11");
```
--------------------------------
### Suggest Postal Office by Query (PHP)
Source: https://dadata.ru/api/suggest/postal_office
Example of using the dadata-php library to suggest a postal office. Requires the dadata-php package to be installed.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->suggest("postal_office", "москва 64");
```
--------------------------------
### Python Bank Suggest API Call
Source: https://dadata.ru/api/suggest/bank
Example of how to call the Bank Suggest API using Python with the 'requests' library. Ensure 'requests' is installed.
```python
import requests
import json
def suggest_bank(query):
url = 'https://suggestions.dadata.ru/suggestions/api/v1/suggest/bank'
token = 'YOUR_API_TOKEN' # Replace with your actual API token
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f'Token {token}'
}
try:
response = requests.post(url, headers=headers, data=json.dumps({'query': query}))
response.raise_for_status() # Raise an exception for bad status codes
return response.json()
except requests.exceptions.RequestException as e:
print(f'Error suggesting bank: {e}')
return None
# Example usage:
result = suggest_bank('Сбербанк')
if result:
print(json.dumps(result, indent=2))
```
--------------------------------
### Node.js Bank Suggest API Call
Source: https://dadata.ru/api/suggest/bank
Example of how to call the Bank Suggest API using Node.js with the 'axios' library. Ensure 'axios' is installed.
```javascript
const axios = require('axios');
async function suggestBank(query) {
const url = 'https://suggestions.dadata.ru/suggestions/api/v1/suggest/bank';
const token = 'YOUR_API_TOKEN'; // Replace with your actual API token
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': `Token ${token}`
};
try {
const response = await axios.post(url, { query: query }, { headers: headers });
return response.data;
} catch (error) {
console.error('Error suggesting bank:', error);
throw error;
}
}
// Example usage:
suggestBank('Сбербанк')
.then(data => console.log(data))
.catch(err => console.error(err));
```
--------------------------------
### Address Suggestion using Go
Source: https://dadata.ru/api/suggest/address
Example of how to get address suggestions using the Go Dadata client library. It uses the API key from the DADATA_API_KEY environment variable.
```go
// https://github.com/ekomobile/dadata
// Использует API-ключ из переменной окружения DADATA_API_KEY
import (
"context"
dadata "github.com/ekomobile/dadata/v2"
"github.com/ekomobile/dadata/v2/api/suggest"
)
func main() {
api := dadata.NewSuggestApi()
params := suggest.RequestParams{Query: "москва хабар"}
result, err := api.Address(context.Background(), ¶ms)
}
```
--------------------------------
### Go Example
Source: https://dadata.ru/api/clean/birthdate
Example of using the Dadata Go SDK to standardize a birthdate. Uses API keys from environment variables.
```go
// https://github.com/ekomobile/dadata
// Использует API-ключ из переменной окружения DADATA_API_KEY
// а секретный ключ из переменной окружения DADATA_SECRET_KEY
import (
"context"
dadata "github.com/ekomobile/dadata/v2"
)
func main() {
api := dadata.NewCleanApi()
query := "24/3/12"
result, err := api.Birthday(context.Background(), query)
}
```
--------------------------------
### C# / .NET Example
Source: https://dadata.ru/api/clean/birthdate
Example of using the Dadata C# SDK to standardize a birthdate.
```csharp
// https://github.com/hflabs/dadata-csharp
var token = "${API_KEY}";
var secret = "${SECRET_KEY}";
var api = new CleanClientAsync(token, secret);
var result = await api.Clean("24/3/12");
```
--------------------------------
### Address Suggestion using Python
Source: https://dadata.ru/api/suggest/address
Example of how to get address suggestions using the Dadata Python client library. Requires the 'dadata-py' package.
```python
# https://github.com/hflabs/dadata-py
from dadata import Dadata
token = "${API_KEY}"
dadata = Dadata(token)
result = dadata.suggest("address", "москва хабар")
```
--------------------------------
### PHP Example
Source: https://dadata.ru/api/clean/birthdate
Example of using the Dadata PHP SDK to standardize a birthdate.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$secret = "${SECRET_KEY}";
$dadata = new \Dadata\DadataClient($token, $secret);
$result = $dadata->clean("birthdate", "24/3/12");
```
--------------------------------
### Suggest OKPDTR Position using Dadata Python Client
Source: https://dadata.ru/api/suggest/okpdtr_position
Example of using the dadata-py library to search for OKPDTR positions. Ensure the dadata-py library is installed.
```Python
# https://github.com/hflabs/dadata-py
from dadata import Dadata
token = "${API_KEY}"
dadata = Dadata(token)
result = dadata.suggest("okpdtr_position", "инженер")
```
--------------------------------
### Address Suggestion using .NET
Source: https://dadata.ru/api/suggest/address
Example of how to get address suggestions using the Dadata C# client library. Requires the 'dadata-csharp' NuGet package.
```csharp
// https://github.com/hflabs/dadata-csharp
var token = "${API_KEY}";
var api = new SuggestClientAsync(token);
var result = await api.SuggestAddress("москва хабар");
```
--------------------------------
### POST Request Example
Source: https://dadata.ru/api/clean/name
This is an example of how to make a POST request to the name standardization API.
```http
POST https://cleaner.dadata.ru/api/v1/clean/name
```
--------------------------------
### POST Request Example
Source: https://dadata.ru/api/clean/phone
This example shows the basic structure of a POST request to the phone standardization API.
```http
POST https://cleaner.dadata.ru/api/v1/clean/phone
[ "раб 846)231.60.14 *139" ]
```
--------------------------------
### Address Suggestion using PHP
Source: https://dadata.ru/api/suggest/address
Example of how to get address suggestions using the Dadata PHP client library. Requires the 'hflabs/dadata-php' package.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->suggest("address", "москва хабар");
```
--------------------------------
### Full-Text Search for Currency (PHP)
Source: https://dadata.ru/api/suggest/currency
This PHP example shows how to use the dadata-php library to search for currency. Ensure you have the library installed and replace ${API_KEY} with your API key.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->suggest("currency", "руб");
```
--------------------------------
### POST Request Example (Sandbox)
Source: https://dadata.ru/api/iplocate
Example of a POST request to the iplocate API endpoint. This is useful for testing and understanding the request structure.
```http
POST https://suggestions.dadata.ru/suggestions/api/4_1/rs/iplocate/address
{
"ip": "46.226.227.20"
}
```
--------------------------------
### Python Example
Source: https://dadata.ru/api/clean/birthdate
Example of using the Dadata Python SDK to standardize a birthdate.
```python
# https://github.com/hflabs/dadata-py
from dadata import Dadata
token = "${API_KEY}"
secret = "${SECRET_KEY}"
dadata = Dadata(token, secret)
result = dadata.clean("birthdate", "24/3/12")
```
--------------------------------
### Email Suggestion using .NET
Source: https://dadata.ru/api/suggest/email
Example of using the Dadata C# SDK to get email suggestions. Requires the API key and the SuggestClientAsync class.
```csharp
// https://github.com/hflabs/dadata-csharp
var token = "${API_KEY}";
var api = new SuggestClientAsync(token);
var result = await api.SuggestEmail("anton@");
```
--------------------------------
### Node.js Example
Source: https://dadata.ru/api/clean/birthdate
Example of standardizing a birthdate using Node.js fetch API.
```javascript
var url = "https://cleaner.dadata.ru/api/v1/clean/birthdate";
var token = "${API_KEY}";
var secret = "${SECRET_KEY}";
var query = "24/3/12";
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": "Token " + token,
"X-Secret": secret
},
body: JSON.stringify([query])
}
fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
```
--------------------------------
### Find Brand by INN Request Example
Source: https://dadata.ru/api/find-brand
This is an example of how to make a POST request to the brand finding API endpoint.
```HTTP
POST https://api.dadata.ru/findById/brand
{
"query": "560404424247"
}
```
--------------------------------
### Get Daily Statistics (JavaScript)
Source: https://dadata.ru/api/stat
Fetch daily statistics using JavaScript's fetch API. This example shows how to set up the request headers, including authorization tokens.
```javascript
var url = "https://dadata.ru/api/v2/stat/daily";
var token = "${API_KEY}";
var secret = "${SECRET_KEY}";
var options = {
method: "GET",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": "Token " + token,
"X-Secret": secret
}
}
fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
```
--------------------------------
### Address Suggestion using JavaScript (fetch)
Source: https://dadata.ru/api/suggest/address
Example of how to get address suggestions using the Fetch API in JavaScript. Make sure to replace ${API_KEY} with your actual API key.
```javascript
var url = "https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address";
var token = "${API_KEY}";
var query = "москва хабар";
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Token " + token
},
body: JSON.stringify({query: query})
}
fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
```
--------------------------------
### POST Request Example
Source: https://dadata.ru/api/clean/vehicle
This is an example of a POST request to the vehicle standardization API.
```http
POST https://cleaner.dadata.ru/api/v1/clean/vehicle
```
--------------------------------
### Successful iplocate Response Example
Source: https://dadata.ru/api/iplocate
This is an example of a successful response from the iplocate API, detailing the location information found for the given IP address.
```json
{
"location": {
"value": "г Краснодар",
"unrestricted_value": "350000, Краснодарский край, г Краснодар",
"data": {
"postal_code": "350000",
"country": "Россия",
"country_iso_code": "RU",
"federal_district": "Южный",
"region_fias_id": "d00e1013-16bd-4c09-b3d5-3cb09fc54bd8",
"region_kladr_id": "2300000000000",
"region_iso_code": "RU-KDA",
"region_with_type": "Краснодарский край",
"region_type": "край",
"region_type_full": "край",
"region": "Краснодарский",
"area_fias_id": null,
"area_kladr_id": null,
"area_with_type": null,
"area_type": null,
"area_type_full": null,
"area": null,
"city_fias_id": "7dfa745e-aa19-4688-b121-b655c11e482f",
"city_kladr_id": "2300000100000",
"city_with_type": "г Краснодар",
"city_type": "г",
"city_type_full": "город",
"city": "Краснодар",
...
}
}
}
```
--------------------------------
### POST Request Example
Source: https://dadata.ru/api/cadastre-clean
Example of a POST request to the clean address API endpoint.
```http
POST https://cleaner.dadata.ru/api/v1/clean/address
[
"москва сухонская 11 89"
]
```
--------------------------------
### Email Standardization Request Example
Source: https://dadata.ru/api/clean/email
This example shows the structure of a POST request to the email standardization API.
```http
POST https://cleaner.dadata.ru/api/v1/clean/email
[ "serega@yandex/ru" ]
__
```
--------------------------------
### API Balance Response Example
Source: https://dadata.ru/api/balance
This is an example of the JSON response you will receive when querying the user balance API. The balance is returned in rubles with decimal precision.
```json
{ "balance": 9922.30 }
```
--------------------------------
### FIAS Address Suggestion Request Example
Source: https://dadata.ru/api/suggest/fias
This example shows the structure of a POST request to the FIAS suggestions API with a sample query. Ensure you include the correct API key in the Authorization header.
```HTTP
POST https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/fias
{
"query": "москва хабар"
}
```
--------------------------------
### Company Employee Count
Source: https://dadata.ru/api/find-party
Example showing the employee count for a company.
```json
"employee_count": 369
}
```
--------------------------------
### POST Request Example
Source: https://dadata.ru/api/clean/passport
This is an example of how to make a POST request to the passport standardization API. Ensure you include the correct Content-Type, Accept headers, and your API and Secret keys.
```http
POST https://cleaner.dadata.ru/api/v1/clean/passport
["4509 235857"]
```
--------------------------------
### Suggest Bank using Go
Source: https://dadata.ru/api/suggest/bank
Example of using the Go Dadata SDK to suggest bank information. Uses the API key from the DADATA_API_KEY environment variable.
```go
// https://github.com/ekomobile/dadata
// Использует API-ключ из переменной окружения DADATA_API_KEY
import (
"context"
dadata "github.com/ekomobile/dadata/v2"
"github.com/ekomobile/dadata/v2/api/suggest"
)
func main() {
api := dadata.NewSuggestApi()
params := suggest.RequestParams{Query: "сбербанк"}
result, err := api.Bank(context.Background(), ¶ms)
}
```
--------------------------------
### Dadata API FIO Suggestion using .NET
Source: https://dadata.ru/api/suggest/name
Example of using the Dadata C# client library to get name suggestions. Ensure you have the 'dadata-csharp' library installed.
```csharp
// https://github.com/hflabs/dadata-csharp
var token = "${API_KEY}";
var api = new SuggestClientAsync(token);
var result = await api.SuggestName("Викт");
```
--------------------------------
### Suggest Bank using Python
Source: https://dadata.ru/api/suggest/bank
Example of using the Dadata Python SDK to suggest bank information. Requires the dadata-py library.
```python
# https://github.com/hflabs/dadata-py
from dadata import Dadata
token = "${API_KEY}"
dadata = Dadata(token)
result = dadata.suggest("bank", "сбербанк")
```
--------------------------------
### FIAS Address Suggestion Request using PHP
Source: https://dadata.ru/api/suggest/fias
This PHP example shows how to use the `dadata-php` library to get FIAS address suggestions. Ensure you have the library installed and replace `${API_KEY}` with your token.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->suggest("fias", "москва хабар");
```
--------------------------------
### Geocoding API Python Client Example
Source: https://dadata.ru/api/geocode
Example of using the dadata-py library in Python to geocode an address. It requires the library to be installed and uses API keys for authentication.
```python
# https://github.com/hflabs/dadata-py
from dadata import Dadata
token = "${API_KEY}"
secret = "${SECRET_KEY}"
dadata = Dadata(token, secret)
result = dadata.clean("address", "москва сухонская 11")
```
--------------------------------
### Suggest Bank using .NET
Source: https://dadata.ru/api/suggest/bank
Example of using the Dadata C# SDK to suggest bank information. Requires the dadata-csharp library.
```csharp
// https://github.com/hflabs/dadata-csharp
var token = "${API_KEY}";
var api = new SuggestClientAsync(token);
var result = await api.SuggestBank("сбербанк");
```
--------------------------------
### Name Standardization in .NET
Source: https://dadata.ru/api/clean/name
Example of using the Dadata C# client to standardize a full name. Ensure you have the dadata-csharp library installed.
```csharp
// https://github.com/hflabs/dadata-csharp
var token = "${API_KEY}";
var secret = "${SECRET_KEY}";
var api = new CleanClientAsync(token, secret);
var result = await api.Clean("Срегей владимерович иванов");
```
--------------------------------
### Suggest Bank using PHP
Source: https://dadata.ru/api/suggest/bank
Example of using the Dadata PHP SDK to suggest bank information. Requires the hflabs/dadata-php library.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new
Dadata\DadataClient($token, null);
$result = $dadata->suggest("bank", "сбербанк");
```
--------------------------------
### Suggest Country by Query (JavaScript)
Source: https://dadata.ru/api/suggest/country
Fetch country suggestions using JavaScript. This example demonstrates setting up the request options, including headers and the request body, and handling the response.
```JavaScript
var url = "https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/country";
var token = "${API_KEY}";
var query = "та";
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Token " + token
},
body: JSON.stringify({query: query})
}
fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
```
--------------------------------
### Go Bank Suggest API Call
Source: https://dadata.ru/api/suggest/bank
Example of calling the Bank Suggest API using Go. This snippet shows how to construct the request and handle the JSON response.
```go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
)
const apiUrl = "https://suggestions.dadata.ru/suggestions/api/v1/suggest/bank"
const apiToken = "YOUR_API_TOKEN" // Replace with your actual API token
type SuggestionData struct {
Value string `json:"value"`
UnrestrictedValue string `json:"unrestricted_value"`
Data json.RawMessage `json:"data"` // Use RawMessage to defer parsing if needed
}
type SuggestionResponse struct {
Suggestions []SuggestionData `json:"suggestions"`
}
func suggestBank(query string) (*SuggestionResponse, error) {
requestBody := map[string]string{"query": query}
jsonBody, err := json.Marshal(requestBody)
if err != nil {
return nil, fmt.Errorf("failed to marshal request body: %w", err)
}
req, err := http.NewRequest("POST", apiUrl, bytes.NewBuffer(jsonBody))
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Token "+apiToken)
client := &http.Client{}
res, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to send request: %w", err)
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
if res.StatusCode < 200 || res.StatusCode >= 300 {
return nil, fmt.Errorf("API request failed with status code %d: %s", res.StatusCode, string(body))
}
var response SuggestionResponse
err = json.Unmarshal(body, &response)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal response body: %w", err)
}
return &response, nil
}
func main() {
query := "Сбербанк"
result, err := suggestBank(query)
if err != nil {
log.Fatalf("Error: %v", err)
}
// Pretty print the JSON response
prettyJSON, err := json.MarshalIndent(result, "", " ")
if err != nil {
log.Fatalf("Error marshaling indent: %v", err)
}
fmt.Println(string(prettyJSON))
}
```
--------------------------------
### Email Suggestion using PHP
Source: https://dadata.ru/api/suggest/email
Example of using the Dadata PHP SDK to get email suggestions. Requires the API key and the DadataClient class.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->suggest("email", "anton@");
```
--------------------------------
### Go Client for iplocate
Source: https://dadata.ru/api/iplocate
Illustrates how to use the ekomobile/dadata Go library to perform an IP location lookup. The API key is expected to be in the DADATA_API_KEY environment variable.
```go
// https://github.com/ekomobile/dadata
// Использует API-ключ из переменной окружения DADATA_API_KEY
import (
"context"
dadata "github.com/ekomobile/dadata/v2"
"github.com/ekomobile/dadata/v2/api/suggest"
)
func main() {
api := dadata.NewSuggestApi()
query := "46.226.227.20"
result, err := api.GeoIP(context.Background(), query)
}
```
--------------------------------
### Find Postal Office by ID (PHP)
Source: https://dadata.ru/api/suggest/postal_office
Example using the dadata-php library to find a postal office by its ID. Ensure the dadata-php package is installed.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->findById("postal_office", "127642");
```
--------------------------------
### Geocoding API Go Client Example
Source: https://dadata.ru/api/geocode
This Go code snippet shows how to use the ekomobile/dadata library to geocode an address. It utilizes environment variables for API keys and requires context for the API call.
```go
// https://github.com/ekomobile/dadata
// Использует API-ключ из переменной окружения DADATA_API_KEY
// а секретный ключ из переменной окружения DADATA_SECRET_KEY
import (
"context"
dadata "github.com/ekomobile/dadata/v2"
)
func main() {
api := dadata.NewCleanApi()
query := "москва сухонская 11"
result, err := api.Address(context.Background(), query)
}
```
--------------------------------
### Find Brand by INN using Node.js Fetch
Source: https://dadata.ru/api/find-brand
This Node.js example demonstrates how to use the fetch API to call the brand finding service. It includes setting necessary headers and sending the query in the request body.
```javascript
var url = "https://api.dadata.ru/findById/brand";
var token = "${API_KEY}";
var secret = "${SECRET_KEY}";
var query = "560404424247";
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Token " + token ,
"X-Secret": secret
},
body: JSON.stringify({query: query})
}
fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
```
--------------------------------
### Find postal unit by ID (PHP)
Source: https://dadata.ru/api/suggest/postal_unit
Example using the dadata-php library to find a postal unit by its ID. Ensure the library is installed and your API key is configured.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->findById("postal_unit", "127642");
```
--------------------------------
### Suggest Party by Name using Go
Source: https://dadata.ru/api/suggest/party
This Go code demonstrates how to use the ekomobile/dadata library to search for organizations by name. The API key is expected to be set in the DADATA_API_KEY environment variable.
```go
// https://github.com/ekomobile/dadata
// Использует API-ключ из переменной окружения DADATA_API_KEY
import (
"context"
dadata "github.com/ekomobile/dadata/v2"
"github.com/ekomobile/dadata/v2/api/suggest"
)
func main() {
api := dadata.NewSuggestApi()
params := suggest.RequestParams{Query: "сбербанк"}
result, err := api.Party(context.Background(), ¶ms)
}
```
--------------------------------
### Find medical position by ID using PHP
Source: https://dadata.ru/api/suggest/medical_position
Use the dadata-php library to find a medical position by its ID. This example assumes the dadata-php library is installed and configured.
```PHP
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->findById("medical_position", "343");
```
--------------------------------
### Find Currency by ID (PHP)
Source: https://dadata.ru/api/suggest/currency
This PHP example uses the dadata-php library to find a currency by its ID. Ensure the library is installed and replace ${API_KEY} with your API key.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->findById("currency", "RUB");
```
--------------------------------
### C# / .NET Bank Suggest API Call
Source: https://dadata.ru/api/suggest/bank
Example of calling the Bank Suggest API using C# with HttpClient. This demonstrates setting headers and sending a JSON payload.
```csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
public class DadataBankSuggest
{
private const string ApiUrl = "https://suggestions.dadata.ru/suggestions/api/v1/suggest/bank";
private const string ApiToken = "YOUR_API_TOKEN"; // Replace with your actual API token
public static async Task SuggestBankAsync(string query)
{
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Token", ApiToken);
var requestBody = new {
query = query
};
var jsonBody = System.Text.Json.JsonSerializer.Serialize(requestBody);
try
{
var response = await client.PostAsync(ApiUrl, new StringContent(jsonBody, Encoding.UTF8, "application/json"));
response.EnsureSuccessStatusCode(); // Throw exception on non-success status codes
return await response.Content.ReadAsStringAsync();
}
catch (HttpRequestException e)
{
Console.WriteLine($"Error suggesting bank: {e.Message}");
return null;
}
}
}
// Example Usage:
public static async Task Main(string[] args)
{
string query = "Сбербанк";
string result = await SuggestBankAsync(query);
if (result != null)
{
Console.WriteLine(result);
}
}
}
```
--------------------------------
### Bank Suggest API Response Example
Source: https://dadata.ru/api/suggest/bank
Illustrates the structure of a successful response from the Bank Suggest API, containing an array of bank suggestions.
```json
{
"suggestions": [
{
"value": "СБЕРБАНК РОССИИ",
"unrestricted_value": "СБЕРБАНК РОССИИ",
"data": {
"opf": {
"type": "BANK",
"full": null,
"short": null
},
"name": {
"payment": "ПАО СБЕРБАНК",
"full": null,
"short": "СБЕРБАНК РОССИИ"
},
"bic": "044525225",
"swift": "SABRRUMM",
"swifts": [
"SABRRUMM",
"SABRRUMM012"
],
"inn": "7707083893",
"kpp": "773601001",
"okpo": null,
"correspondent_account": "30101810400000000225",
"treasury_accounts": null,
"registration_number": "1481",
"payment_city": "г. Москва",
"state": {
"status": "ACTIVE",
"actuality_date": 1564532138000,
"registration_date": 677376000000,
"liquidation_date": null
},
"rkc": null,
"cbr": null,
"address": {
"value": "г Москва, ул Вавилова, д 19",
...
},
"phones": null
}
},
...
]
}
```
--------------------------------
### Full-text search for postal units (PHP)
Source: https://dadata.ru/api/suggest/postal_unit
Example of performing a full-text search for a postal unit using the dadata-php library. Ensure the library is installed and your API key is provided.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->suggest("postal_unit", "дежнева 2а");
```
--------------------------------
### Find OKPDTR Position by ID using Dadata Python Client
Source: https://dadata.ru/api/suggest/okpdtr_position
Example of using the dadata-py library to find an OKPDTR position by its ID. Make sure dadata-py is installed.
```Python
# https://github.com/hflabs/dadata-py
from dadata import Dadata
token = "${API_KEY}"
dadata = Dadata(token)
result = dadata.find_by_id("okpdtr_position", "201294")
```
--------------------------------
### Find Delivery City by KLADR Code (PHP)
Source: https://dadata.ru/api/delivery
This PHP example utilizes the dadata-php library to find a delivery city identifier. Ensure you have the library installed and replace ${API_KEY} with your token.
```php
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->findById("delivery", "3100400100000", 1);
```
--------------------------------
### Find OKTMO by ID using Dadata Python Client
Source: https://dadata.ru/api/suggest/oktmo
This Python example utilizes the `dadata-py` library to find an OKTMO entry. Install the library and substitute `${API_KEY}` with your valid API key.
```python
# https://github.com/hflabs/dadata-py
from dadata import Dadata
token = "${API_KEY}"
dadata = Dadata(token)
result = dadata.find_by_id("oktmo", "54623425")
```
--------------------------------
### FIAS Address Suggestion Request using Python
Source: https://dadata.ru/api/suggest/fias
This Python example utilizes the `dadata-py` library to request FIAS address suggestions. Make sure the library is installed and substitute `${API_KEY}` with your actual API key.
```python
# https://github.com/hflabs/dadata-py
from dadata import Dadata
token = "${API_KEY}"
dadata = Dadata(token)
result = dadata.suggest("fias", "москва хабар")
```
--------------------------------
### Standardize Composite Record using Node.js
Source: https://dadata.ru/api/clean/record
This Node.js example shows how to call the API using `fetch` to standardize a composite record. It includes setting up the request headers and body with the structure and data.
```javascript
var url = "https://cleaner.dadata.ru/api/v1/clean";
var token = "${API_KEY}";
var secret = "${SECRET_KEY}";
var query = {
structure: [ "NAME", "ADDRESS", "PHONE" ],
data: [
[
"Федотов Алексей",
"Москва, Сухонская улица, 11 кв 89",
"8 916 823 3454"
]
]
};
var options = {
method: "POST",
mode: "cors",
headers: {
"Content-Type": "application/json",
"Authorization": "Token " + token,
"X-Secret": secret
},
body: JSON.stringify(query)
}
fetch(url, options)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log("error", error));
```
--------------------------------
### Suggest OKPDTR Position using Dadata PHP Client
Source: https://dadata.ru/api/suggest/okpdtr_position
Demonstrates how to use the dadata-php library to search for OKPDTR positions. Requires the dadata-php package to be installed.
```PHP
// https://github.com/hflabs/dadata-php
$token = "${API_KEY}";
$dadata = new \Dadata\DadataClient($token, null);
$result = $dadata->suggest("okpdtr_position", "инженер");
```
--------------------------------
### Email Suggestion using Go
Source: https://dadata.ru/api/suggest/email
Example of using the Go Dadata SDK to retrieve email suggestions. It utilizes the API key from the DADATA_API_KEY environment variable.
```go
// https://github.com/ekomobile/dadata
// Использует API-ключ из переменной окружения DADATA_API_KEY
import (
"context"
dadata "github.com/ekomobile/dadata/v2"
"github.com/ekomobile/dadata/v2/api/suggest"
)
func main() {
api := dadata.NewSuggestApi()
params := suggest.RequestParams{Query: "anton@"}
result, err := api.Email(context.Background(), ¶ms)
}
```
--------------------------------
### POST Request Example
Source: https://dadata.ru/api/clean/birthdate
Example of a POST request to the birthdate standardization API.
```http
POST https://cleaner.dadata.ru/api/v1/clean/birthdate
[
"24/3/12"
]
```