what3words.dotnet.wrapper
4.1.0
dotnet add package what3words.dotnet.wrapper --version 4.1.0
NuGet\Install-Package what3words.dotnet.wrapper -Version 4.1.0
<PackageReference Include="what3words.dotnet.wrapper" Version="4.1.0" />
paket add what3words.dotnet.wrapper --version 4.1.0
#r "nuget: what3words.dotnet.wrapper, 4.1.0"
// Install what3words.dotnet.wrapper as a Cake Addin #addin nuget:?package=what3words.dotnet.wrapper&version=4.1.0 // Install what3words.dotnet.wrapper as a Cake Tool #tool nuget:?package=what3words.dotnet.wrapper&version=4.1.0
w3w-dotnet-wrapper
An .NET library to use the what3words v3 API.
API methods are grouped into a single service object which can be centrally managed by a What3WordsV3 instance. It will act as a factory for all of the API endpoints and will automatically initialize them with your API key.
Installation
The artifact is available through NuGet Package
Documentation
See the what3words public API documentation
Setup
To obtain an API key, please visit https://what3words.com/select-plan and sign up for an account.
var wrapper = new What3WordsV3("YOUR_API_KEY_HERE");
If you run our Enterprise Suite API Server yourself, you may specify the URL to your own server like so:
var wrapper = new What3Words("YOUR_API_KEY_HERE", "https://api.yourserver.com")
Usage
- ConvertTo3WA() - Convert a coordinate (latitude and longitude) to a 3 word address:
var result = await wrapper.ConvertTo3WA(new Coordinates(51.222011, 0.152311)).RequestAsync();
- ConvertToCoordinates() - Convert a 3 word address to a coordinate (latitude and longitude):
var result = await wrapper.ConvertToCoordinates("filled.count.soap").RequestAsync();
- Autosuggest() - AutoSuggest can take a slightly incorrect 3 word address, and suggest a list of valid 3 word addresses. For more autosuggest proprieties similar to focus below go to our documentation
var result = await wrapper.Autosuggest("index.home.r", new AutosuggestOptions().SetFocus(51.502,-0.12345)).RequestAsync();
- GridSection() - Returns a section of the 3m x 3m what3words grid for a bounding box (Coordinats SW, Coordinates NE).
var result = await wrapper.GridSection(new Coordinates(51.222011, 0.152311), new Coordinates(51.222609, 0.152898)).RequestAsync();
- AvailableLanguages() - Retrieves a list all available 3 word address languages.
var result = await wrapper.AvailableLanguages().RequestAsync();
- IsPossible3wa() - This method takes a string as a parameter and returns whether the string is in the format of a 3WA (eg "filled.count.soap"). Return type is boolean.
⚠️ NOTE: Does not check if it is an actual existing 3WA.
var result = wrapper.IsPossible3wa("filled.count.so"); // true
- FindPossible3wa() - This method takes a string as a parameter and searches the string for any possible instances of a 3WA - e.g. "leave in my porch at word.word.word." Likely to be the main method that is called on the delivery notes. Returns an array of matched items. Returns an empty array if no matches are found.
⚠️ NOTE: Does not check if it is an actual existing 3WA.
var result = wrapper.FindPossible3wa("from index.home.raft to filled.count.soap"); // IEnumerable<string>[ "index.home.raft", "filled.count.soap"]
- IsValid3wa() - This method takes a string as a parameter and first passes it through the W3W regex filter (akin to calling isPossible3wa() on the string) and then calls the W3W api to verify it is a real 3WA.
var result = wrapper.IsValid3wa("filled.count.soap"); // true
Tests
To run the tests, you need to provide the following environment variables:
W3W_API_KEY
- A valid API Key (with autosuggest with coordinates enabled - otherwise tests related tov3/autosuggest-with-endpoint
will fail)W3W_API_ENDPOINT
- (optional) You can override the default endpoint which is https://api.what3words.com (perhaps a self hosted or a local instance of the what3words api).
dotnet test what3words.dotnet.wrapper.utests/what3words.dotnet.wrapper.utests.csproj
Test run for /w3w-dotnet-wrapper/what3words.dotnet.wrapper.utests/bin/Debug/net5.0/what3words.dotnet.wrapper.utests.dll(.NETCoreApp,Version=v5.0)
Microsoft (R) Test Execution Command Line Tool Version 16.11.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Test Run Successful.
Total tests: 42
Passed: 42
Total time: 7.0222 Seconds
Changes
v4.1.0
- chore: removed Refit dependency
v4.0.0
- breaking change: moved
AutosuggestInputType
andRequest<T>
towhat3words.dotnet.wrapper.request
namespace
v3.1.1
- fix: revert Refit v6.0.24
v3.1.0
- feat: validation helper methods
v3.0.5
- fix: updated Line class visibility
v3.0.4
- fix: culture variant on coordinates double to URL
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.1.0 | 336 | 12/2/2024 |
4.0.0 | 2,274 | 11/4/2024 |
3.1.1 | 1,998 | 9/23/2024 |
3.1.0 | 8,924 | 7/8/2024 |
3.0.5 | 23,110 | 1/23/2023 |
3.0.4 | 19,487 | 5/10/2021 |
3.0.4-beta | 321 | 5/4/2021 |
3.0.4-alpha | 241 | 3/24/2021 |
3.0.3 | 361 | 3/18/2021 |
3.0.2 | 371 | 3/16/2021 |
3.0.1 | 336 | 3/9/2021 |
3.0.0 | 387 | 3/9/2021 |
1.0.0 | 345 | 3/8/2021 |
1.0.0-beta | 207 | 3/2/2021 |
1.0.0-alpha | 212 | 3/2/2021 |