Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/digillect/dadata
DaData.ru client for .NET Standard
https://github.com/digillect/dadata
Last synced: 15 days ago
JSON representation
DaData.ru client for .NET Standard
- Host: GitHub
- URL: https://github.com/digillect/dadata
- Owner: Digillect
- License: mit
- Created: 2023-02-27T08:57:02.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-15T13:47:36.000Z (2 months ago)
- Last Synced: 2024-12-15T23:26:09.040Z (about 1 month ago)
- Language: C#
- Size: 26.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Digillect DaData.ru client
Implementation of the [DaData](https://dadata.ru/) features, based on HTTP Client through Refit.
## Available features
- [Address suggestions](https://dadata.ru/api/suggest/address/)
- [Address by FIAS/KLADR identifier](https://dadata.ru/api/find-address/)
- [City by IP address](https://dadata.ru/api/iplocate/)## Usage
Register the client in DI container passing API key, if any:
```csharp
services.AddDaDataSuggestionsClient("123456");
```Then inject the client into your services/controllers:
```csharp
[Route("/api/addresses")]
public sealed class AddressesController : ApiController
{
private readonly IDaDataSuggestionsClient _client;
public AddressesController(IDaDataSuggestionsClient client)
{
_client = client;
}///
/// Suggests addresses for the specified query.
///
[HttpGet("suggestions")]
public Task> GetSuggestionsAsync(string query) => _client.SuggestAddressAsync(query);
///
/// Suggests cities for the specified query.
///
[HttpGet("cities")]
public async Task> GetCitiesAsync(string query)
{
var request = SuggestAddressRequest.Create(query).From(SuggestAddressBound.City).To(SuggestAddressBound.City);
var response = await _client.SuggestAddressAsync(request);
return response.Suggestions;
}
}
```