This library is wrapper to help to use neshan.org in dotnet. all api neshan provide is suported. you can get more information in this link
You can install it from nuget with this command
Install-Package NeshanApi.Dotnet
Or with dotnet cli with
dotnet add package NeshanApi.Dotnet
Before to start use this you must get your API KEY from Neshan
Platform, then you can start.
for configure your client you must use NeshanConfig class and pass to client instance. the only config currently
available is API KEY.
After done all of this you can create a instance of NeshanApiClient. to do that you have 2 option
- Create directly
this is example how you can create your instance
public static INeshanApiClient GetInstance()
{
return new NeshanApiClient(new HttpClient(), new NeshanConfig()
{
ApiKey = Constants.ApiKey
});
}
- With DI Container
if you want use dependency injection you can register NeshanApiClient as INeshanApiClient.
for example if you use this in Asp.net Core you registerd as typed client like below
services.AddHttpClient<INeshanApiService, NeshanApiService>();
Client has 8 method for 7 api:
- Direction & DirectionWithOutTraffic methods are for Routing API (Doc link)
- LocationBasedSearch method is for Search API (Doc link)
- TravelingSalesmanProblem method is for Traveling Salesman Problem API (Doc link)
- ReverseGeocoding method is for Reverse Geocoding API (Doc link)
- Geocoding method is for Geocoding API (Doc link)
- DistanceMatrix method is for Distance Matrix API ( Doc link)
- MapMatching method is for Map Matching API (Doc link)
There are 2 types of Exception in this library.
- Neshan Api Error
these exceptions are neshan api error such as 470(CoordinateParseError) status code. when response status code set 470, NeshanCoordinateParseException will rise.
Exceptions:
- 470: NeshanCoordinateParseException
- 480: NeshanKeyNotFoundException
- 481: NeshanLimitExceededException
- 482: NeshanRateExceededException
- 483: NeshanApiKeyTypeErrorException
- 484: NeshanApiWhiteListErrorException
- 485: NeshanApiServiceListErrorException
- Internal Exceptions
these exceptions are rise when response status code are 200 but a error happened.
Exceptions:
- NeshanNoResultException: this is happened in Geocoding API
- NeshanNoRouteFoundException: this is happened in Routing API