Skip to content

Repository files navigation

Dadata API Client

Data cleansing, enrichment and suggestions via Dadata API

Nuget VersionDownloads

The official Dadata .NET library, supporting .NET Standard 2.0+

Installation

Using the .NET Core command-line interface (CLI) tools:

dotnet add package Newtonsoft.Json
dotnet add package Dadata

Using the NuGet Command Line Interface (CLI):

nuget install Newtonsoft.Json
nuget install Dadata

Using the Package Manager Console:

Install-Package Newtonsoft.Json
Install-Package Dadata

From within Visual Studio:

  1. Open the Solution Explorer.
  2. Right-click on a project within your solution.
  3. Click on Manage NuGet Packages...
  4. Click on the Browse tab and search for "Dadata".
  5. Click on the Dadata package, select the appropriate version in the right-tab and click Install.

Usage

Import namespaces:

usingDadata;usingDadata.Model;

Create API client instance:

vartoken="Replace with Dadata API key";varsecret="Replace with Dadata secret key";varapi=newCleanClientAsync(token,secret);// or any of the following, depending on the API methodapi=newSuggestClientAsync(token,secret);api=newOutwardClientAsync(token);api=newProfileClientAsync(token,secret);

Then call API methods as specified below.

Examples use async clients: CleanClientAsync, SuggestClientAsync, OutwardClientAsync and ProfileClientAsync. There are sync alternatives with Sync suffixes — they exist for backward compatibility and will be removed in future releases.

The library does not enforce a specific TLS version. If you need to set one, do it in your code like this:

ServicePointManager.SecurityProtocol=SecurityProtocolType.Tls12;

Postal Address

varapi=newCleanClientAsync(token,secret);varaddress=awaitapi.Clean<Address>("мск сухонская 11 89");

Same API method as "validate and cleanse":

varapi=newCleanClientAsync(token,secret);varaddress=awaitapi.Clean<Address>("москва сухонская 11");
varapi=newSuggestClientAsync(token);varresponse=awaitapi.Geolocate(lat:55.878,lon:37.653);varaddress=response.suggestions[0].data;
varapi=newSuggestClientAsync(token);varresponse=awaitapi.Iplocate("46.226.227.20");varaddress=response.location.data;
varapi=newSuggestClientAsync(token);varresponse=awaitapi.SuggestAddress("самара метал");varaddress=response.suggestions[0].data;

Show suggestions in English:

varrequest=newSuggestAddressRequest("samara metal"){language="en"};varresponse=awaitapi.SuggestAddress(request);varaddress=response.suggestions[0].data;

Constrain by city (Yuzhno-Sakhalinsk):

varrequest=newSuggestAddressRequest("ватутина"){locations=new[]{newAddress(){kladr_id="6500000100000"},}};varresponse=awaitapi.SuggestAddress(request);varaddress=response.suggestions[0].data;

Constrain by specific geo point and radius (in Vologda city):

varrequest=newSuggestAddressRequest("сухонская"){locations_geo=new[]{newLocationGeo(){lat=59.244634,lon=39.913355,radius_meters=200}}};varresponse=awaitapi.SuggestAddress(request);varaddress=response.suggestions[0].data;

Boost city to top (Toliatti):

varrequest=newSuggestAddressRequest("авто"){locations_boost=new[]{newAddress(){kladr_id="6300000700000"},}};varresponse=awaitapi.SuggestAddress(request);varaddress=response.suggestions[0].data;
varapi=newSuggestClientAsync(token);varresponse=awaitapi.FindAddress("9120b43f-2fae-4838-a144-85e43c2bfb29");varaddress=response.suggestions[0].data;

Find by KLADR ID:

varresponse=awaitapi.FindAddress("77000000000268400");varaddress=response.suggestions[0].data;

Suggest postal office by address or code:

varapi=newOutwardClientAsync(token);varresponse=awaitapi.Suggest<PostalUnit>("дежнева 2а");varunit=response.suggestions[0].data;

Find postal office by code:

varresponse=awaitapi.Find<PostalUnit>("127642");varunit=response.suggestions[0].data;

Find nearest postal office:

varresponse=awaitapi.Geolocate<PostalUnit>(lat:55.878,lon:37.653,radius_meters:1000);varunit=response.suggestions[0].data;
varapi=newOutwardClientAsync(token);varresponse=awaitapi.Find<DeliveryCity>("3100400100000");varcity=response.suggestions[0].data;
varapi=newSuggestClientAsync(token);varresponse=awaitapi.FindFias("9120b43f-2fae-4838-a144-85e43c2bfb29");varaddress=response.suggestions[0].data;
varapi=newOutwardClientAsync(token);varresponse=awaitapi.Suggest<Country>("та");varcountry=response.suggestions[0].data;

Company or individual enterpreneur

varapi=newSuggestClientAsync(token);varresponse=awaitapi.FindParty("7707083893");varparty=response.suggestions[0].data;

Find by INN and KPP:

varrequest=newFindPartyRequest(query:"7707083893",kpp:"540602001");varresponse=awaitapi.FindParty(request);varparty=response.suggestions[0].data;
varapi=newSuggestClientAsync(token);varresponse=awaitapi.SuggestParty("сбер");varparty=response.suggestions[0];

