LocationIQ provides flexible enterprise-grade location based solutions. We work with developers, startups and enterprises worldwide serving billions of requests everyday. This page provides an overview of the technical aspects of our API and will help you get started.
This C# SDK is automatically generated by the OpenAPI Generator project:
- API version: 1.1.0
- SDK version: 1.0.0
- Build package: org.openapitools.codegen.languages.CSharpClientCodegen
- .NET 4.0 or later
- Windows Phone 7.1 (Mango)
- RestSharp - 105.1.0 or later
- Json.NET - 7.0.0 or later
- JsonSubTypes - 1.2.0 or later
The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:
Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742
Run the following command to generate the DLL
- [Mac/Linux]
/bin/sh build.sh
- [Windows]
build.bat
Then include the DLL (under the bin
folder) in the C# project, and use the namespaces:
using locationiq.Api;
using locationiq.Client;
using locationiq.Model;
A .nuspec
is included with the project. You can follow the Nuget quickstart to create and publish packages.
This .nuspec
uses placeholders from the .csproj
, so build the .csproj
directly:
nuget pack -Build -OutputDirectory out locationiq.csproj
Then, publish to a local feed or other host and consume the new package via Nuget as usual.
using System.Collections.Generic;
using System.Diagnostics;
using locationiq.Api;
using locationiq.Client;
using locationiq.Model;
namespace Example
{
public class Example
{
public static void Main()
{
Configuration.Default.BasePath = "https://eu1.locationiq.com/v1";
// Configure API key authorization: key
Configuration.Default.ApiKey.Add("key", "YOUR_API_KEY");
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// Configuration.Default.ApiKeyPrefix.Add("key", "Bearer");
var apiInstance = new AutocompleteApi(Configuration.Default);
var q = "Empire state"; // string | Address to geocode
var normalizecity = 1; // int | For responses with no city value in the address section, the next available element in this order - city_district, locality, town, borough, municipality, village, hamlet, quarter, neighbourhood - from the address section will be normalized to city. Defaults to 1 for SDKs.
var limit = 10; // int | Limit the number of returned results. Default is 10. (optional) (default to 10)
var viewbox = "-132.84908,47.69382,-70.44674,30.82531"; // string | The preferred area to find search results. To restrict results to those within the viewbox, use along with the bounded option. Tuple of 4 floats. Any two corner points of the box - `max_lon,max_lat,min_lon,min_lat` or `min_lon,min_lat,max_lon,max_lat` - are accepted in any order as long as they span a real box. (optional)
var bounded = 1; // int | Restrict the results to only items contained with the viewbox (optional)
var countrycodes = "us"; // string | Limit search to a list of countries. (optional)
var acceptLanguage = "en"; // string | Preferred language order for showing search results, overrides the value specified in the Accept-Language HTTP header. Defaults to en. To use native language for the response when available, use accept-language=native (optional)
var tag = "place"; // string | Restricts the autocomplete search results to elements of specific OSM class and type. Example - To restrict results to only class place and type city: tag=place:city, To restrict the results to all of OSM class place: tag=place (optional)
try
{
List<Object> result = apiInstance.Autocomplete(q, normalizecity, limit, viewbox, bounded, countrycodes, acceptLanguage, tag);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling AutocompleteApi.Autocomplete: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}
All URIs are relative to https://eu1.locationiq.com/v1
Class | Method | HTTP request | Description |
---|---|---|---|
AutocompleteApi | Autocomplete | GET /autocomplete.php | |
BalanceApi | Balance | GET /balance.php | |
DirectionsApi | Directions | GET /directions/driving/{coordinates} | Directions Service |
MatchingApi | Matching | GET /matching/driving/{coordinates} | Matching Service |
MatrixApi | Matrix | GET /matrix/driving/{coordinates} | Matrix Service |
NearestApi | Nearest | GET /nearest/driving/{coordinates} | Nearest Service |
ReverseApi | Reverse | GET /reverse.php | Reverse Geocoding |
SearchApi | Search | GET /search.php | Forward Geocoding |
- Model.Address
- Model.Balance
- Model.Daybalance
- Model.DirectionsDirections
- Model.DirectionsDirectionsRoutes
- Model.DirectionsMatching
- Model.DirectionsMatrix
- Model.DirectionsMatrixSources
- Model.DirectionsNearest
- Model.DirectionsNearestWaypoints
- Model.Error
- Model.Location
- Model.Matchquality
- Model.Namedetails
-
Type: API key
-
API key parameter name: key
-
Location: URL query string