Constrain by specific regions (Saint Petersburg and Leningradskaya oblast):

varrequest=newSuggestPartyRequest("сбер"){locations=new[]{newAddress(){kladr_id="7800000000000"},newAddress(){kladr_id="4700000000000"},}};varresponse=awaitapi.SuggestParty(request);varparty=response.suggestions[0];

Constrain by active companies:

varrequest=newSuggestPartyRequest("сбер"){status=new[]{PartyStatus.ACTIVE}};varresponse=awaitapi.SuggestParty(request);varparty=response.suggestions[0];

Constrain by individual entrepreneurs:

varrequest=newSuggestPartyRequest("сбер"){type=PartyType.INDIVIDUAL};varresponse=awaitapi.SuggestParty(request);varparty=response.suggestions[0];
varapi=newSuggestClientAsync(token);varresponse=awaitapi.FindAffiliated("7736207543");varparty=response.suggestions[0].data;

Search only by manager INN:

varrequest=newFindAffiliatedRequest("773006366201"){scope=new[]{FindAffiliatedScope.MANAGERS}};varresponse=awaitapi.FindAffiliated(request);varparty=response.suggestions[0].data;

Bank

varapi=newSuggestClientAsync(token);varresponse=awaitapi.FindBank("044525225");varbank=response.suggestions[0].data;

Find by SWIFT code:

varresponse=awaitapi.FindBank("SABRRUMM");varbank=response.suggestions[0].data;

Find by INN:

varresponse=awaitapi.FindBank("7728168971");varbank=response.suggestions[0].data;

Find by INN and KPP:

varrequest=newFindBankRequest(query:"7728168971",kpp:"667102002");varresponse=awaitapi.FindBank(request);varbank=response.suggestions[0].data;

Find by registration number:

varresponse=awaitapi.FindBank("1481");varbank=response.suggestions[0].data;
varapi=newSuggestClientAsync(token);varresponse=awaitapi.SuggestBank("ти");varbank=response.suggestions[0].data;

Personal name

varapi=newCleanClientAsync(token,secret);varfullname=awaitapi.Clean<Fullname>("Срегей владимерович иванов");
varapi=newSuggestClientAsync(token);varresponse=awaitapi.SuggestName("викт");varfullname=response.suggestions[0].data;

Suggest female first name:

varrequest=newSuggestNameRequest("викт"){parts=new[]{FullnamePart.NAME},gender=Gender.FEMALE};varresponse=awaitapi.SuggestName(request);varfullname=response.suggestions[0].data;

Phone

varapi=newCleanClientAsync(token,secret);varphone=awaitapi.Clean<Phone>("9168-233-454");

Passport

varapi=newCleanClientAsync(token,secret);varpassport=awaitapi.Clean<Passport>("4509 235857");
varapi=newOutwardClientAsync(token);varresponse=awaitapi.Suggest<FmsUnit>("772 053");varunit=response.suggestions[0].data;

Email

varapi=newCleanClientAsync(token,secret);varemail=awaitapi.Clean<Email>("serega@yandex/ru");
varapi=newSuggestClientAsync(token);varresponse=awaitapi.SuggestEmail("maria@");varemail=response.suggestions[0].data;

Other datasets

varapi=newOutwardClientAsync(token);varresponse=awaitapi.Find<FnsUnit>("5257");varunit=response.suggestions[0].data;
varapi=newOutwardClientAsync(token);varresponse=awaitapi.Suggest<MetroStation>("алек");varstation=response.suggestions[0].data;

Constrain by city (Saint Petersburg):

varrequest=newSuggestOutwardRequest("алек"){filters=newDictionary<string,string>(){{"city","Санкт-Петербург"}}};varresponse=awaitapi.Suggest<MetroStation>(request);varstation=response.suggestions[0].data;
varapi=newOutwardClientAsync(token);varresponse=awaitapi.Suggest<CarBrand>("фо");varbrand=response.suggestions[0].data;
varapi=newOutwardClientAsync(token);varresponse=awaitapi.Find<OktmoRecord>("54623425");varrecord=response.suggestions[0].data;
varapi=newOutwardClientAsync(token);varresponse=awaitapi.Suggest<OkvedRecord>("космических");varrecord=response.suggestions[0].data;

Profile API

varapi=newProfileClientAsync(token,secret);

Balance:

varresponse=awaitapi.GetBalance();varbalance=response.balance;

Usage stats:

varresponse=awaitapi.GetDailyStats();varcleanCount=response.services.clean;varsuggestionsCount=response.services.suggestions;varmergingCount=response.services.merging;

Dataset versions:

varresponse=awaitapi.GetVersions();varegrulVersion=response.suggestions.resources["ЕГРЮЛ"];vargeoVersion=response.factor.resources["Геокоординаты"];

Contributing

This project only accepts bug fixes.

This project uses CalVer with YY.MM.MICRO schema. See changelog for details specific to each release.

License

MIT

About

Data cleansing, enrichment and suggestions via Dadata API

Resources

Stars

68 stars

Watchers

12 watching

Forks

Releases

Packages

Used by

Contributors

Languages