# what3words developer documentation: API & SDK Reference
> Reference for the what3words API: the Cloud REST API, API wrappers for each language, error codes, the Partner API, the Playground and the regular expressions for 3 word addresses.
Every page in this section, in menu order, as Markdown. Section page: https://developer.what3words.com/docs/api-sdk-reference.md. All sections: https://developer.what3words.com/llms.txt
---
# Android
Getting started with the what3words Android API wrapper.
Topics: Android, Mobile App, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/android
Updated: 2026-11-27
### Step by step
> #### If you are migrating from version 3.x of the Android API Wrapper library, please refer to the [Migration Guide from Version 3.x to 4.x](https://developer.what3words.com/tutorial/migrating-android-api-wrapper-from-version-3-x-to-4-x) for detailed instructions.
The Android API wrapper helps developers easily integrate the [what3words API](https://docs.what3words.com/api/v3/) into their Android applications, avoiding the complexity of managing low-level API calls.
The what3words API allows conversion between what3words addresses (e.g., ///index.home.raft) and coordinates (e.g., -0.203586, 51.521251). It features powerful autosuggest functions to validate and autocorrect user input, restrict suggestions to specific areas, request sections of the what3words grid as GeoJSON, and list all supported languages. Advanced users can also post-process voice output with autosuggest.
All coordinates are in latitude, longitude pairs using the WGS-84 standard, with latitudes ranging from -90 to 90.
Full sample app for the wrapper can be found in our Github repo
[Android Sample Apps](https://github.com/what3words/w3w-android-samples)
## 1. Get an API Key
You will need a what3words API key to complete this tutorial. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
The library is available through [Maven Central](https://search.maven.org/search?q=g:com.what3words). Please add the following to your `gradle.build:`
**Android**
```java
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("com.what3words:w3w-android-wrapper:$latest_version")
}
```
## 3. Setup
#### Android Manifest
Add to `AndroidManifest.xml`:
**Android**
```java
```
## 4. Usage
This step-by-step guide demonstrates the usage of the new Android API Wrapper library using Kotlin Coroutines. For a cleaner architecture or a Java example, refer to the [sample app](https://github.com/what3words/w3w-android-samples/tree/main/wrappers-sample).
We’ve restructured What3WordsV3 into two distinct classes, each serving specific functions:
1. **W3WApiTextDataSource**: Handles text-based tasks like address searching and conversions.
2. **W3WApiVoiceDataSource**: Specialises in voice-based address suggestions.
## 5. W3WApiTextDataSource
The `W3WApiTextDataSource` class facilitates the conversion of coordinates to what3words addresses and vice versa, as well as providing suggestions for slightly incomplete what3words addresses.
Create an instance of W3WApiTextDataSource via the factory method:
**Android**
```kotlin
val textDataSource = W3WApiTextDataSource.create(context, "YOUR_API_KEY")
```
If you are running your own Enterprise Suite API Server, specify the URL to your server:
**Android**
```kotlin
val textDataSource = W3WApiTextDataSource.create(context, "YOUR_API_KEY", "YOUR_SERVER_ENPOINT")
```
### Convert Coordinates to what3words Address
This function converts coordinates (expressed as latitude and longitude) to a what3words address.
More information about `convertTo3wa`, including returned results, is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (lat:`51.222011`, long: `0.152311`):
**Android**
```kotlin
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
...
val coordinates = W3WCoordinates("51.222011", "0.152311")
val language = W3WRFC5646Language.EN_GB
CoroutineScope(Dispatchers.IO).launch {
// Run to convert method in Dispatchers.IO
val result = textDataSource.convertTo3wa(coordinates, language)
//Switch to Dispatcher.Main to update your views with the results if needed
withContext(Dispatchers.Main) {
when (result) {
is W3WResult.Failure -> {
Log.e("MainActivity", "Error: ${result.message}")
}
is W3WResult.Success -> {
Log.d("MainActivity", "what3words address: ${result.value.address}")
}
}
}
}
}
}
```
### Convert what3words Address to Coordinates
This function converts a 3 word address to a position, expressed as coordinates of latitude and longitude.
This function takes the words parameter as a string of what3words address e.g.`filled.count.soap`
More information about `convertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the coordinates for `///filled.count.soap`:
**Android**
```kotlin
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
...
val w3wAddress = "filled.count.soap"
CoroutineScope(Dispatchers.IO).launch {
val result = textDataSource.convertToCoordinates(w3wAddress)
withContext(Dispatchers.Main) {
when (result) {
is W3WResult.Failure -> {
Log.e("MainActivity", "Error: ${result.message}")
}
is W3WResult.Success -> {
Log.d("MainActivity", "Coordinates: ${result.value.center.lat}, ${result.value.center.lng}")
}
}
}
}
}
}
```
### AutoSuggest
When presented with a what3words address that may be incorrectly entered, AutoSuggest returns a list of potential correct what3wordsaddresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural vs singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `focus` to user’s current location. This will make `autosuggest` return results which are closer to the user.
More information about `autosuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Example:** Basic AutoSuggest call
**Android**
```kotlin
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
...
val incompletedW3WAddress = "filled.count.so"
CoroutineScope(Dispatchers.IO).launch {
// Run to auto suggest method in Dispatchers.IO
val result = textDataSource.autosuggest(incompletedW3WAddress)
//Switch to Dispatcher.Main to update your views with the results if needed
withContext(Dispatchers.Main) {
when (result) {
is W3WResult.Failure -> {
Log.e("MainActivity", "Error: ${result.message}")
}
is W3WResult.Success -> {
if (result.value.isNotEmpty()) {
Log.d("MainActivity", "Suggestions: ${result.value.joinToString { it.w3wAddress.address }}")
} else {
Log.d("MainActivity", "No suggestions found")
}
}
}
}
}
}
}
```
### Get Grid Section
Grid Section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `gridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for (`51.222609, 0.152898`) in the south-west, and (`51.222011, 0.152311`) in the north-east:
**Android**
```kotlin
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
...
CoroutineScope(Dispatchers.IO).launch {
// Run to gridSection method in Dispatchers.IO
val result = w3WApiTextDataSource.gridSection(
W3WRectangle(W3WCoordinates(51.222609, 0.152898), W3WCoordinates(51.222011, 0.152311)))
//Switch to Dispatcher.Main to update your views with the results if needed
withContext(Dispatchers.Main) {
when (result) {
is W3WResult.Failure -> {
Log.e("MainActivity", "Error: ${result.message}")
}
is W3WResult.Success -> {
val gridSection = result.value
// Convert to GeoJSON
val geoJsonString = gridSection.toGeoJSON()
}
}
}
}
}
}
```
### Get Available Languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `availableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**Android**
```kotlin
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
...
CoroutineScope(Dispatchers.IO).launch {
// Run to availableLanguages method in Dispatchers.IO
val result = textDataSource.availableLanguages()
//Switch to Dispatcher.Main to update your views with the results if needed
withContext(Dispatchers.Main) {
when (result) {
is W3WResult.Failure -> {
Log.e("MainActivity", "Error: ${result.message}")
}
is W3WResult.Success -> {
result.value.forEach {
Log.d("MainActivity", "languageCode: ${it.code} - locale: ${it.locale}")
}
}
}
}
}
}
}
```
## 6. W3WApiVoiceDataSource
The `W3WApiVoiceDataSource` class allows searching for what3words addresses using voice input. Ensure you have a Voice API plan enabled in your account to use this feature.
Create a W3WApiVoiceDataSource Instance:
**Android**
```kotlin
val voiceDataSource = W3WApiVoiceDataSource("YOUR_API_KEY")
```
If you are running your own Enterprise Suite API Server, you can specify the URL to your server:
**Android**
```kotlin
val voiceDataSource = W3WApiVoiceDataSource("YOUR_API_KEY", "YOUR_SERVER_ENDPOINT")
```
Create a W3WMicrophone instance to handle voice recording:
**Android**
```kotlin
val microphone = W3WMicrophone()
```
You can set up callbacks to receive information about the recording progress:
**Android**
```kotlin
microphone.setEventsListener(object : W3WAudioStream.EventsListener {
override fun onVolumeChange(volume: Float) {
}
override fun onError(error: W3WError) {
}
override fun onAudioStreamStateChange(state: W3WAudioStreamState) {
}
})
```
### Perform Voice AutoSuggest
The Voice API AutoSuggest allows the user to say what3words and using speech recognition technology displays what3words address suggestions to the user.
Before enabling Voice AutoSuggest you will need to add a Voice API plan in [your account](https://accounts.what3words.com/billing).
For a full working example with voice and `AUDIO_RECORD` permission, request check our [sample app](https://github.com/what3words/w3w-android-samples/tree/main/wrappers-sample).
**Note:** Please bear in mind that the Android Emulator cannot record audio. Therefore, you will need to test on a real device that can record.
**Android**
```kotlin
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
...
val voiceLanguage = W3WRFC5646Language.EN_GB
CoroutineScope(Dispatchers.IO).launch {
// Perform the Voice AutoSuggest in Dispatchers.IO
voiceDataSource.autosuggest(
microphone,
voiceLanguage,
null, // W3WAutosuggestOptions
null, // onSpeechDetected
) { result ->
//Switch to Dispatcher.Main to update your views with the results if needed
withContext(Dispatchers.IO) {
is W3WResult.Failure -> {
Log.e("MainActivity", "Error: ${result.message}")
}
is W3WResult.Success -> {
if (result.value.isNotEmpty()) {
Log.d("MainActivity", "Suggestions: ${result.value.joinToString { it.w3wAddress.address }}")
} else {
Log.d("MainActivity", "No suggestions found")
}
}
}
}
}
}
}
```
## 7. Using AutosuggestHelper Class
### Add what3words AutoSuggest to an existing text field
Add the API and helper wherever you make your class variables and be sure to use your [API key](https://what3words.com/select-plan):
**Android**
```kotlin
val dataSource = W3WApiTextDataSource.create(context, "YOUR_API_KEY_HERE")
val autosuggestOptions = W3WAutosuggestOptions.Builder().
.focus(...)
.clipToCountry(...)
// others options as well
.build()
val autosuggestHelper = AutosuggestHelper(dataSource).options(autosuggestOptions)
```
Next step is to use a `TextWatcher` (or `doOnTextChanged EditText` extension) and let **AutoSuggestHelper** know about the changed text and add what3words suggestion data to your existing RecyclerView/Adapter. (check sample for complete working example with [custom data model and RecyclerView adapter](https://github.com/what3words/w3w-android-wrapper/blob/master/sample-multi-autosuggest-providers/src/main/java/com/what3words/sample_multi_autosuggest_providers/SuggestionsAdapter.kt) to show different autosuggest sources and [EditText and RecyclerView](https://github.com/what3words/w3w-android-wrapper/blob/master/sample-multi-autosuggest-providers/src/main/java/com/what3words/sample_multi_autosuggest_providers/MainActivity.kt) setup.
**Android**
```java
editText.doOnTextChanged { text, _, _, _ ->
// update options in case of new clippings applying/changing dynamically i.e: Location.
autosuggestHelper.options(autosuggestOptions).update(
text.toString(),
onSuccessListener = { suggestionResults ->
suggestionResults.forEach { suggestion ->
//Add suggestion to existing RecyclerView adapter
list.add(suggestion)
Log.i("MainActivity", suggestion.w3wAddress.address)
}
//notify adapter that there's changes on the data.
adapter.notifyDataSetChanged()
},
onFailureListener = {
//log any errors returned by what3words API.
Log.e("MainActivity", it.message)
}
)
}
```
### Get the full what3words address once the user has selected a row
When user selects a row from the RecyclerView `*autosuggestHelper.selected()*` or `*autosuggestHelper.selectedWithCoordinates()*` should be called to retrieve the full what3words address with or without coordinates.
**Note:** that `selectedWithCoordinates()` will convert the what3words address to a lat/lng which will count against your plan’s quota.
**Android**
```java
autosuggestHelper.selectedWithCoordinates(
query.text.toString(),
selectedSuggestion,
onSuccessListener = { suggestion ->
Log.d("MainActivity", "suggestion selected from what3words: ${suggesstion.w3wAddress.address}, lat=${suggestion.w3wAddress.center?.lat} lng=${suggestion.w3wAddress.center?.lng}")
},
onFailureListener = {
Log.e("MainActivity", it.message)
}
)
```
## 8. RegEx Functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `isPossible3wa` – Match what3words address format;
- `isValid3wa` – Verify a what3words address with the API;
### isPossible3wa
Our API wrapper RegEx function “`isPossible3wa`” can be used used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `isValid3wa` to verify validity.
**Android**
```java
com.what3words.javawrapper.What3WordsV3.isPossible3wa("filled.count.soap") returns true
com.what3words.javawrapper.What3WordsV3.isPossible3wa("not a 3wa") returns false
com.what3words.javawrapper.What3WordsV3.isPossible3wa("not.3wa address") returns false
```
### isValid3wa
Our API wrapper RegEx function “`isValid3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**Android**
```kotlin
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
...
CoroutineScope(Dispatchers.IO).launch {
// Run to gridSection method in Dispatchers.IO
val result = w3WApiTextDataSource.isValid3wa("filled.count.soap")
//Switch to Dispatcher.Main to update your views with the results if needed
withContext(Dispatchers.Main) {
when (result) {
is W3WResult.Failure -> {
Log.e("MainActivity", "Error: ${result.message}")
}
is W3WResult.Success -> {
Log.d("MainActivity", "isValid: ${result.value}")
}
}
}
}
}
}
```
## 9. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
---
# Migrating Android API Wrapper from version 3.x. to 4.x
This guide helps developers transition from version 3.x to 4.x with clear examples and detailed references.
Topics: Android, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/migrating-android-api-wrapper-from-version-3-x-to-4-x
Updated: 2026-11-27
In version 4.0, the Android API Wrapper library changed significantly. This guide will help you gradually adapt your existing code to the new wrapper.
**Note**:
- For users still using version 3.x, you can access the legacy Android tutorial [here](https://developer.what3words.com/tutorial/legacy-android).
- For users using version 4.x, you can access the latest Android tutorial [here](https://developer.what3words.com/tutorial/android).
## 1. Introduction to the Core Library
The core library establishes essential models and interfaces that maintain consistency across various other libraries. Significant changes have been made by substituting existing models with those from the core library. It is imperative to update your code accordingly to utilise these new models.
**Android v4 Tutorial**: For a comprehensive guide on using the latest version 4.x, see its tutorial [here](https://developer.what3words.com/tutorial/android).
### Model Replacements
| Android v3 models | Android v4 models |
| --- | --- |
| com.what3words.javawrapper.response.SuggestionWithCoordinates | com.what3words.core.types.domain.W3WSuggestion |
| com.what3words.javawrapper.request.AutosuggestOptions | com.what3words.core.types.options.W3WAutosuggestOptions |
| com.what3words.javawrapper.response.Coordinates | com.what3words.core.types.geometry.W3WCoordinates |
| com.what3words.javawrapper.response.Square | com.what3words.core.types.geometry.W3WRectangle |
| com.what3words.core.domain.language.W3WLanguage | com.what3words.core.types.language.W3WLanguage |
| com.what3words.javawrapper.request.BoundingBox | com.what3words.core.types.geometry.W3WRectangle |
| com.what3words.androidwrapper.voice.Microphone | com.what3words.core.datasource.voice.audiostream.W3WMicrophone |
## 2. Transition to W3WApiTextDataSource and W3WApiVoiceDataSource
The Android API Wrapper version 3 What3WordsV3 has been restructured into two distinct classes:
- **W3WApiTextDataSource**: Handles text-based tasks like address searching and conversions.
- **W3WApiVoiceDataSource**: Specialises in voice-based address suggestions.
For more information on version 4.x usage, see the latest tutorial [here](https://developer.what3words.com/tutorial/android).
## 3. Method Changes List
### convertToCoordinates
Converts a what3words address to coordinates.
**Android v3**
```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.convertToCoordinates(words).execute()
```
**Parameters**:
- `words`: String (the what3words address to convert)
**Return**: ConvertToCoordinates (coordinates corresponding to the what3words address)
**Android v4**
```kotlin
val textDataSource = W3WApiTextDataSource.create(context, API_KEY)
val result = textDataSource.convertToCoordinates(words) // Must run on background thread
```
**Parameters**:
- `words`: String (the what3words address to convert)
**Return**: W3WResult (result containing the coordinates)
For more details and instructions, see [Convert to Coordinates Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#converttocoordinates-example).
### convertTo3wa
Converts coordinates to a what3words address.
**Android v3**
```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.convertTo3wa(coordinates).execute()
```
**Parameters**:
- `coordinates`: Coordinates (latitude and longitude to convert)
**Return**: ConvertTo3WA (the corresponding what3words address)
**Android v4**
```kotlin
val textDataSource = W3WApiTextDataSource.create(context, API_KEY)
val result = textDataSource.convertTo3wa(coordinates, language) // Must run on background thread
```
**Parameters**:
- `coordinates`: W3WCoordinates (latitude and longitude to convert)
- `language`: W3WLanguage (the language for the what3words address)
**Return**: W3WResult (result containing the what3words address)
For more details and instructions, see [Convert to what3words Address Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#converttocoordinates-example).
### AutoSuggest
Provides address suggestions based on a partial or full what3words address.
**Android v3**
```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.autosuggest(word).execute()
```
**Parameters**:
- `word`: String (the partial or full what3words address to get suggestions for)
**Return**: Autosuggest (list of suggested addresses)
**Android v4**
```kotlin
val textDataSource = W3WApiTextDataSource.create(context, API_KEY)
val result = textDataSource.autosuggest(word, options) // Must run on background thread
```
**Parameters**:
- `word`: String (the partial or full what3words address to get suggestions for)
- `options`: W3WAutosuggestOptions? (optional parameters to refine suggestions)
**Return**: W3WResult> (result containing the list of suggestions)
For more details and instructions, see [Autosuggest Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#autosuggest-example).
### availableLanguages
Fetches the list of available languages for what3words addresses.
**Android v3**
```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.availableLanguages().execute()
```
**Return**: AvailableLanguages (set of supported languages)
**Android v4**
```kotlin
val textDataSource = W3WApiTextDataSource.create(context, API_KEY)
val result = textDataSource.availableLanguages() // Must run on background thread
```
**Return**: W3WResult> (result containing the set of supported languages)
For more details and instructions, see [Get Available Languages Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#availablelanguages-example).
### gridSection
Retrieves a section of the what3words address grid for a specified bounding box.
**Android v3**
```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.gridSection(boudingBox).execute()
```
**Parameters**:
- `boundingBox`: BoundingBox (the area to get the grid section for)
**Return**: GridSection (section of the grid)
**Android v4**
```kotlin
val textDataSource = W3WApiTextDataSource.create(context, API_KEY)
val result = textDataSource.gridSection(boundingBox) // Must run on background thread
```
- **Parameters**:
- `boundingBox`: W3WRectangle (the area to get the grid section for)
- **Return**: W3WResult (result containing the section of the grid)
For more details and instructions, see [Grid Section Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#gridsection-example).
### Voice AutoSuggest
Provides address suggestions based on voice input.
**Android v3**
```kotlin
val wrapper = What3WordsV3(API_KEY, activityContext)
val result = wrapper.autosuggest(microphone, voiceLanguage)
.onSuggstions { suggestions ->
// Handle the suggestions
}
.onError { error ->
// Handle the error
}
```
**Parameters**:
- `microphone`: Microphone (the audio input device)
- `voiceLanguage`: String (the language for voice recognition)
**Return**:
- `suggestions`: List (list of suggested addresses)
- `error`: APIResponse.What3WordsError (error information)
**Android v4**
```kotlin
val voiceDataSource = W3WApiVoiceDataSource.create(API_KEY)
val result = voiceDataSource.autosuggest(
audioStream,
voiceLanguage,
options,
onSpeechDetected,
) { result ->
// Handle result
}
```
**Parameters**:
- `input`: W3WAudioStream (the audio input stream)
- `voiceLanguage`: W3WLanguage (the language for voice recognition)
- `options`: W3WAutosuggestOptions? (optional parameters to refine suggestions)
- `onSpeechDetected`: ((String) -> Unit)? (callback for speech detection)
**Return**:
- `result`: W3WResult> (result containing the list of suggestions)
For more details and instructions, see [Voice Autosuggest Example](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#w3wapivoicedatasource).
## 4. AutosuggestHelper
In the previous version, AutosuggestHelper relied on the Android API Wrapper v3 (What3WordsV3). Now, it has transitioned to using `W3WApiTextDataSource`.
**Android v3**
```kotlin
val what3words = What3WordsV3("YOUR_API_KEY_HERE", this)
val autosuggestHelper = AutosuggestHelper(what3words)
```
**Android v4**
```kotlin
val dataSource = W3WApiTextDataSource.create(context, "YOUR_API_KEY_HERE")
val autosuggestHelper = AutosuggestHelper(dataSource)
```
For more details and instructions, see [AutoSuggestHelper](https://github.com/what3words/w3w-android-wrapper?tab=readme-ov-file#using-autosuggesthelper-class).
---
# C++
The C++ API wrapper provides a synchronous, type-safe way to use the [what3words Public API](https://developer.what3words.com/public-api/docs) from C++17 applications, without managing HTTPS requests or response parsing yourself.
Topics: C++, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/cpp
Updated: 2026-11-27
This wrapper calls the hosted Public API. It is separate from the offline C++ Core SDK and does not require an Enterprise Suite installation.
A full example of how to integrate the what3words C++ wrapper is available in our
[C++ Github repository](https://github.com/what3words/w3w-cpp-wrapper)
## 1. Requirements
Use a supported C++17 compiler and CMake to add the wrapper to your application.
| | |
| --- | --- |
| C++17 | MSVC 2019+, GCC 9+, Clang 10+, or supported Apple Clang |
| CMake | CMake 3.20 or newer |
| Git | Required for FetchContent and source builds |
| Dependencies | libcurl and nlohmann/json |
CMake can fetch missing dependencies for FetchContent and standalone source builds. The repository also provides a `vcpkg.json` manifest. An installable CMake package requires an installed libcurl. The fully system-resolved install recipe below disables dependency fetching, so it also requires nlohmann/json as an installed CMake dependency.
## 2. Installation
### CMake FetchContent
Add the wrapper directly to an application with CMake `FetchContent`:
**CMake**
```cmake
include(FetchContent)
FetchContent_Declare(
what3words_api
GIT_REPOSITORY https://github.com/what3words/w3w-cpp-wrapper
GIT_TAG v1.0.0
)
FetchContent_MakeAvailable(what3words_api)
target_compile_features(your-target PRIVATE cxx_std_17)
target_link_libraries(your-target PRIVATE what3words::api)
```
Use an immutable released version so that later wrapper changes cannot break an existing application build. The wrapper also exports its C++17 requirement, but declaring the application target’s requirement makes the project contract explicit.
### Build the wrapper source
Clone the released source before using the standalone build commands:
**Shell**
```shellscript
git clone https://github.com/what3words/w3w-cpp-wrapper what3words-api-cpp
cd what3words-api-cpp
```
Static libraries are built by default. Add `-DBUILD_SHARED_LIBS=ON` for a shared library. On Windows, place the wrapper and libcurl DLLs beside the consuming executable or on `PATH`.
#### Windows with vcpkg
Configure with the vcpkg toolchain so that the manifest supplies libcurl and nlohmann/json:
**PowerShell**
```powershell
cmake -S . -B build `
-A x64 `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" `
-DW3W_BUILD_TESTS=OFF `
-DW3W_BUILD_EXAMPLES=ON
cmake --build build --config Release
```
#### Linux and macOS
Use GCC, Clang or Apple Clang with a single-configuration CMake build. On Linux, install the distribution’s TLS development package first if CMake will fetch libcurl.
**Shell**
```shellscript
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DW3W_BUILD_TESTS=OFF \
-DW3W_BUILD_EXAMPLES=ON
cmake --build build
```
### Install and consume the CMake package
Only fetching libcurl disables installation; fetching nlohmann/json alone is compatible with the install rules. The fully system-resolved recipe below is for Linux and macOS. It disables dependency fetching, chooses an installation prefix, then installs the wrapper:
**Shell**
```shellscript
cmake -S . -B build-install \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/your/prefix \
-DW3W_FETCH_DEPENDENCIES=OFF \
-DW3W_BUILD_TESTS=OFF \
-DW3W_BUILD_EXAMPLES=OFF
cmake --build build-install
cmake --install build-install
```
On Windows, use the vcpkg toolchain from the earlier build and pass the Release configuration to both build and install:
**PowerShell**
```powershell
cmake -S . -B build-install `
-A x64 `
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" `
-DCMAKE_INSTALL_PREFIX="$PWD/stage" `
-DW3W_FETCH_DEPENDENCIES=OFF `
-DW3W_BUILD_TESTS=OFF `
-DW3W_BUILD_EXAMPLES=OFF
cmake --build build-install --config Release
cmake --install build-install --config Release
```
The consuming build must also be able to resolve CURL. Add the installed wrapper to the application with:
**CMake**
```cmake
find_package(what3words-api 1.0 CONFIG REQUIRED)
target_compile_features(your-target PRIVATE cxx_std_17)
target_link_libraries(your-target PRIVATE what3words::api)
```
When using a custom installation prefix, configure the consuming application with `-DCMAKE_PREFIX_PATH=/your/prefix` on Linux/macOS or `-DCMAKE_PREFIX_PATH="$PWD/stage"` on Windows. Alternatively, set `what3words-api_DIR` to the directory containing `what3words-api-config.cmake`. If libcurl is fetched during a standalone build, install rules are disabled because the resulting dependency graph cannot be exported as a relocatable package. `FetchContent` and `add_subdirectory` consumption continue to work normally.
## 3. Setup an API key
Create an API key through the [what3words developer portal](https://accounts.what3words.com/). In the examples below, replace `"your API key here"` with your API key.
> [!WARNING]
> **Keep API keys out of source control.** The inline value keeps the examples concise. Do not commit or distribute source containing a real production key. The wrapper sends the key in the X-Api-Key header and prevents additional headers from replacing it.
## 4. Quick start
The following complete program creates a client and converts a what3words address to latitude and longitude:
**C++**
```cpp
#include
#include
#include
#include
#include
int main() {
try {
const what3words::Client client("your API key here");
const auto result =
client.convert_to_coordinates("filled.count.soap");
std::cout << std::fixed << std::setprecision(6)
<< result.coordinates.lat << ", "
<< result.coordinates.lng << '\n';
return 0;
} catch (const what3words::ApiError& error) {
std::cerr << error.code() << ": "
<< error.api_message() << '\n';
} catch (const what3words::Error& error) {
std::cerr << error.what() << '\n';
}
return 2;
}
```
Expected output:
> 51.520847, -0.195521
The remaining C++ fragments assume the configured `client` and standard-library headers established by Quick start. `` and `` are included in the complete setup because later timeout and GeoJSON fragments use them.
### Configure timeouts and client identity
Defaults are 5 seconds for connection and 10 seconds for a request. Set non-default values before constructing the client.
**C++**
```cpp
what3words::ClientConfig config;
config.api_key = "your API key here";
config.connect_timeout = std::chrono::seconds{3};
config.request_timeout = std::chrono::seconds{15};
config.user_agent = "your-application/1.0";
const what3words::Client client(config);
```
> [!NOTE]
> **Thread safety.** The default client can be called concurrently: configuration is immutable and each request uses its own libcurl easy handle.
## 5. API operations
### convert_to_3wa / convert_to_3wa_geojson
### Convert coordinates to a what3words address
Find the what3words address for `51.520847, -0.195521`:
**C++**
```cpp
const auto address = client.convert_to_3wa(
{51.520847, -0.195521},
what3words::ConvertTo3waOptions{}.language("en")
);
std::cout << "///" << address.words << '\n';
```
### convert_to_coordinates / convert_to_coordinates_geojson
### GeoJSON
Use the dedicated type-safe GeoJSON methods for conversions and grid sections. GeoJSON point coordinates are ordered as `[longitude, latitude]`:
**C++**
```cpp
const auto geojson =
client.convert_to_coordinates_geojson(
"filled.count.soap"
);
const auto& point = std::get(
geojson.features.front().geometry.coordinates
);
std::cout << point[1] << ", " << point[0] << '\n'; // latitude, longitude
```
### autosuggest / autosuggest_with_coordinates
### AutoSuggest with country clipping
Improve results by clipping suggestions to relevant countries using two-letter country codes:
**C++**
```cpp
const auto options =
what3words::AutosuggestOptions{}
.clip_to_countries({"GB", "DE"})
.number_of_results(3);
const auto response =
client.autosuggest("filled.count.so", options);
for (const auto& suggestion : response.suggestions) {
std::cout << "///" << suggestion.words << '\n';
}
```
### AutoSuggest with coordinates
Use `autosuggest_with_coordinates` when each suggestion also needs coordinates, its three-metre square and its map URL:
**C++**
```cpp
const auto options =
what3words::AutosuggestOptions{}
.clip_to_countries({"GB"})
.number_of_results(3);
const auto response =
client.autosuggest_with_coordinates(
"filled.count.so",
options
);
for (const auto& suggestion : response.suggestions) {
std::cout << "///" << suggestion.words << ": "
<< suggestion.coordinates.lat << ", "
<< suggestion.coordinates.lng << '\n';
}
```
### grid_section / grid_section_geojson
### Grid section
Retrieve the what3words grid lines for a bounding box that is no more than 4 km from corner to corner:
**C++**
```cpp
const what3words::BoundingBox bounds{
{52.207988, 0.116126}, // southwest
{52.208867, 0.117540} // northeast
};
const auto grid = client.grid_section(bounds);
for (const auto& line : grid.lines) {
std::cout << line.start.lat << ","
<< line.start.lng << " -> "
<< line.end.lat << ","
<< line.end.lng << '\n';
}
```
### available_languages
### Available languages
List each currently supported language using its code, English name and native name:
**C++**
```cpp
const auto response = client.available_languages();
for (const auto& language : response.languages) {
std::cout << language.code << " - "
<< language.name << " - "
<< language.native_name << '\n';
}
```
## 6. RegEx functions
These helpers can detect text that looks like a what3words address before making an API request:
**C++**
```cpp
const bool possible =
what3words::is_possible_3wa("///filled.count.soap");
const auto matches =
what3words::find_possible_3wa(
"Meet at filled.count.soap"
);
const bool looks_mistyped =
what3words::did_you_mean("filled count soap");
// Makes an AutoSuggest API request to verify the address
const bool valid =
client.is_valid_3wa("filled.count.soap");
std::cout << std::boolalpha
<< "Possible format: " << possible << '\n'
<< "Matches found: " << matches.size() << '\n'
<< "Looks mistyped: " << looks_mistyped << '\n'
<< "Valid address: " << valid << '\n';
```
> [!NOTE]
> **Format is not validity.** `is_possible_3wa` runs locally and checks only the text format. Use `is_valid_3wa` to verify that an address exists.
See [Detecting if text is in the format of a what3words address using RegEx](https://developer.what3words.com/tutorial/detecting-if-text-is-in-the-format-of-a-3-word-address) for the C++ expressions.
## 7. Error handling
The wrapper exposes specific error types for configuration, transport, API, HTTP and response parsing failures.
| Error | When it is used |
| --- | --- |
| InvalidArgumentError | Locally invalid coordinates, options or configuration |
| TransportError | DNS, connection, timeout or TLS failure |
| ApiError | A structured what3words API error with HTTP status, code and message |
| HttpError | A non-success HTTP response without a structured API error |
| ParseError | A successful response that does not match the expected contract |
**C++**
```cpp
try {
const auto result =
client.convert_to_coordinates("filled.count.soap");
std::cout << "///" << result.words << '\n';
} catch (const what3words::ApiError& error) {
std::cerr << error.status_code() << " "
<< error.code() << ": "
<< error.api_message() << '\n';
} catch (const what3words::TransportError& error) {
std::cerr << "Network error: "
<< error.what() << '\n';
} catch (const what3words::Error& error) {
std::cerr << error.what() << '\n';
}
```
Endpoint availability and quotas depend on the API plan associated with the key.
> [!NOTE]
> **HTTP 402 responses.** An HTTP 402 response can indicate that a feature is unavailable on the current plan or that a plan quota has been exceeded. A structured response is surfaced as `ApiError`.
---
# Dart
Getting started with the what3words Dart API wrapper.
Topics: Dart, Mobile App, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/dart
Updated: 2026-11-27
The Dart API wrapper (**now null safe**) is useful for Dart or [Flutter](https://developer.what3words.com/tutorial/flutter) developers who wish to seamlessly integrate the [what3words API](https://docs.what3words.com/api/v3/) into their Dart or Flutter applications, without the hassle of having to manage the low level API calls themselves.
A full example of how to integrate the what3words Dart wrapper is available in our
[Dart Github repository](https://github.com/what3words/w3w-dart-wrapper)
## 1. Get API key
You will need this API key for your installation. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
The artifact is available through [pub.dev](https://pub.dev/packages/what3words). Update your `pubspec.yaml` file with
**Dart**
```dart
dependencies:
what3words: 3.2.0
```
## 3. Setup
Import the `what3words` library
**Dart**
```dart
import 'package:what3words/what3words.dart';
```
## 4. Initialise
Instantiate an instance of What3WordsV3, from which all API requests can be made
**Dart**
```dart
var api = What3WordsV3('what3words-api-key');
```
In the case that you run our Enterprise Suite API Server yourself, you may specify the URL to your server like so:
**Dart**
```dart
var api = What3WordsV3.withEndpoint( 'what3words-api-key', 'https://api.yourserver.com');
```
## 5. Usage
### Convert to what3words address
This function converts coordinates (expressed as latitude and longitude) to a what3words address.
More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (`51.508344,0.12549900`):
**Dart**
```dart
var words = await api
.convertTo3wa(Coordinates(51.508344, -0.12549900))
.language('en')
.execute();
print('Words: ${words.data()?.toJson()}');
```
### Convert to coordinates
This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of a what3words `'table.book.chair'`
More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///filled.count.soap`:
**Dart**
```dart
var coordinates = await api
.convertToCoordinates('table.book.chair')
.execute();
print('Coordinates ${coordinates.data()?.toJson()}');
```
### AutoSuggest
When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `Focus` to user’s current location. This will make `AutoSuggest` return results which are closer to the user.
More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Code example** Simple basic call:
**Dart**
```dart
var autosuggest = await api
.autosuggest('fun.with.code')
.nResults(3)
.execute();
print('Autosuggest: ${autosuggest.data()?.toJson()}');
```
**Code example** AutoSuggest, clipping the results returned to the United Kingdom and Belgium:
**Dart**
```dart
var autosuggest = await api
.autosuggest('fun.with.code')
.clipToCountry(['gb', 'be'])
.execute();
print('Autosuggest: ${autosuggest.data()?.toJson()}');
```
**Code example** AutoSuggest, Focus on (`51.4243877,-0.34745`).
**Dart**
```dart
var autosuggest = await api
.autosuggest('fun.with.code')
.focus(Coordinates(51.4243877, -0.34745))
.execute();
print('Autosuggest: ${autosuggest.data()?.toJson()}');
```
**Code example** AutoSuggest, with Generic Voice input type.
**Dart**
```dart
var autosuggest = await api
.autosuggest('fun with code')
.input-type('generic-voice')
.language('en')
.execute();
print('Autosuggest: ${autosuggest.data()?.toJson()}');
```
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for `52.207988,0.116126`) in the south west, and `52.208867,0.117540` in the north east:
**Dart**
```dart
// Obtain a grid section within the provided bounding box
var gridSection = await api
.gridSection(Coordinates(51.515900, -0.212517), Coordinates(51.527649, -0.191746))
.execute();
print(gridSection.data()?.toJson());
```
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**Dart**
```dart
var languages = await api
.availableLanguages()
.execute();
print('Languages: ${languages.data()?.toJson()}');
```
### Handling errors
Success of failure of an API call can be determined through the use of the `isSuccessful()` function.
If it’s been determined that an API call was not successful, `code` and `message` values which represent the error, are accessible from through the `getError()` function.
**Dart**
```dart
var autosuggest = await api
.autosuggest('freshen.overlook.clo')
.clipToCountry(['fr', 'de'])
.execute();
if (autosuggest.isSuccessful()) {
...
} else {
var error = autosuggest.getError();
if (error == What3WordsError.BAD_CLIP_TO_COUNTRY) {
// Invalid country clip is provided
print('BadClipToCountry: ${error.message}');
}
}
```
## 6. RegEx Functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `isPossible3wa` – Match what3words address format;
- `isValid3wa` – Verify a what3words address with the API;
### isPossible3wa
Our API wrapper RegEx function “`isPossible3wa`” can be used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `isValid3wa` to verify validity.
**Dart**
```dart
void main() async {
// Replace 'what3words-api-key' with your actual API key
var api = What3WordsV3('what3words-api-key');
List addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"];
// Check if the addresses are possible what3words addresses
for (String address in addresses) {
bool isPossible = api.isPossible3wa(address);
print("Is '$address' a possible what3words address? $isPossible");
}
}
```
#### Expected Output
- isPossible3wa(“filled.count.soap”) returns `true`
- isPossible3wa(“not a 3wa”) returns `false`
- isPossible3wa(“not.3wa address”)returns `false`
**Dart**
```dart
void main() async {
// Replace 'what3words-api-key' with your actual API key
var api = What3WordsV3('what3words-api-key');
List texts = [
"Please leave by my porch at filled.count.soap",
"Please leave by my porch at filled.count.soap or deed.tulip.judge",
"Please leave by my porch at"
];
// Check each text for possible what3words addresses
for (String text in texts) {
List possibleAddresses = api.findPossible3wa(text);
print("Possible what3words addresses in '$text': $possibleAddresses");
}
}
```
### isValid3wa
Our API wrapper RegEx function “`isValid3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**Dart**
```dart
void main() async {
// Replace 'what3words-api-key' with your actual API key
var api = What3WordsV3('what3words-api-key');
List w3w_addresses = [
"filled.count.soap",
"filled.count.",
"coding.is.cool"
];
// Iterate over the list and check if each address is valid
for (String w3w_address in w3w_addresses) {
var response = await api.isValid3wa(w3w_address);
if (response.isSuccessful() && response.isValid == true) {
print("$w3w_address is a valid what3words address");
} else if (response.isSuccessful() && response.isValid == false) {
print("$w3w_address is an invalid what3words address");
} else {
print("isValid3wa error: ${response.error?.code} - ${response.error?.message}");
}
}
}
```
#### Expected Outputs
- isValid3wa(“filled.count.soap”) returns `True`
- isValid3wa(“filled.count.”) returns `False`
- isValid3wa(“coding.is.cool”) returns `False`
Also make sure to replace `` with your actual API key. These functionalities provide different levels of validation for what3words addresses, from simply identifying potential addresses to verifying their existence on Earth.
## 7. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
## 8. Full example
The example below takes the concepts described above, and turns some of them into a complete example. Here we take a partial 3 word address and pass it into AutoSuggest – clipping the results to consider only addresses in France, setting a focus of Paris, and returning a single result
We then take the result and convert the 3 word address to coordinates, and find the nearest place.
**Dart**
```dart
import 'package:what3words/what3words.dart';
void main() async {
// For all requests a what3words API key is needed
var api = What3WordsV3('what3words-api-key');
var autosuggest = await api
.autosuggest('freshen.overlook.clo')
.clipToCountry(['fr'])
.focus(Coordinates(48.856618, 2.3522411))
.nResults(1)
.execute();
if (autosuggest.isSuccessful()) {
var words = autosuggest.suggestions[0].words;
print(
'Top 3 word address match: ${words}',
);
var convertToCoordinates = await api.convertToCoordinates(words).execute();
if (convertToCoordinates.isSuccessful()) {
print(
'WGS84 Coordinates: ${convertToCoordinates.coordinates.lat}, ${convertToCoordinates.coordinates.lng}');
print(
'Nearest Place: ${convertToCoordinates.nearestPlace}',
);
} else {
var error = autosuggest.getError();
if (error == What3WordsError.INTERNAL_SERVER_ERROR) {
// Server Error
print('InternalServerError: ');
} else if (error == What3WordsError.NETWORK_ERROR) {
// Network Error
print('NetworkError: ${error.message}');
}
}
} else {
var error = autosuggest.getError();
if (error == What3WordsError.BAD_CLIP_TO_COUNTRY) {
// Invalid country clip is provided
print('BadClipToCountry: ${error.message}');
} else if (error == What3WordsError.BAD_FOCUS) {
// Invalid focus
print('BadFocus: ${error.message}');
} else if (error == What3WordsError.BAD_N_RESULTS) {
// Invalid number of results
print('BadNResults: ${error.message}');
} else if (error == What3WordsError.INTERNAL_SERVER_ERROR) {
// Server Error
print('InternalServerError: ${error.message}');
} else if (error == What3WordsError.NETWORK_ERROR) {
// Network Error
print('NetworkError: ${error.message}');
} else {
print('error: ${error.message}');
}
}
}
```
---
# Flutter
Getting started with the what3words Flutter API wrapper.
Topics: Dart, Flutter, Mobile App, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/flutter
Updated: 2026-11-27
The Flutter API wrapper is useful for [Dart](https://developer.what3words.com/tutorial/dart) or Flutter developers who wish to seamlessly integrate the [what3words API](https://docs.what3words.com/api/v3/) into their Dart or Flutter applications, without the hassle of having to manage the low level API calls themselves.
A full example of how to integrate the what3words Flutter wrapper is available in our
[Flutter Github repository](https://github.com/what3words/w3w-dart-wrapper/tree/master/example/flutter_what3words)
Also, a live sample of a Flutter application with Google Maps as a basemap is available in this **[FlutLab project](https://flutlab.io/editor/cebfba35-f9bd-4662-bc9d-bb7aa41bdd62)**.
## 1. Get API key
You will need this API key for your installation. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
The artifact is available through [pub.dev](https://pub.dev/packages/what3words). Update your `pubspec.yaml` file with
**Dart**
```dart
dependencies:
what3words: 3.1.0
```
## 3. Setup
Import the `what3words` library
**Dart**
```dart
import 'package:what3words/what3words.dart';
```
## 4. Initialise
Instantiate an instance of What3WordsV3, from which all API requests can be made.
**Dart**
```dart
var api = What3WordsV3('what3words-api-key');
```
In the case that you run our Enterprise Suite API Server yourself, you may specify the URL to your server like so:
**Dart**
```dart
var api = What3WordsV3.withEndpoint( 'what3words-api-key', 'https://api.yourserver.com');
```
## 5. Usage
### Convert to what3words address
This function converts coordinates (expressed as latitude and longitude) to a what3words address.
More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (`51.508344,0.12549900`):
**Dart**
```dart
var words = await api
.convertTo3wa(Coordinates(51.508344, -0.12549900))
.language('en')
.execute();
print('Words: ${words.data()?.toJson()}');
```
### Convert to coordinates
This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of a what3words `'table.book.chair'`
More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///filled.count.soap`:
**Dart**
```dart
var coordinates = await api
.convertToCoordinates('table.book.chair')
.execute();
print('Coordinates ${coordinates.data()?.toJson()}');
```
### AutoSuggest
When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `Focus` to user’s current location. This will make `AutoSuggest` return results which are closer to the user.
More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Code example** Simple basic call:
**Dart**
```dart
var autosuggest = await api
.autosuggest('fun.with.code')
.nResults(3)
.execute();
print('Autosuggest: ${autosuggest.data()?.toJson()}');
```
**Code example** AutoSuggest, clipping the results returned to the United Kingdom and Belgium:
**Dart**
```dart
var autosuggest = await api
.autosuggest('fun.with.code')
.clipToCountry(['gb', 'be'])
.execute();
print('Autosuggest: ${autosuggest.data()?.toJson()}');
```
**Code example** AutoSuggest, Focus on (`51.4243877,-0.34745`).
**Dart**
```dart
var autosuggest = await api
.autosuggest('fun.with.code')
.focus(Coordinates(51.4243877, -0.34745))
.execute();
print('Autosuggest: ${autosuggest.data()?.toJson()}');
```
**Code example** AutoSuggest, with Generic Voice input type.
**Dart**
```dart
var autosuggest = await api
.autosuggest('fun with code')
.input-type('generic-voice')
.language('en')
.execute();
print('Autosuggest: ${autosuggest.data()?.toJson()}');
```
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for `52.207988,0.116126`) in the south west, and `52.208867,0.117540` in the north east:
**Dart**
```dart
// Obtain a grid section within the provided bounding box
var gridSection = await api
.gridSection(Coordinates(51.515900, -0.212517), Coordinates(51.527649, -0.191746))
.execute();
print(gridSection.data()?.toJson());
```
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**Dart**
```dart
var languages = await api
.availableLanguages()
.execute();
print('Languages: ${languages.data()?.toJson()}');
```
### Handling errors
Success of failure of an API call can be determined through the use of the `isSuccessful()` function.
If it’s been determined that an API call was not successful, `code` and `message` values which represent the error, are accessible from through the `getError()` function.
**Dart**
```dart
var autosuggest = await api
.autosuggest('freshen.overlook.clo')
.clipToCountry(['fr', 'de'])
.execute();
if (autosuggest.isSuccessful()) {
...
} else {
var error = autosuggest.getError();
if (error == What3WordsError.BAD_CLIP_TO_COUNTRY) {
// Invalid country clip is provided
print('BadClipToCountry: ${error.message}');
}
}
```
## 6. RegEx Functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `isPossible3wa` – Match what3words address format;
- `isValid3wa` – Verify a what3words address with the API;
### isPossible3wa
Our API wrapper RegEx function “`isPossible3wa`” can be used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `isValid3wa` to verify validity.
**Dart**
```dart
void main() async {
// Replace 'what3words-api-key' with your actual API key
var api = What3WordsV3('what3words-api-key');
List addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"];
// Check if the addresses are possible what3words addresses
for (String address in addresses) {
bool isPossible = api.isPossible3wa(address);
print("Is '$address' a possible what3words address? $isPossible");
}
}
```
#### Expected Output
- isPossible3wa(“filled.count.soap”) returns `true`
- isPossible3wa(“not a 3wa”) returns `false`
- isPossible3wa(“not.3wa address”)returns `false`
### isValid3wa
Our API wrapper RegEx function “`isValid3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**Dart**
```dart
void main() async {
// Replace 'what3words-api-key' with your actual API key
var api = What3WordsV3('what3words-api-key');
List w3w_addresses = [
"filled.count.soap",
"filled.count.",
"coding.is.cool"
];
// Iterate over the list and check if each address is valid
for (String w3w_address in w3w_addresses) {
var response = await api.isValid3wa(w3w_address);
if (response.isSuccessful() && response.isValid == true) {
print("$w3w_address is a valid what3words address");
} else if (response.isSuccessful() && response.isValid == false) {
print("$w3w_address is an invalid what3words address");
} else {
print("isValid3wa error: ${response.error?.code} - ${response.error?.message}");
}
}
}
```
#### Expected Outputs
- isValid3wa(“filled.count.soap”) returns `True`
- isValid3wa(“filled.count.”) returns `False`
- isValid3wa(“coding.is.cool”) returns `False`
Also make sure to replace `` with your actual API key. These functionalities provide different levels of validation for what3words addresses, from simply identifying potential addresses to verifying their existence on Earth.
## 7. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
## 8. Full example
The example below is a simple Flutter application demonstrating a basic GUI application featuring a text box which accepts a what3words address, and a ‘Convert To Coordinates’ button which geocodes the what3words address provided, returning the WGS84 Coordinates back to screen.
**Dart**
```dart
import 'package:flutter/material.dart';
import 'package:what3words/what3words.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final appTitle = 'what3words';
return MaterialApp(
title: appTitle,
home: Scaffold(
appBar: AppBar(
title: Text(appTitle),
),
body: LocationForm(),
),
);
}
}
class LocationForm extends StatefulWidget {
@override
LocationFormState createState() {
return LocationFormState();
}
}
class LocationFormState extends State {
String twaHolder = '';
var api = What3WordsV3('what3words-api-key');
final _formKey = GlobalKey();
@override
Widget build(BuildContext context) {
var twaController = TextEditingController();
var twaInput = TextFormField(
controller: twaController,
decoration: InputDecoration(
hintText: "e.g. lock.spout.radar"
),
);
var convertToCoordsButton = ElevatedButton(
child: Text("Convert To Coordinates"),
onPressed: () async {
var location = await api.convertToCoordinates(twaController.text).execute();
setState(() {
if (location.isSuccessful()) {
twaHolder = '${location.coordinates.lat}, ${location.coordinates.lng}';
} else {
twaHolder = '${location.getError().code}: ${location.getError().message}';
}
});
},
);
return Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
twaInput,
convertToCoordsButton,
Text('$twaHolder', style: TextStyle(fontSize: 21))
],
),
);
}
}
```
---
# Golang
Getting started with the what3words Go API wrapper.
Topics: Go, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/go
Updated: 2026-11-27
The Go wrapper is useful for Go developers who wish to seamlessly integrate the [what3words Public API](https://docs.what3words.com/api/v3/) into their Go applications, without the hassle of having to manage the low level API calls themselves.
A full example of Go application is available in our **[GitHub](https://github.com/what3words/w3w-go-wrapper)** repository.
## 1. Get API key
You will need this API key for your installation. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
First, install the Go wrapper by running:
**Go**
```go
go get github.com/what3words/w3w-go-wrapper
```
## 3. Setup
### Import the Package
Start by importing the what3words package in your Go code:
**Go**
```go
import (
"github.com/what3words/w3w-go-wrapper/pkg/apis/v3"
what3words "github.com/what3words/w3w-go-wrapper"
)
```
### Initialise the Geocoder service
Create a new geocoder instance using your what3words API key. By default, the wrapper will point to the public version of the what3words API.
Public API:
**Go**
```go
apiKey := ""
svc := what3words.NewService(apiKey)
```
However, if required, the wrapper can be configured to point to a custom endpoint, for example a locally running version of the API. In this case an optional `WithCustomBaseURL` parameter can be passed to the `what3words.NewService` constructor.
API Server:
**Go**
```go
svc := what3words.NewService(apiKey, WithCustomBaseURL("http://localhost:8080"))
```
## 4. Usage
### Convert to what3words address
This function converts coordinates (expressed as latitude and longitude) to a what3words address.
More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (`51.520847,-0.195521`):
**Go**
```go
func main() {
apiKey := ""
svc := w3w.NewService(apiKey)
resp, err := svc.V3.ConvertTo3wa(context.Background(), v3.Coordinates{
Lat: 51.520847,
Lng: -0.195521,
}, nil)
if err != nil {
panic(err)
}
fmt.Println(resp.Json.Words)
}
```
### Convert to coordinates
This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of a what3words `'table.book.chair'`
More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///filled.count.soap`:
**Go**
```go
func main() {
apiKey := ""
svc := w3w.NewService(apiKey)
resp, err := svc.V3.ConvertToCoordinates(context.Background(), "filled.count.soap", nil)
if err != nil {
panic(err)
}
// By default response JSON is used
fmt.Println(resp.Json.Coordinates)
// Getting a geojson response
geoResp, err := svc.V3().ConvertToCoordinatesGeoJson(context.Background(), "filled.count.soap", nil)
if err != nil {
panic(err)
}
// If format GeoJson is not set in options, GeoJson attribute of the response will be set to nil
fmt.Println(geoResp.GeoJson.Features[0].Geometry.Coordinates)
}
```
### AutoSuggest
When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `Focus` to user’s current location. This will make `AutoSuggest` return results which are closer to the user.
More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Code example** Simple basic call:
**Go**
```go
func main() {
apiKey := ""
svc := w3w.NewService(apiKey)
resp, err := svc.V3.AutoSuggest(context.Background(), "filled.count.so")
if err != nil {
panic(err)
}
fmt.Println(resp)
}
```
**Code example** AutoSuggest, clipping the results returned to France and Germany:
**Go**
```go
func main() {
apiKey := ""
svc := w3w.NewService(apiKey)
resp, err := svc.V3.AutoSuggest(context.Background(), "filled.count.so",&v3.AutoSuggestOpts{
ClipToCountry: []string{"FR", "DE"},
})
if err != nil {
panic(err)
}
fmt.Println(resp)
}
```
**Code example** AutoSuggest, Focus on (`51.4243877,-0.34745`).
**Go**
```go
func main() {
apiKey := ""
svc := w3w.NewService(apiKey)
resp, err := svc.V3.AutoSuggest(context.Background(), "filled.count.so",&v3.AutoSuggestOpts{
Focus: &core.Coordinates{
Lat: 51.4243877,
Lng: -0.34745,
},
})
if err != nil {
panic(err)
}
fmt.Println(resp)
}
```
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for `52.207988,0.116126`) in the south west, and `52.208867,0.117540` in the north east:
**Go**
```go
func main() {
apiKey := ""
svc := w3w.NewService(apiKey)
resp, err := svc.V3.GridSection(context.Background(), v3.BoundingBox{
SouthWest: v3.Coordinates{
Lat: 52.207988,
Lng: 0.116126,
},
NorthEast: v3.Coordinates{
Lat: 52.208867,
Lng: 0.117540,
},
}, nil)
if err != nil {
panic(err)
}
fmt.Println(resp.Json.Lines)
}
```
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**Go**
```go
func main() {
apiKey := ""
svc := w3w.NewService(apiKey)
resp, err := svc.V3.AvailableLanguages(context.Background())
if err != nil {
panic(err)
}
fmt.Println(resp)
}
```
### Handling errors
In Go, error handling is a fundamental aspect of programming, and the what3words Go wrapper adheres to this convention by returning errors as the second value from its functions. This approach allows developers to handle errors gracefully and implement custom logic based on the error type or message.
Here’s how you can handle errors when using the what3words Go wrapper:
**Go**
```go
package main
import (
"context"
"fmt"
"log"
w3w "github.com/what3words/w3w-go-wrapper"
"github.com/what3words/w3w-go-wrapper/pkg/apis/v3"
)
func main() {
// Initialize the What3Words API with your API key
apiKey := ""
service := w3w.NewService(apiKey)
// Attempt to convert an invalid 3-word address to coordinates
address := "garbage.input"
resp, err := service.V3.ConvertToCoordinates(context.Background(), address, nil)
if err != nil {
// Handle the error
fmt.Printf("Error converting '%s' to coordinates: %v\n", address, err)
return
}
// If no error, proceed to use the response
fmt.Printf("Coordinates for '%s': %+v\n", address, resp.Json.Coordinates)
}
```
### Custom Error Handling:
The what3words Go wrapper provides specific error types that can be checked using Go’s `errors.As` function. This allows for more granular error handling based on the error type.
**Go**
```go
package main
import (
"context"
"errors"
"fmt"
"log"
w3w "github.com/what3words/w3w-go-wrapper"
"github.com/what3words/w3w-go-wrapper/pkg/apis/v3"
)
func main() {
// Initialize the What3Words API with your API key
apiKey := ""
service := w3w.NewService(apiKey)
// Attempt to convert an invalid 3-word address to coordinates
address := "garbage.input"
resp, err := service.V3.ConvertToCoordinates(context.Background(), address, nil)
if err != nil {
// Check if the error is of type BadWords
var badWordsErr *v3.BadWords
if errors.As(err, &badWordsErr) {
fmt.Printf("Invalid 3-word address '%s': %s\n", address, badWordsErr.Error())
} else {
// Handle other types of errors
fmt.Printf("Error converting '%s' to coordinates: %v\n", address, err)
}
return
}
// If no error, proceed to use the response
fmt.Printf("Coordinates for '%s': %+v\n", address, resp.Json.Coordinates)
}
```
## 5. RegEx Functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `IsPossible3wa` – Match what3words address format;
- `IsValid3wa` – Verify a what3words address with the API;
### IsPossible3wa
Our API wrapper RegEx function “`IsPossible3wa`” can be used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `IsValid3wa` to verify validity.
**Go**
```go
package main
import (
"fmt"
w3w "github.com/what3words/w3w-go-wrapper"
)
func main() {
// Initialize the What3Words API with your API key
apiKey := ""
service := w3w.NewService(apiKey)
// Example what3words addresses
addresses := []string{"filled.count.soap", "not a 3wa", "not.3wa address"}
// Check if the addresses are possible what3words addresses
for _, address := range addresses {
isPossible := service.IsPossible3wa(address)
fmt.Printf("Is '%s' a possible what3words address? %t\n", address, isPossible)
}
}
```
#### Expected Output
- IsPossible3wa(“filled.count.soap”) returns `true`
- IsPossible3wa(“not a 3wa”) returns `false`
- IsPossible3wa(“not.3wa address”)returns `false`
### isValid3wa
Our API wrapper RegEx function “`IsValid3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**Go**
```go
package main
import (
"context"
"fmt"
w3w "github.com/what3words/w3w-go-wrapper"
)
func main() {
// Initialize the What3Words API with your API key
apiKey := ""
service := w3w.NewService(apiKey)
// Example addresses
addresses := []string{
"filled.count.soap",
"filled.count.",
"coding.is.cool",
}
// Check if the addresses are valid what3words addresses
for _, address := range addresses {
isValid, err := service.IsValid3wa(context.Background(), address)
if err != nil {
fmt.Printf("Error validating address '%s': %v\n", address, err)
} else {
fmt.Printf("Is '%s' a valid what3words address? %t\n", address, isValid)
}
}
}
```
#### Expected Outputs
- IsValid3wa(“filled.count.soap”) returns `True`
- IsValid3wa(“filled.count.”) returns `False`
- IsValid3wa(“coding.is.cool”) returns `False`
Also, make sure to replace `` with your actual API key. These functionalities provide different levels of validation for what3words addresses, from simply identifying potential addresses to verifying their existence on Earth.
## 6. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
---
# JavaScript / TypeScript
Getting started with the what3words JavaScript API wrapper.
Topics: Angular, JavaScript, NodeJS, React, Vue, Server and Scripting, Website
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/javascript
Updated: 2026-11-27
### Step by step
The JavaScript/TypeScript API wrapper is useful for developers who wish to seamlessly integrate the [what3words Public API](https://docs.what3words.com/api/v3/) into their Node.js/Browser-based environment, without the hassle of having to manage the low-level API calls themselves.
Alternatively, there is a [JavaScript SDK](https://developer.what3words.com/tutorial/javascript-sdk) that uses the JavaScript/TypeScript API Wrapper under the hood, and it supports native web components `@what3words/javascript-components` (which can also be loaded via CDN), Angular components – `@what3words/angular-components`, React components – `@what3words/react-components` and Vue components – `@what3words/vue-components`.
The components available for you to use are as follows:
- [AutoSuggest Component](https://developer.what3words.com/tutorial/javascript-autosuggest-component)
- [Map Component](https://developer.what3words.com/tutorial/using-the-web-map-component)
## 1. Get an API Key
You will need a what3words API key to complete this tutorial. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
To load the JavaScript/TypeScript wrapper for the what3words API, use npm or yarn:
**npm**
```shellscript
npm install @what3words/api
```
**yarn**
```shellscript
yarn add @what3words/api
```
If you wish to use the built-in transports you will also need to install the peer dependencies for them. For more information on the default transports read the section on [Transports](https://developer.what3words.com/tutorial/javascript#transport).
## 3. Setup
First, configure the wrapper including adding your what3words API key:
**JavaScript**
```javascript
const what3words,
{ fetchTransport } = require('@what3words/api');
const apiKey = '';
const config = {
host: 'https://api.what3words.com',
apiVersion: 'v3',
};
const transport = fetchTransport(); // or you can import 'axiosTransport' instead
const w3wService = what3words(apiKey, config, { transport });
// you can uncomment the following lines to set your api key and config after instantiation of the w3w service
// w3wService.setApiKey(apiKey);
// w3wService.setConfig(config);
```
**TypeScript**
```typescript
import what3words, {
ApiVersion,
Transport,
What3wordsService,
axiosTransport,
} from '@what3words/api';
const apiKey = '';
const config: {
host: string;
apiVersion: ApiVersion;
} = {
host: 'https://api.what3words.com',
apiVersion: ApiVersion.Version3,
};
const transport: Transport = axiosTransport();
const w3wService: What3wordsService = what3words(apiKey, config, { transport });
// code continues...
```
### what3words Service
The `What3wordsService` provides a quick and easy way to instantiate the API clients that can be used to make requests against the what3words API. It also provides helper functions for setting API configuration, such as host and API version and your API key across the what3words API clients.
### Clients
The what3words API clients in this library are used to validate request options, serialise and handle request/response and errors against an API endpoint. Each client extends the abstract `ApiClient` class.
There is a specific client for each request and you can use them independently of the `What3wordsService`. This can be particularly useful if you want to extend the client behavior, minimise your code, or, in a more extreme example, use a custom transport to handle requests differently in each client.
Every client accepts the following parameters:
| Parameter | Datatype | Default value |
| --- | --- | --- |
| apiKey | string | '' |
| config | config.host | https://api.what3words.com |
| | config.apiVersion | v3 |
### Transport
The transport is a function responsible for executing the request against the API. Given a `ClientRequest` the transport should return a promise that resolves to `TransportResponse`.
A `ClientRequest` consists of the following properties:
| Property | Datatype |
| --- | --- |
| host\* | string |
| url\* | string |
| method\* | get or post |
| query | object |
| headers | object |
| body | object |
| format\* | json or geojson. Default: json |
A `TransportResponse` consists of the following properties:
| Property | Datatype |
| --- | --- |
| status\* | number |
| statusText\* | string |
| body\* | any |
| headers | object |
There are two built-in transports available with this library that you can use; either [isomorphic-unfetch](https://www.npmjs.com/package/isomorphic-unfetch) or [axios](https://www.npmjs.com/package/axios). By specifying which transport you would like to use on initialisation of the `What3wordsService` or a client, if you wish to instantiate a client for yourself.
### Built-ins
There are two built-in transports available:
- [Isomorphic-unfetch](https://www.npmjs.com/package/isomorphic-unfetch)
- [Axios](https://www.npmjs.com/package/axios)
To use either of these you will need to install the peer dependency. By default, [isomorphic-unfetch](https://www.npmjs.com/package/isomorphic-unfetch) is assumed by the `What3wordsService` or any instantiated client where no override is provided.
**npm**
```shellscript
npm install cross-fetch
npm install axios
```
**yarn**
```shellscript
yarn add cross-fetch
yarn add axios
```
### Custom
You can provide your own custom transport, if you wish to use another library for handling requests, which might be useful if you have other integrations or you are already using an http library elsewhere.
In order to do so you need to define your own `Transport` and pass it into the `What3wordsService` or client to use it.
The custom `Transport` you create should be a function that accepts a `ClientRequest` as an argument and returns a promise that resolves to a `TransportResponse`.
### Example
**TypeScript**
```typescript
import what3words, { ClientRequest, TransportResponse } from '@what3words/api';
import superagent from 'superagent';
const API_KEY = '';
const config = {}; // This will ensure we do not override the defaults
function customTransport(
request: ClientRequest
): Promise> {
const {
method,
host,
url,
query = {},
headers = {},
body = {},
format,
} = request;
return new Promise(resolve =>
superagent[method](`${host}${url}`)
.query({ ...query, format })
.send(body || {})
.set(headers)
.end((err, res) => {
if (err || !res)
return resolve({
status: err.status || 500,
statusText: err.response.text || 'Internal Server Error',
headers: err.headers || {},
body: err.response.text || null,
});
const response: TransportResponse = {
status: res.status,
statusText: res.text,
headers: res.headers,
body: res.body,
};
resolve(response);
})
);
}
const service = what3words(API_KEY, config, { transport: customTransport });
service
.availableLanguages()
.then(({ languages }) => console.log('Available languages', languages));
```
## 4. Usage on Browser-based environment
### Requirements
There are some requirements to use the JavaScript/TypeScript API wrapper on a browser environment please note the following:
- [esbuild](https://esbuild.github.io/) was used to build the project with a dependency on [esbuild-plugin-polyfill-node](https://www.npmjs.com/package/esbuild-plugin-polyfill-node) to shim node-specific features to successfully compile for browsers. You may choose to bundle your project with any appropriate tool of your choice, the only requirement as of `what3words/api v5.0.1` now is to polyfill the node `os` built-in.
- To use the package, run the following command to install the javascript API wrapper and its core dependencies:
**npm**
```shellscript
npm install -S @what3words/api axios cross-fetch
```
- Alternatively, there is a [JavaScript SDK](https://developer.what3words.com/tutorial/javascript-sdk) that uses the JavaScript/TypeScript API Wrapper under the hood, and it supports native web components `@what3words/javascript-components` (which can also be loaded via CDN), Angular components – `@what3words/angular-components`, React components – `@what3words/react-components` and Vue components – `@what3words/vue-components`. The components available for you to use are the [AutoSuggest Component](https://developer.what3words.com/tutorial/javascript-autosuggest-component) and the [Map Component](https://developer.what3words.com/tutorial/using-the-web-map-component).
### Convert to 3 word address
This function converts coordinates (expressed as latitude and longitude) to a 3 word address.
More information about `convertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (51.520847, -0.195521):
**JavaScript**
```javascript
import what3words, {
axiosTransport,
ApiVersion
} from "@what3words/api";
const W3W_API_KEY = ""; //TODO: Add your what3words API key here
// Instantiate what3words instance
window.what3words = what3words(
"",
{ apiVersion: ApiVersion.Version3 },
{ transport: axiosTransport() },
);
// Configure what3words JS wrapper
window.what3words.setApiKey(W3W_API_KEY);
// Convert a coordinate to a three word address and retrieve the JSON response from our API
window.what3words
.convertTo3wa({
coordinates: { lat: 51.520847, lng: -0.195521 },
language: 'en',
format: 'json'
})
.then((response) => {
word = response.words;
console.log(word);
})
// Convert a coordinate to a three word address and retrieve the GEOJSON response from our API
window.what3words
.convertTo3wa({
coordinates: { lat: 51.520847, lng: -0.195521 },
language: 'en',
format: 'geojson'
})
.then((response) => {
console.log(response);
})
```
### Convert to coordinates
This function converts a 3 word address to a position, expressed as coordinates of latitude and longitude.
It takes the word parameter as a string of 3 words `'table.book.chair'`
More information about `convertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///filled.count.soap`:
**JavaScript**
```javascript
import what3words, {
axiosTransport,
ApiVersion,
W3W_REGEX,
} from "@what3words/api";
const W3W_API_KEY = ""; //TODO: Add your what3words API key here
// Instantiate what3words instance
window.what3words = what3words(
"",
{ apiVersion: ApiVersion.Version3 },
{ transport: axiosTransport() },
);
// Configure what3words JS wrapper
window.what3words.setApiKey(W3W_API_KEY);
const THREE_WORD_ADDRESS = "filled.count.soap";
// Retrieve coordinates for initial three word address in JSON
window.what3words
.convertToCoordinates({
words: THREE_WORD_ADDRESS,
format: 'json' // or format: 'geojson'
})
.then((res) => {
coordinates = res.coordinates;
console.log(coordinates);
})
// Retrieve coordinates for initial three word address in GEOJSON
window.what3words
.convertToCoordinates({
words: THREE_WORD_ADDRESS,
format: 'geojson' // or format: json'
})
.then((res) => {
console.log(response);
})
```
### AutoSuggest
When presented with a 3 words address that may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `focus` to user’s current location. This will make `autosuggest` return results which are closer to the user.
More information about `autosuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Example:** Basic AutoSuggest call.
**JavaScript**
```javascript
import what3words, {
axiosTransport,
ApiVersion
} from "@what3words/api";
const W3W_API_KEY = ""; //TODO: Add your what3words API key here
// Instantiate what3words instance
window.what3words = what3words(
"",
{ apiVersion: ApiVersion.Version3 },
{ transport: axiosTransport() },
);
// Configure what3words JS wrapper
window.what3words.setApiKey(W3W_API_KEY);
window.what3words
.autosuggest({
input: 'freshen.overlook.clo',
language: 'en'
})
.then(function (response) {
console.log(`suggestions for: ${response}`);
});
```
### Grid section
The grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner or a `BadBoundingBoxTooBig` error will be returned.
More information about `gridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for (52.208867,0.117540) in the south-west, and (52.207988,0.116126) in the north-east:
**JavaScript**
```javascript
import what3words, {
axiosTransport,
ApiVersion
} from "@what3words/api";
const W3W_API_KEY = ""; //TODO: Add your what3words API key here
// Instantiate what3words instance
window.what3words = what3words(
"",
{ apiVersion: ApiVersion.Version3 },
{ transport: axiosTransport() },
);
// Configure what3words JS wrapper
window.what3words.setApiKey(W3W_API_KEY);
// Call the what3words Grid API to obtain the grid squares within the current visible bounding box
window.what3words.
.gridSection({
boundingBox: {
southwest: {
lat: sw.lat(), // replace with SouthWest Latitude coordinates
lng: sw.lng() // replace with SouthWest Longitude coordinates
},
northeast: {
lat: ne.lat(), // replace with NorthEast Latitude coordinates
lng: ne.lng() // replace with NorthEast Longitude coordinates
}
},
format: "json"
})
.then(function (data) {
console.log(data)
})
.catch(console.error);
```
### Available languages
This function returns the currently supported languages. It will return the two-letter code, and the name of the language both in that language and English.
More information about `availableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**JavaScript**
```javascript
import what3words, {
axiosTransport,
ApiVersion
} from "@what3words/api";
const W3W_API_KEY = ""; //TODO: Add your what3words API key here
// Instantiate what3words instance
window.what3words = what3words(
"",
{ apiVersion: ApiVersion.Version3 },
{ transport: axiosTransport() },
);
// Configure what3words JS wrapper
window.what3words.setApiKey(W3W_API_KEY)
// Retrieve and print out supported languages
window.what3words.availableLanguages().then((res) => {
languages = res.languages;
console.log(languages);
});
```
## 5. Usage on Node.js-based environment
### Convert to 3 word address
This function converts coordinates (expressed as latitude and longitude) to a 3 word address.
More information about `convertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (51.520847, -0.195521):
**TypeScript**
```typescript
import {
ConvertTo3waClient,
ConvertTo3waOptions,
FeatureCollectionResponse,
LocationGeoJsonResponse,
LocationJsonResponse,
} from '@what3words/api';
const API_KEY = '';
const client: ConvertTo3waClient = ConvertTo3waClient.init(API_KEY);
const options: ConvertTo3waOptions = {
coordinates: { lat: 51.520847, lng: -0.195521 },
};
// If you want to retrieve the JSON response from our API
client
.run({ ...options, format: 'json' }) // { format: 'json' } is the default response
.then((res: LocationJsonResponse) => console.log('Convert to 3wa', res));
// If you want to retrieve the GeoJsonResponse from our API
client
.run({ ...options, format: 'geojson' })
.then((res: FeatureCollectionResponse) =>
console.log('Convert to 3wa', res)
);
```
### Convert to coordinates
This function converts a 3 word address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of 3 words `'table.book.chair'`
More information about `convertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for ///filled.count.soap:
**TypeScript**
```typescript
import {
ConvertToCoordinatesClient,
ConvertToCoordinatesOptions,
FeatureCollectionResponse,
LocationGeoJsonResponse,
LocationJsonResponse,
} from '@what3words/api';
const API_KEY = '';
const client: ConvertToCoordinatesClient =
ConvertToCoordinatesClient.init(API_KEY);
const options: ConvertToCoordinatesOptions = { words: 'filled.count.soap' };
// If you want to retrieve the JSON response from our API
client
.run({ ...options, format: 'json' }) // { format: 'json' } is the default response
.then((res: LocationJsonResponse) =>
console.log('Convert to coordinates', res)
);
// If you want to retrieve the GeoJsonResponse from our API
client
.run({ ...options, format: 'geojson' })
.then((res: FeatureCollectionResponse) =>
console.log('Convert to coordinates', res)
);
```
### AutoSuggest
When presented with a 3 words address that may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `focus` to user’s current location. This will make `autosuggest` return results which are closer to the user.
More information about `autosuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Example:** Basic AutoSuggest call
**TypeScript**
```typescript
import {
AutosuggestClient,
AutosuggestOptions,
AutosuggestResponse,
} from '@what3words/api';
const API_KEY = '';
const client: AutosuggestClient = AutosuggestClient.init(API_KEY);
const options: AutosuggestOptions = {
input: 'filled.count.s',
};
client
.run(options)
.then((res: AutosuggestResponse) =>
console.log(`suggestions for "${options.input}"`, res)
);
```
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `gridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for (52.208867,0.117540) in the south west, and (52.207988,0.116126) in the north east:
**TypeScript**
```typescript
import {
GridSectionClient,
GridSectionOptions,
FeatureCollectionResponse,
GridSectionGeoJsonResponse,
GridSectionJsonResponse,
} from '../src';
const API_KEY = '';
const client: GridSectionClient = GridSectionClient.init(API_KEY);
const options: GridSectionOptions = {
boundingBox: {
southwest: { lat: 52.208867, lng: 0.11754 },
northeast: { lat: 52.207988, lng: 0.116126 },
},
};
// If you want to retrieve the JSON response from our API
client
.run({ ...options, format: 'json' }) // { format: 'json' } is the default response
.then((res: GridSectionJsonResponse) => console.log('Grid Section', res));
// If you want to retrieve the JSON response from our API
client
.run({ ...options, format: 'geojson' }) // { format: 'json' } is the default response
.then((res: FeatureCollectionResponse) =>
console.log('Grid Section', res)
);
```
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `availableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**TypeScript**
```typescript
import {
AvailableLanguagesClient,
AvailableLanguagesResponse,
} from '@what3words/api';
const API_KEY = '';
const client: AvailableLanguagesClient = AvailableLanguagesClient.init(API_KEY);
client
.run()
.then((res: AvailableLanguagesResponse) =>
console.log('Available Languages', res)
);
```
## 6. RegEx functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `isPossible3wa` – Match what3words address format;
- `isValid3wa` – Verify a what3words address with the API;
### isPossible3wa
Our API wrapper RegEx function “`isPossible3wa`” can be used used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `isValid3wa` to verify validity.
**TypeScript**
```typescript
import { AutosuggestClient } from "@what3words/api";
// Initialise the What3Words API with your API key
const API_KEY = 'YOUR_API_KEY';
const client = AutosuggestClient.init(API_KEY);
// Example what3words addresses
const addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"];
// Function to check if the address is a possible what3words address
const checkPossible3wa = (address) => {
const isPossible = client.isPossible3wa(address);
console.log(`Is '${address}' a possible what3words address? ${isPossible}`);
};
// Check each address
addresses.forEach(checkPossible3wa);
```
### Expected Output
- isPossible3wa(“filled.count.soap”) returns `true`
- isPossible3wa(“not a 3wa”) returns `false`
- isPossible3wa(“not.3wa address”)returns `false`
### isValid3wa
Our API wrapper RegEx function “`isValid3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**TypeScript**
```typescript
import { AutosuggestClient } from "@what3words/api";
const API_KEY = 'YOUR_API_KEY';
const client = AutosuggestClient.init(API_KEY);
// Example addresses
const addresses = [
"filled.count.soap",
"filled.count.",
"coding.is.cool"
];
// Function to check if the address is valid
const checkIsValid3wa = async (address) => {
try {
const isValid = await client.isValid3wa(address);
console.log(`Is '${address}' a valid what3words address? ${isValid}`);
} catch (error) {
console.error(`Error validating address '${address}':`, error);
}
};
// Check each address for validity
addresses.forEach(checkIsValid3wa);
```
### Expected Outputs
- isValid3wa(“filled.count.soap”) returns `True`
- isValid3wa(“filled.count.”) returns `False`
- isValid3wa(“coding.is.cool”) returns `False`
Also make sure to replace `` with your actual API key. These functionalities provide different levels of validation for what3words addresses, from simply identifying potential addresses to verifying their existence on Earth.
## 7. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
---
# Java
Getting started with the what3words Java API wrapper.
Topics: Java, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/java
Updated: 2026-11-27
The Java API wrapper is useful for Java developers who wish to seamlessly integrate the [what3words API](https://docs.what3words.com/api/v3/) into their Java applications, without the hassle of having to manage the low level API calls themselves.
A full example of how to integrate the what3words Java wrapper is available in our
[Java Github repository](https://github.com/what3words/w3w-java-wrapper)
## 1. Get API key
You will need this API key for your installation. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
The library is available through [Maven Central](https://search.maven.org/search?q=g:com.what3words). Please add one of the following to either your `pom.xml` or `gradle.build` files.
Maven:
**Java**
```java
com.what3words
w3w-java-wrapper
3.1.17
```
Using Gradle:
**Java**
```java
implementation 'com.what3words:w3w-java-wrapper:3.1.17'
```
## 3. Setup
Instantiate an instance of What3WordsV3, from which all API requests can be made
**Java**
```java
// For all requests a what3words API key is needed
What3WordsV3 api = new What3WordsV3("what3words-api-key");
```
In the case that you run our Enterprise Suite API Server yourself, you may specify the URL to your server like so:
**Java**
```java
// In the case that you run our Enterprise Suite API Server yourself, you may specify the URL to your own server like so:
What3WordsV3 api = new What3WordsV3("what3words-api-key", "https://api.yourserver.com/v3/");
```
Additionally, if you run the Enterprise Suite API Server there is another optional `setup()` parameter: `customHeaders`. Use this if you need to send custom headers to your server:
**Java**
```java
/**
* Additionally, if you run the Enterprise Suite API Server there is another optional setup() parameter: customHeaders.
* Use this if you need to send custom headers to your own server:
*/
Map headers = new HashMap();
headers.put("Name1", "Value1");
headers.put("Name2", "Value2");
What3WordsV3 api = new What3WordsV3("what3words-api-key", "https://api.yourserver.com/v3/", headers);
```
## 4. Usage
### Convert to what3words address
This function converts coordinates (expressed as latitude and longitude) to a what3words address.
More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (`51.484463, -0.195405`):
**Java**
```java
// Convert coordinates to a 3 word address
ConvertTo3WA words = api.convertTo3wa(new Coordinates(51.484463, -0.195405))
.language("en")
.execute();
System.out.println("Words: " + words);
```
### Convert to coordinates
This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of a what3words `'table.book.chair'`
More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///filled.count.soap`:
**Java**
```java
// Convert a 3 word address to coordinates
ConvertToCoordinates coordinates = api.convertToCoordinates("filled.count.soap")
.execute();
System.out.println("Coordinates: " + coordinates);
```
### AutoSuggest
When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `Focus` to user’s current location. This will make `AutoSuggest` return results which are closer to the user.
More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Code example** Simple basic call:
**Java**
```java
Autosuggest autosuggest = api.autosuggest("fun.with.code")
.execute();
System.out.println("Autosuggest: " + autosuggest);
```
**Code example** AutoSuggest, clipping the results returned to the United Kingdom and Belgium:
**Java**
```java
Autosuggest autosuggest = api.autosuggest("fun.with.code")
.clipToCountry("GB", "BE")
.execute();
System.out.println("Autosuggest: " + autosuggest);
```
**Code example** AutoSuggest, Focus on (`51.4243877,-0.34745`).
**Java**
```java
Autosuggest autosuggest = api.autosuggest("fun.with.code")
.focus(new Coordinates(51.4243877,-0.34745))
.execute();
System.out.println("Autosuggest: " + autosuggest);
```
**Code example** AutoSuggest, with Generic Voice input type.
**Java**
```java
Autosuggest autosuggest = api.autosuggest("fun with code")
.inputType(AutosuggestInputType.GENERIC_VOICE)
.language("en")
.execute();
System.out.println("Autosuggest: " + autosuggest);
```
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for (`51.527649, -0.191746`) in the south-west, and (`51.515900, -0.212517` in the north-east:
**Java**
```java
// Obtain a grid section within the provided bounding box
GridSection gridSection = api.gridSection(
new BoundingBox(
new Coordinates(51.515900, -0.212517),
new Coordinates(51.527649, -0.191746)
)
).execute();
System.out.println("Grid section: " + gridSection);
```
#### Serializing To GeoJSON
If GeoJSON format is required (you are using on a map in an app for example) a function such as `geoJsonSerializer` can be added. This should be registered to Gson as a `TypeAdapter` and then you can then serialize the objects returned from the wrapper into GeoJSON.
**Java**
```java
JsonSerializer geoJsonSerializer = api.getGridSectionJsonSerializer();
GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(GridSection.class, geoJsonSerializer);
Gson geoJsonGson = gsonBuilder.create();
String geoJson = geoJsonGson.toJson(gridSection);
```
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**Java**
```java
// Obtain the list of available languages
AvailableLanguages languages = api.availableLanguages().execute();
System.out.println("Languages: " + languages);
```
### Handling errors
Errors returned from the API can be caught with the wrapper through the use of a `catch` function.
Within the `catch` function, `code` and `message` values which represent the error, are accessible from the `error` object parameter
**Java**
```java
Autosuggest autosuggest = api.autosuggest("freshen.overlook.clo")
.clipToCountry("fr")
.execute();
if (autosuggest.isSuccessful()) {
...
} else { // An error occurred
What3WordsError error = autosuggest.getError();
if (error == What3WordsError.BAD_CLIP_TO_COUNTRY) { // Invalid country clip is provided
System.out.println("BadClipToCountry: " + error.getMessage());
}
}
```
## 5. RegEx Functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `isPossible3wa` – Match what3words address format;
- `isValid3wa` – Verify a what3words address with the API;
### isPossible3wa
Our API wrapper RegEx function “`isPossible3wa`” can be used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `isValid3wa` to verify validity.
**Java**
```java
public class What3WordsExample {
public static void main(String[] args) {
// Example what3words addresses
String[] addresses = {"filled.count.soap", "not a 3wa", "not.3wa address"};
// Check if the addresses are possible what3words addresses
for (String address : addresses) {
boolean isPossible = What3WordsV3.isPossible3wa(address);
System.out.println("Is '" + address + "' a possible what3words address? " + isPossible);
}
}
}
```
#### Expected Output
- isPossible3wa(“filled.count.soap”) returns `true`
- isPossible3wa(“not a 3wa”) returns `false`
- isPossible3wa(“not.3wa address”)returns `false`
### isValid3wa
Our API wrapper RegEx function “`isValid3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**Java**
```java
public class What3WordsExample {
public static void main(String[] args) {
// Initialize the What3Words API with your API key
What3WordsV3 api = new What3WordsV3("YOUR_API_KEY");
// Example addresses
String[] addresses = {
"filled.count.soap",
"filled.count.",
"coding.is.cool"
};
// Check if the addresses are valid what3words addresses
for (String address : addresses) {
boolean response = api.isValid3wa(address);
if (response.isSuccessful() && response.getIsValid()) {
System.out.println(address + " is a valid what3words address");
} else if (response.isSuccessful() && !response.getIsValid()) {
System.out.println(address + " is an invalid what3words address");
} else {
System.out.println("isValid3wa error: " + response.getError().getKey() + " " + response.getError().getMessage());
}
}
}
}
```
#### Expected Outputs
- isValid3wa(“filled.count.soap”) returns `True`
- isValid3wa(“filled.count.”) returns `False`
- isValid3wa(“coding.is.cool”) returns `False`
Also make sure to replace `` with your actual API key. These functionalities provide different levels of validation for what3words addresses, from simply identifying potential addresses to verifying their existence on Earth.
## 6. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
## 7. Full example
The example below takes the concepts described above, and turns some of them into a complete example. Here we take a partial 3 word address and pass it into AutoSuggest – clipping the results to consider only addresses in France, setting a focus of Paris, and returning a single result
We then take the result and convert the 3 word address to coordinates, and find the nearest place.
**Java**
```java
// For all requests a what3words API key is needed
What3WordsV3 api = new What3WordsV3("what3words-api-key");
Autosuggest autosuggest = api.autosuggest("freshen.overlook.clo")
.clipToCountry("FR")
.focus(new Coordinates(48.856618, 2.3522411))
.nResults(1)
.execute();
if (autosuggest.isSuccessful()) {
String words = autosuggest.getSuggestions().get(0).getWords();
System.out.printf("Top 3 word address match: %s%n", words);
ConvertToCoordinates convertToCoordinates = api.convertToCoordinates(words).execute();
if (convertToCoordinates.isSuccessful()) {
System.out.printf("WGS84 Coordinates: %f, %f%n",
convertToCoordinates.getCoordinates().getLat(),
convertToCoordinates.getCoordinates().getLng());
System.out.printf("Nearest Place: %s%n", convertToCoordinates.getNearestPlace());
} else {
What3WordsError error = autosuggest.getError();
if (error == What3WordsError.INTERNAL_SERVER_ERROR) { // Server Error
System.out.println("InternalServerError: " + error.getMessage());
} else if (error == What3WordsError.NETWORK_ERROR) { // Network Error
System.out.println("NetworkError: " + error.getMessage());
}
}
} else {
What3WordsError error = autosuggest.getError();
if (error == What3WordsError.BAD_CLIP_TO_COUNTRY) { // Invalid country clip is provided
System.out.println("BadClipToCountry: " + error.getMessage());
} else if (error == What3WordsError.BAD_FOCUS) { // Invalid focus
System.out.println("BadFocus: " + error.getMessage());
} else if (error == What3WordsError.BAD_N_RESULTS) { // Invalid number of results
System.out.println("BadNResults: " + error.getMessage());
} else if (error == What3WordsError.INTERNAL_SERVER_ERROR) { // Server Error
System.out.println("InternalServerError: " + error.getMessage());
} else if (error == What3WordsError.NETWORK_ERROR) { // Network Error
System.out.println("NetworkError: " + error.getMessage());
} else {
System.out.println(error + ": " + error.getMessage());
}
}
```
---
# .NET
Getting started with the what3words .NET API wrapper.
Topics: .NET, Server and Scripting, Website
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/dotnet
Updated: 2026-11-27
The .NET API wrapper is useful for .NET developers who wish to seamlessly integrate the [what3words API](https://docs.what3words.com/api/v3/) into their applications, without the hassle of having to manage the low level API calls themselves.
A full example of how to integrate the what3words .NET wrapper is available in our
[.NET Github repository](https://github.com/what3words/w3w-dotnet-wrapper)
## 1. Get API key
You will need this API key for your installation. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
The artifact is available through NuGet Package [what3words.dotnet.wrapper](https://www.nuget.org/packages/what3words.dotnet.wrapper/).
**.NET**
```csharp
dotnet add package what3words.dotnet.wrapper
```
## 3. Setup
Use the `What3WordsV3`
**C#**
```csharp
using What3WordsV3;
```
**F#**
```fsharp
open What3WordsV3
```
**VB .NET**
```vb
Imports What3WordsV3
```
## 4. Initialise
Instantiate an instance of What3WordsV3, from which all API requests can be made
**C#**
```csharp
var wrapper = new What3WordsV3("YOUR_API_KEY_HERE");
```
**F#**
```fsharp
let wrapper = What3WordsV3("YOUR_API_KEY_HERE")
```
**VB .NET**
```vb
Dim wrapper As 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:
**C#**
```csharp
var wrapper = new What3Words("YOUR_API_KEY_HERE", "https://api.yourserver.com")
```
**F#**
```fsharp
let wrapper = What3Words("YOUR_API_KEY_HERE", "https://api.yourserver.com")
```
**VB .NET**
```vb
Dim wrapper As New What3Words("YOUR_API_KEY_HERE", "https://api.yourserver.com")
```
## 5. Usage
### Convert to what3words address
This function converts coordinates (expressed as latitude and longitude) to a what3words address.
More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (`51.222011, 0.152311`):
**C#**
```csharp
var result = await wrapper
.ConvertTo3WA(new Coordinates(51.222011, 0.152311))
.RequestAsync();
```
**F#**
```fsharp
let! result =
wrapper
.ConvertTo3WA(Coordinates(51.222011, 0.152311))
.RequestAsync()
```
**VB .NET**
```vb
Dim result = Await wrapper _
.ConvertTo3WA(New Coordinates(51.222011, 0.152311)) _
.RequestAsync()
```
### Convert to coordinates
This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of a what3words `'table.book.chair'`
More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///filled.count.soap`:
**C#**
```csharp
var result = await wrapper
.ConvertToCoordinates("filled.count.soap")
.RequestAsync();
```
**F#**
```fsharp
let! result =
wrapper
.ConvertToCoordinates("filled.count.soap")
.RequestAsync()
```
**VB .NET**
```vb
Dim result = Await wrapper _
.ConvertToCoordinates("filled.count.soap") _
.RequestAsync()
```
### AutoSuggest
When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `focus` to user’s current location. This will make `AutoSuggest` return results which are closer to the user.
More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Code example** Simple basic call:
**C#**
```csharp
var result = await wrapper
.Autosuggest("index.home.r")
.RequestAsync();
```
**F#**
```fsharp
let! result =
wrapper
.Autosuggest("index.home.r")
.RequestAsync()
```
**VB .NET**
```vb
Dim result = Await wrapper _
.Autosuggest("index.home.r") _
.RequestAsync()
```
**Code example** AutoSuggest, clipping the results returned to the United Kingdom and Belgium:
**C#**
```csharp
var result = await wrapper
.Autosuggest("index.home.r", new AutosuggestOptions().ClipToCircle("GB,BE"))
.RequestAsync();
```
**F#**
```fsharp
let! result =
wrapper
.Autosuggest("index.home.r", AutosuggestOptions().ClipToCircle("GB,BE"))
.RequestAsync()
```
**VB .NET**
```vb
Dim result = Await wrapper _
.Autosuggest("index.home.r", New AutosuggestOptions().ClipToCircle("GB,BE")) _
.RequestAsync()
```
**Code example** AutoSuggest, Focus on (`51.4243877,-0.34745`).
**C#**
```csharp
var result = await wrapper
.Autosuggest("index.home.r", new AutosuggestOptions().SetFocus(51.4243877, -0.34745))
.RequestAsync();
```
**F#**
```fsharp
let! result =
wrapper
.Autosuggest("index.home.r", AutosuggestOptions().SetFocus(51.4243877, -0.34745))
.RequestAsync()
```
**VB .NET**
```vb
Dim result = Await wrapper _
.Autosuggest("index.home.r", New AutosuggestOptions().SetFocus(51.4243877, -0.34745)) _
.RequestAsync()
```
**Code example** AutoSuggest, with Generic Voice input type.
**C#**
```csharp
var result = await wrapper
.Autosuggest("fun with code", new AutosuggestOptions().InputType("generic-voice"))
.RequestAsync();
```
**F#**
```fsharp
let! result =
wrapper
.Autosuggest("fun with code", AutosuggestOptions().InputType("generic-voice"))
.RequestAsync()
```
**VB .NET**
```vb
Dim result = Await wrapper _
.Autosuggest("fun with code", New AutosuggestOptions().InputType("generic-voice")) _
.RequestAsync()
```
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for (`51.222609, 0.152898`) in the south-west, and (`51.222011, 0.152311` in the north-east:
**C#**
```csharp
var result = await wrapper
.GridSection(new Coordinates(51.222011, 0.152311), new Coordinates(51.222609, 0.152898))
.RequestAsync();
```
**F#**
```fsharp
let! result =
wrapper
.GridSection(Coordinates(51.222011, 0.152311), Coordinates(51.222609, 0.152898))
.RequestAsync()
```
**VB .NET**
```vb
Dim result = Await wrapper _
.GridSection(New Coordinates(51.222011, 0.152311), New Coordinates(51.222609, 0.152898)) _
.RequestAsync()
```
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**C#**
```csharp
var result = await wrapper
.AvailableLanguages()
.RequestAsync();
```
**F#**
```fsharp
let! result =
wrapper
.AvailableLanguages()
.RequestAsync()
```
**VB .NET**
```vb
Dim result = Await wrapper _
.AvailableLanguages() _
.RequestAsync()
```
### Handling errors
Success or failure of an API call can be determined through the use of the `IsSuccessful` propriety.
If it’s been determined that an API call was not successful, `Error` type and `Message` values which represent the error, are accessible from through the `Error` propriety.
**C#**
```csharp
var autosuggestResult = await api.Autosuggest(
"freshen.overlook.clo",
new AutosuggestOptions().SetClipToCountry(new List { "fr", "de" })
).RequestAsync();
if (autosuggestResult.IsSuccessful)
{
...
}
else
{
if (autosuggestResult.Error.Error == What3WordsError.BadClipToCountry)
{
// Invalid country clip is provided
Console.WriteLine($"BadClipToCountry: {autosuggestResult.Error.Message}");
}
}
```
**F#**
```fsharp
let! autosuggestResult =
api.Autosuggest(
"freshen.overlook.clo",
AutosuggestOptions().SetClipToCountry(new List [ "fr"; "de" ])
).RequestAsync()
if autosuggestResult.IsSuccessful then
...
else
if autosuggestResult.Error.Error = What3WordsError.BadClipToCountry then
// Invalid country clip is provided
printfn "BadClipToCountry: %s" autosuggestResult.Error.Message
```
**VB .NET**
```vb
Dim autosuggestResult = Await api.Autosuggest(
"freshen.overlook.clo",
New AutosuggestOptions().SetClipToCountry(New List(Of String) From { "fr", "de" })
).RequestAsync()
If autosuggestResult.IsSuccessful Then
...
Else
If autosuggestResult.Error.Error = What3WordsError.BadClipToCountry Then
' Invalid country clip is provided
Console.WriteLine($"BadClipToCountry: {autosuggestResult.Error.Message}")
End If
End If
```
## 6. RegEx Functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `isPossible3wa` – Match what3words address format;
- `isValid3wa` – Verify a what3words address with the API;
### isPossible3wa
Our API wrapper RegEx function “`isPossible3wa`” can be used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `isValid3wa` to verify validity.
**C#**
```csharp
using System;
using what3words.dotnet.wrapper;
namespace What3WordsExample
{
class Program
{
static void Main(string[] args)
{
// Initialize the What3Words API with your API key
var api = new What3WordsV3("YOUR_API_KEY");
// Example what3words addresses
string[] addresses = { "filled.count.soap", "not a 3wa", "not.3wa address" };
// Check if the addresses are possible what3words addresses
foreach (var address in addresses)
{
bool isPossible = api.IsPossible3wa(address);
Console.WriteLine($"Is '{address}' a possible what3words address? {isPossible}");
}
}
}
}
```
**F#**
```fsharp
open System
open what3words.dotnet.wrapper
[]
let main argv =
// Initialize the What3Words API with your API key
let api = What3WordsV3("YOUR_API_KEY")
// Example what3words addresses
let addresses = [| "filled.count.soap"; "not a 3wa"; "not.3wa address" |]
// Check if the addresses are possible what3words addresses
for address in addresses do
let isPossible = api.IsPossible3wa(address)
printfn "Is '%s' a possible what3words address? %b" address isPossible
0
```
**VB .NET**
```vb
Imports System
Imports what3words.dotnet.wrapper
Namespace What3WordsExample
Module Program
Sub Main(args As String())
' Initialize the What3Words API with your API key
Dim api = New What3WordsV3("YOUR_API_KEY")
' Example what3words addresses
Dim addresses As String() = { "filled.count.soap", "not a 3wa", "not.3wa address" }
' Check if the addresses are possible what3words addresses
For Each address In addresses
Dim isPossible As Boolean = api.IsPossible3wa(address)
Console.WriteLine($"Is '{address}' a possible what3words address? {isPossible}")
Next
End Sub
End Module
End Namespace
```
#### Expected Output
- isPossible3wa(“filled.count.soap”) returns `true`
- isPossible3wa(“not a 3wa”) returns `false`
- isPossible3wa(“not.3wa address”)returns `false`
### isValid3wa
Our API wrapper RegEx function “`isValid3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**C#**
```csharp
using System;
using what3words.dotnet.wrapper;
namespace What3WordsExample
class Program
{
static void Main(string[] args)
{
// Initialize the what3words API with your API key
var api = new What3WordsV3("YOUR_API_KEY");
// Example addresses
string[] addresses = {
"filled.count.soap",
"filled.count.",
"coding.is.cool"
};
// Check if the addresses are valid what3words addresses
foreach (var address in addresses)
{
bool isValid = api.IsValid3wa(address);
Console.WriteLine($"Is '{address}' a valid what3words address? {isValid}");
}
}
}
```
**F#**
```fsharp
open System
open what3words.dotnet.wrapper
[]
let main argv =
// Initialize the what3words API with your API key
let api = What3WordsV3("YOUR_API_KEY")
// Example addresses
let addresses =
[| "filled.count.soap"
"filled.count."
"coding.is.cool" |]
// Check if the addresses are valid what3words addresses
for address in addresses do
let isValid = api.IsValid3wa(address)
printfn "Is '%s' a valid what3words address? %b" address isValid
0
```
**VB .NET**
```vb
Imports System
Imports what3words.dotnet.wrapper
Namespace What3WordsExample
Module Program
Sub Main(args As String())
' Initialize the what3words API with your API key
Dim api = New What3WordsV3("YOUR_API_KEY")
' Example addresses
Dim addresses As String() = {
"filled.count.soap",
"filled.count.",
"coding.is.cool"
}
' Check if the addresses are valid what3words addresses
For Each address In addresses
Dim isValid As Boolean = api.IsValid3wa(address)
Console.WriteLine($"Is '{address}' a valid what3words address? {isValid}")
Next
End Sub
End Module
End Namespace
```
#### Expected Outputs
- isValid3wa(“filled.count.soap”) returns `True`
- isValid3wa(“filled.count.”) returns `False`
- isValid3wa(“coding.is.cool”) returns `False`
Also make sure to replace `` with your actual API key. These functionalities provide different levels of validation for what3words addresses, from simply identifying potential addresses to verifying their existence on Earth.
## 7. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
---
# Objective-C
Getting started with the what3words Objective-C API wrapper.
Topics: Objective-C, Mobile App, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/objective-c
Updated: 2026-11-27
The Objective-C wrapper is useful for Objective-C developers who wish to seamlessly integrate the [what3words Public API](https://docs.what3words.com/api/v3/) into their Objective-C applications, without the hassle of having to manage the low level API calls themselves.
Full sample apps for the wrapper can be found in our Github repo
[iOS Sample Apps](https://github.com/what3words/w3w-swift-samples)
## 1. Get API key
You will need a what3words API key to complete this tutorial. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
You can install the [what3Words API V3 Objective-C Wrapper](https://github.com/what3words/w3w-objectivec-wrapper) into your project using CocoaPods, or Carthage (see the package manager code below).
Find out more on this repository
[Objective-C Wrapper](https://github.com/what3words/w3w-objectivec-wrapper)
**Objective-C**
```objective-c
platform :ios, '9.0'
use_frameworks!
target 'MyApp' do
pod 'what3words', :git => 'https://github.com/what3words/w3w-objectivec-wrapper.git'
end
```
Carthage:
**Objective-C**
```objective-c
github "what3words/w3w-objectivec-wrapper"
```
For manual installation, `Drop the [W3wGeocoder.m](https://github.com/what3words/w3w-objectivec-wrapper/blob/master/Sources/W3wGeocoder.m) and [W3wGeocoder.h](https://github.com/what3words/w3w-objectivec-wrapper/blob/master/Sources/W3wGeocoder.h) file into your project.`
## 3. Setup
Use these header files:
**Objective-C**
```objective-c
#import "W3wGeocoder.h"
#import
```
Or, if you are using Carthage:
**Objective-C**
```objective-c
#import
#import
```
## 4. Initialise
First create a W3wGeocoder object:
**Objective-C**
```objective-c
W3wGeocoder *api = [[W3wGeocoder alloc] initWithApiKey:@""];
```
## 5. Usage
### Convert to what3words address
This function converts coordinates (expressed as latitude and longitude) to a what3words address. It takes the latitude and longitude as a [CLLocationCoordinate2D](https://developer.apple.com/documentation/corelocation/cllocationcoordinate2d?language=swift) object.
More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (`51.520847, -0.195521`):
**Objective-C**
```objective-c
CLLocationCoordinate2D coordinates = CLLocationCoordinate2DMake(51.520847, -0.195521);
[api convertTo3wa:coordinates completion:^(W3wPlace *place, W3wError *error)
{
NSLog(@"%@", place.words);
}];
```
### Convert to coordinates
This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of a what3words `'table.book.chair'`
More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///filled.count.soap`:
**Objective-C**
```objective-c
[api convertToCoordinates:@"filled.count.soap" format:JSON completion:^(W3wPlace *place, W3wError *error)
{
NSLog(@"Coordinates are: (%f, %f)", place.coordinates.latitude, place.coordinates.longitude);
}];
```
### AutoSuggest
When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `Focus` to user’s current location. This returns an `Array?` of `W3wSuggestion` objects.
More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Code example** Simple basic call:
**Objective-C**
```objective-c
[api autosuggest:@"geschaft.planter.carciofi" completion:^(NSArray *suggestions, W3wError *error)
{
W3wSuggestion *first_match = suggestions[0];
NSLog(@"%@", first_match.words);
}];
```
**Code example** AutoSuggest, clipping the results returned to Germany:
**Objective-C**
```objective-c
[api autosuggest:@"geschaft.planter.carciofi" parameters:@[[AutoSuggestOption clipToCountry:@"DE"], [AutoSuggestOption numberResults:4]] completion:^(NSArray *suggestions, W3wError *error)
{
W3wSuggestion *first_match = suggestions[0];
NSLog(@"%@", first_match.words);
}];
```
**Code example** Focus on (51.4243877,-0.34745)
**Objective-C**
```objective-c
[api autosuggest:@"fun.with.code" parameters:@[[AutoSuggestOption focus:CLLocationCoordinate2DMake(51.4243877, -0.3474524)], [AutoSuggestOption numberResults:6]] completion:^(NSArray *suggestions, W3wError *error)
{
W3wSuggestion *first_match = suggestions[0];
NSLog(@"%@", first_match.words);
}];
```
**Code example** AutoSuggest, with Generic Voice input type.
**Objective-C**
```objective-c
[api autosuggest:@"fun with code" parameters:@[[AutoSuggestOption fallBackLanguage:@"EN"], [AutoSuggestOption inputType:GENERIC_VOICE]] completion:^(NSArray *suggestions, W3wError *error)
{
W3wSuggestion *first_match = suggestions[0];
NSLog(@"%@", first_match.words);
}];
```
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for `52.207988,0.116126`) in the south west, and `52.208867,0.117540` in the north east:
**Objective-C**
```objective-c
[api gridSection:52.208867 west_lng:0.117540 north_lat:52.207988 east_lng:0.116126 format:JSON completion:^(NSArray *grid, W3wError *error)
{
W3wLine *first_line = grid[0];
NSLog(@"First line goes from (%.5f,%.5f) to (%.5f,%.5f)", first_line.start.latitude, first_line.start.longitude, first_line.end.latitude, first_line.end.longitude);
}];
```
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**Objective-C**
```objective-c
[api availableLanguages:^(NSArray *languages, W3wError *error)
{
W3wLanguage *language = languages[0];
NSLog(@"First language returned: %@", language.name);
}];
```
### Handling errors
All functions call the completion block with error as the second parameter. Be sure to check it for possible problems.
**Objective-C**
```objective-c
[api convertToCoordinates:@"aaaa.bbbb.cccc" format:JSON completion:^(W3wPlace *result, W3wError *error)
{
if (error)
NSLog(@"There was an %@ error: %@", error.code, error.message);
}];
```
## 6. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
## 7. Full example
Complete example using AutoSuggest to find a location.
**Objective-C**
```objective-c
#import "W3wGeocoder.h"
#import
W3wGeocoder *api = [[W3wGeocoder alloc] initWithApiKey:@""];
AutoSuggestOption *france = [AutoSuggestOption clipToCountry:@"FR"];
AutoSuggestOption *place = [AutoSuggestOption focus:CLLocationCoordinate2DMake(48.856618, 2.3522411)];
AutoSuggestOption *count = [AutoSuggestOption numberResults:10];
[api autosuggest:@"hangry.selfie.x" parameters:@[france, place, count] completion:^(NSArray *suggestions, W3wError *error)
{
if (error)
NSLog(@"There was an %@ error: %@", error.code, error.message);
else
{
NSLog(@"Suggestions Returned:");
for (W3wSuggestion *suggestion in suggestions)
{
NSLog(@"%@ is near %@", suggestion.words, suggestion.nearestPlace);
}
}
}];
```
---
# PHP
Getting started with the what3words PHP API wrapper.
Topics: PHP, Server and Scripting, Website
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/php
Updated: 2026-11-27
The PHP wrapper is useful for PHP developers who wish to seamlessly integrate the [what3words Public API](https://docs.what3words.com/api/v3/) into their PHP applications, without the hassle of having to manage the low level API calls themselves.
A full example of how to integrate the what3words PHP wrapper is available in our
[PHP Github repository](https://github.com/what3words/w3w-php-wrapper)
## 1. Get API key
You will need this API key for your installation. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
Use [Composer](https://getcomposer.org/) to integrate this library into your project, or do it manually.
Composer:
**PHP**
```php
{
“require”: {
“what3words/w3w-php-wrapper”: "3.*"
}
}
```
Manually:
Add this file to your project: `[Geocoder.php](https://github.com/what3words/w3w-php-wrapper/blob/master/src/Geocoder.php).`
## 3. Setup
If you manually dropped in the file then use `require_once("Geocoder.php")` instead of `require_once("vendor/autoload.php")`
**PHP**
```php
require_once("vendor/autoload.php");
use What3words\Geocoder\Geocoder;
use What3words\Geocoder\AutoSuggestOption;
```
## 4. Initialise
Initialise the what3words API client in your PHP script.
**PHP**
```php
require_once("vendor/autoload.php");
use What3words\Geocoder\Geocoder;
use What3words\Geocoder\AutoSuggestOption;
$api = new Geocoder("");
```
## 5. Usage
### Convert to what3words address
This function converts coordinates (expressed as latitude and longitude) to a what3words address.
More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (`51.484463, -0.195405`):
**PHP**
```php
$result = $api->convertTo3wa(51.484463, -0.195405);
print_r($result);
```
### Convert to coordinates
This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of a what3words `'table.book.chair'`
More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///filled.count.soap`:
**PHP**
```php
$result = $api->convertToCoordinates("filled.count.soap");
print_r($result);
```
### AutoSuggest
When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `Focus` to user’s current location. This will make `AutoSuggest` return results which are closer to the user.
More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Code example** Simple basic call:
**PHP**
```php
$result = $api->autosuggest("fun.with.code");
print_r($result);
```
**Code example** AutoSuggest, clipping the results returned to the United Kingdom and Belgium:
**PHP**
```php
$result = $api->autosuggest("fun.with.code", [AutoSuggestOption::clipToCountry("GB","BE")]);
print_r($result);
```
**Code example** AutoSuggest, Focus on (`51.4243877,-0.34745`).
**PHP**
```php
$result = $api->autosuggest("fun.with.code", [AutoSuggestOption::focus(51.4243877,-0.34745));
print_r($result);
```
**Code example** AutoSuggest, with Generic Voice input type.
**PHP**
```php
$result = $api->autosuggest("fun.with.code", [AutoSuggestOption::fallbackLanguage("EN"), AutoSuggestOption::inputType("generic-voice")]);
print_r($result);
```
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for `52.207988,0.116126`) in the south west, and `52.208867,0.117540` in the north east:
**PHP**
```php
$result = $api->gridSection(52.207988,0.116126, 52.208867,0.117540);
print_r($result);
```
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**PHP**
```php
$result = $api->availableLanguages();
print_r($result);
```
### Handling errors
Errors returned from the API can be caught with the wrapper through the use of a `catch` function.
Within the `catch` function, `code` and `message` values which represent the error, are accessible from the `error` object parameter.
**PHP**
```php
$result = $api->convertToCoordinates("garbage.input");
if ($result == false)
{
$error = $api->getError();
print "Error with code " . $error["code"] . ": ";
print $error["message"] . ":\n";
exit();
}
```
## 6. RegEx Functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `isPossible3wa` – Match what3words address format;
- `isValid3wa` – Verify a what3words address with the API;
### isPossible3wa
Our API wrapper RegEx function “`isPossible3wa`” can be used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `isValid3wa` to verify validity.
**PHP**
```php
isPossible3wa($address);
echo "Is '{$address}' a possible what3words address? " . ($isPossible ? "true" : "false") . "\n";
}
}
main();
?>
```
#### Expected Output
- isPossible3wa(“filled.count.soap”) returns `true`
- isPossible3wa(“not a 3wa”) returns `false`
- isPossible3wa(“not.3wa address”)returns `false`
### isValid3wa
Our API wrapper RegEx function “`isValid3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**PHP**
```php
isValid3wa($address);
echo "Is '$address' a valid what3words address? " . ($isValid ? 'True' : 'False') . "\n";
}
}
main();
```
#### Expected Outputs
- isValid3wa(“filled.count.soap”) returns `True`
- isValid3wa(“filled.count.”) returns `False`
- isValid3wa(“coding.is.cool”) returns `False`
Also, make sure to replace `` with your actual API key. These functionalities provide different levels of validation for what3words addresses, from simply identifying potential addresses to verifying their existence on Earth.
## 7. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
## 8. Full example
Complete Composer convert to 3 word address example:
**PHP**
```php
");
$options = [
AutoSuggestOption::clipToCountry("FR"),
AutoSuggestOption::focus(48.856618, 2.3522411),
AutoSuggestOption::numberResults(1)
];
$result = $api->autosuggest("inder.dweii.coo", $options);
if ($result)
{
print "Top 3 word address match: " . $result["suggestions"][0]["words"];
print " in " . $result["suggestions"][0]["nearest-place"] . "\n";
}
else
print "Error with code " . $error["code"] . ": " . $error["message"] . ":\n";
?>
```
---
# Python
Getting started with the what3words Python API wrapper.
Topics: Python, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/python
Updated: 2026-11-27
The Python wrapper is useful for Python developers who wish to seamlessly integrate the [what3words Public API](https://docs.what3words.com/api/v3/) into their Python applications, without the hassle of having to manage the low level API calls themselves.
A full example of how to integrate the what3words Python wrapper is available in our
[Python Github repository](https://github.com/what3words/w3w-python-wrapper)
## 1. Get API key
You will need this API key for your installation. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
The library is available through [PyPi](https://pypi.org/project/what3words/). To install what3words, simply:
**Python**
```python
pip install what3words
```
## 3. Setup
You need to import the library
**Python**
```python
import what3words
```
## 4. Initialise
By default, the wrapper will point to the public version of the what3words API. However, if required, the wrapper can be configured to point to a custom endpoint, for example a locally running version of the API. In this case an optional `end_point` parameter can be passed to the `what3words.Geocoder` constructor.
**Python**
```python
# Using the Public API:
geocoder = what3words.Geocoder("what3words-api-key")
```
**Python**
```python
# Using the API Server:
geocoder = what3words.Geocoder("what3words-api-key", end_point='http://localhost:8080/v3')
```
## 5. Usage
### Convert to what3words address
This function converts coordinates (expressed as latitude and longitude) to a what3words address.
More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (`51.484463, -0.195405`):
**Python**
```python
res = geocoder.convert_to_3wa(what3words.Coordinates(51.484463, -0.195405))
print(res)
```
### Convert to coordinates
This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of a what3words `'table.book.chair'`
More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///prom.cape.pump`:
**Python**
```python
res = geocoder.convert_to_coordinates('prom.cape.pump')
print(res)
```
### AutoSuggest
When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `Focus` to user’s current location. This will make `AutoSuggest` return results which are closer to the user.
More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Code example** Simple basic call:
**Python**
```python
res = geocoder.autosuggest('filled.count.soap')
print(res)
```
**Code example** AutoSuggest, clipping the results returned to the United Kingdom and Belgium:
**Python**
```python
res = geocoder.autosuggest('filled.count.soap', clip_to_country="GB,BE")
print(res)
```
**Code example** AutoSuggest, Focus on (`51.4243877,-0.34745`).
**Python**
```python
res = geocoder.autosuggest('filled.count.soap', \
focus=what3words.Coordinates(51.4243877,-0.34745))
print(res)
```
**Code example** AutoSuggest, with Generic Voice input type.
**Python**
```python
res = geocoder.autosuggest('fun with code', input_type='generic-voice', language='en')
print(res)
```
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for `52.207988,0.116126`) in the south west, and `52.208867,0.117540` in the north east:
**Python**
```python
sw = what3words.Coordinates(52.207988,0.116126)
ne = what3words.Coordinates(52.208867,0.117540)
bb = what3words.BoundingBox(sw, ne)
res = geocoder.grid_section(bb)
print(res)
```
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**Python**
```python
res = geocoder.available_languages()
print(res)
```
### Handling errors
Errors returned from the API can be caught with the wrapper through the use of a `catch` function.
Within the `catch` function, `code` and `message` values which represent the error, are accessible from the `error` object parameter
**Python**
```python
autosuggest = geocoder.autosuggest('freshen.overlook.clo', clip_to_country="FR")
if 'error' in autosuggest: # An error has been returned from the API
code = autosuggest['error']['code']
message = autosuggest['error']['message']
print (code, message)
```
## 6. RegEx Functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `is_possible_3wa` – Match what3words address format;
- `is_valid_3wa` – Verify a what3words address with the API;
### is\_possible\_3wa
Our API wrapper RegEx function “`is_possible_3wa`” can be used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `is_valid_3wa` to verify validity.
**Python**
```python
import what3words
def main():
# Initialize the What3Words API with your API key
api_key = 'YOUR_API_KEY'
w3w = what3words.Geocoder(api_key)
# Example what3words addresses
addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"]
# Check if the addresses are possible what3words addresses
for address in addresses:
is_possible = w3w.is_possible_3wa(address)
print(f"Is '{address}' a possible what3words address? {is_possible}")
if __name__ == "__main__":
main()
```
#### Expected Output
- is\_possible\_3wa(“filled.count.soap”) returns `true`
- is\_possible\_3wa(“not a 3wa”) returns `false`
- is\_possible\_3wa(“not.3wa address”)returns `false`
### is\_valid\_3wa
Our API wrapper RegEx function “`is_valid_3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**Python**
```python
import what3words
def main():
# Initialize the what3words API with your API key
api_key = 'YOUR_API_KEY'
w3w = what3words.Geocoder(api_key)
# Example addresses
addresses = [
"filled.count.soap",
"filled.count.",
"coding.is.cool"
]
# Check if the addresses are valid what3words addresses
for address in addresses:
is_valid = w3w.is_valid_3wa(address)
print(f"Is '{address}' a valid what3words address? {is_valid}")
if __name__ == "__main__":
main()
```
#### Expected Outputs
- is\_valid\_3wa(“filled.count.soap”) returns `True`
- is\_valid\_3wa(“filled.count.”) returns `False`
- is\_valid\_3wa(“coding.is.cool”) returns `False`
Also, make sure to replace `` with your actual API key. These functionalities provide different levels of validation for what3words addresses, from simply identifying potential addresses to verifying their existence on Earth.
## 7. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
## 8. Full example
The example below takes the concepts described above, and turns some of them into a complete example. Here we take a partial 3 word address and pass it into AutoSuggest – clipping the results to consider only addresses in France, setting a focus of Paris, and returning a single result
We then take the result and convert the 3 word address to coordinates, and find the nearest place.
**Python**
```python
import what3words
from os import environ
geocoder = what3words.Geocoder("what3words-api-key")
autosuggest = geocoder.autosuggest('freshen.overlook.clo', \
clip_to_country="FR", \
focus=what3words.Coordinates(48.856618, 2.3522411), \
n_results=1, \
)
if 'error' in autosuggest: # An error has been returned from the API
code = autosuggest['error']['code']
message = autosuggest['error']['message']
print (code, message)
else:
# Obtains the one, and only result from the returned list of suggestions
words = autosuggest['suggestions'][0]['words']
print("Top 3 word address match: {}".format(words))
# Use the `convert_to_coordinates` API to convert the returned 3 word address into coordinates
convert_to_coordinates = geocoder.convert_to_coordinates(words)
print("WGS84 Coordinates: {}, {}".format( \
convert_to_coordinates['coordinates']['lat'], \
convert_to_coordinates['coordinates']['lng']))
print("Nearest Place: {}".format(convert_to_coordinates['nearestPlace']))
```
---
# Ruby
Getting started with the what3words Ruby API wrapper.
Topics: Ruby, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/ruby
Updated: 2026-11-27
The Ruby wrapper is useful for Ruby developers who wish to seamlessly integrate the [what3words Public API](https://developer.what3words.com/public-api) into their Ruby applications, without the hassle of having to manage the low level API calls themselves.
A full example of how to integrate the what3words Ruby wrapper is available in our **[GitHub repository](https://github.com/what3words/w3w-ruby-wrapper).**
## 1. Get API key
You will need this API key for your installation. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
The library is available through [RubyGems](https://rubygems.org/gems/what3words).
You can simply add this line to your application’s Gemfile:
**Ruby**
```ruby
gem 'what3words', '~> 3.4'
```
And then execute:
**Ruby**
```ruby
bundle
```
Or install it yourself as:
**Ruby**
```ruby
gem install what3words
```
## 3. Setup
If not using Bundler, require it:
**Ruby**
```ruby
require 'what3words'
```
## 4. Initialise
The wrapper will point to the public version of the what3words API, to initialise it simply:
**Ruby**
```ruby
what3words = What3Words::API.new(:key => "YOURAPIKEY")
```
## 5. Usage
### Convert to what3words address
This function converts coordinates (expressed as latitude and longitude) to a what3words address.
More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (`29.567041, 106.587875`):
**Ruby**
```ruby
what3words.convert_to_3wa [29.567041, 106.587875]
# Expected Output
# => {:country=>"CN", :square=>{:southwest=>{:lng=>106.58786, :lat=>29.567028}, :northeast=>{:lng=>106.587891, :lat=>29.567055}}, :nearestPlace=>"Chongqing", :coordinates=>{:lng=>106.587875, :lat=>29.567041}, :words=>"disclose.strain.redefined", :language=>"en", :map=>"https://w3w.co/disclose.strain.redefined"}
```
### Convert to coordinates
This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of a what3words `'table.book.chair'`
More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///prom.cape.pump`:
**Ruby**
```ruby
what3words.convert_to_coordinates "prom.cape.pump"
# Expected Output
# => {:country=>"GB", :square=>{:southwest=>{:lng=>-0.195426, :lat=>51.484449}, :northeast=>{:lng=>-0.195383, :lat=>51.484476}}, :nearestPlace=>"Kensington, London", :coordinates=>{:lng=>-0.195405, :lat=>51.484463}, :words=>"prom.cape.pump", :language=>"en", :map=>"https://w3w.co/prom.cape.pump"}
```
### AutoSuggest
When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `Focus` to user’s current location. This will make `AutoSuggest` return results which are closer to the user.
More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Code example** Simple basic call:
**Ruby**
```ruby
what3words.autosuggest 'trop.caler.perdre', language: 'fr'
# Expected Output
# => {:suggestions=>[{:country=>"FR", :nearestPlace=>"Saint-Lary-Soulan, Hautes-Pyrénées", :words=>"trier.caler.perdre", :rank=>1, :language=>"fr"}, {:country=>"ET", :nearestPlace=>"Asbe Teferi, Oromiya", :words=>"trôler.caler.perdre", :rank=>2, :language=>"fr"}, {:country=>"CN", :nearestPlace=>"Ulanhot, Inner Mongolia", :words=>"froc.caler.perdre", :rank=>3, :language=>"fr"}]}
```
**Code example** AutoSuggest, clipping the results returned to the United Kingdom and Belgium:
**Ruby**
```ruby
what3words.autosuggest 'disclose.strain.redefin', 'clip-to-country': 'GB,BE'
# Expected Output
# => {:suggestions=>[{:country=>"GB", :nearestPlace=>"Nether Stowey, Somerset", :words=>"disclose.retrain.redefined", :rank=>1, :language=>"en"}, {:country=>"BE", :nearestPlace=>"Zemst, Flanders", :words=>"disclose.strain.reckon", :rank=>2, :language=>"en"}, {:country=>"GB", :nearestPlace=>"Waddington, Lincolnshire", :words=>"discloses.trains.redefined", :rank=>3, :language=>"en"}]}
```
**Code example** AutoSuggest, Focus on (`51.4243877,-0.34745`).
**Ruby**
```ruby
what3words.autosuggest 'filled.count.soap', focus: [51.4243877,-0.34745]
# Expected Output
# => {:suggestions=>[{:country=>"GB", :nearestPlace=>"Bayswater, London", :words=>"filled.count.soap", :rank=>1, :distanceToFocusKm=>15, :language=>"en"}, {:country=>"GB", :nearestPlace=>"Orsett, Essex", :words=>"fills.count.slap", :rank=>2, :distanceToFocusKm=>48, :language=>"en"}, {:country=>"GB", :nearestPlace=>"Cobham, Surrey", :words=>"field.count.slap", :rank=>3, :distanceToFocusKm=>14, :language=>"en"}]}
```
**Code example** AutoSuggest, with Generic Voice input type.
**Ruby**
```ruby
what3words.autosuggest 'fun with code', 'input-type': 'generic-voice', language: 'en'
# Expected Output
# => {:suggestions=>[{:country=>"US", :nearestPlace=>"Homer, Alaska", :words=>"fund.with.code", :rank=>1, :language=>"en"}, {:country=>"AU", :nearestPlace=>"Kumpupintil, Western Australia", :words=>"funk.with.code", :rank=>2, :language=>"en"}, {:country=>"US", :nearestPlace=>"Charleston, West Virginia", :words=>"fund.with.cove", :rank=>3, :language=>"en"}]}
```
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for `52.207988,0.116126`) in the south west, and `52.208867,0.117540` in the north east:
**Ruby**
```ruby
what3words.grid_section '52.208867,0.117540,52.207988,0.116126'
# Expected Output
# => {:lines=>[{:start=>{:lng=>0.116126, :lat=>52.20801}, :end=>{:lng=>0.11754, :lat=>52.20801}}, {:start=>{:lng=>0.116126, :lat=>52.208037}, :end=>{:lng=>0.11754, :lat=>52.208037}}, {:start=>{:lng=>0.116126, :lat=>52.208064}, :end=>{:lng=>0.11754, :lat=>52.208064}}, ___...___ ]}
```
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**Ruby**
```ruby
what3words.available_languages
# Expected Output
# => {:languages=>[{:nativeName=>"Deutsch", :code=>"de", :name=>"German"}, {:nativeName=>"हिन्दी", :code=>"hi", :name=>"Hindi"}, {:nativeName=>"Português", :code=>"pt", :name=>"Portuguese"}, {:nativeName=>"Magyar", :code=>"hu", :name=>"Hungarian"}, {:nativeName=>"Українська", :code=>"uk", :name=>"Ukrainian"}, {:nativeName=>"Bahasa Indonesia", :code=>"id", :name=>"Bahasa Indonesia"}, {:nativeName=>"اردو", :code=>"ur", :name=>"Urdu"}, ___...___]}
```
### Handling errors
Errors returned from the API can be caught with the wrapper through the use of a `raise` function.
Within the `raise` function, `code` and `message` values which represent the error, are accessible from the `error` object parameter
**Ruby**
```ruby
if response['error'].to_s.strip != ''
raise ResponseError, "#{response['code']}: #{response['message']}"
end
```
## 6. RegEx Functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `isPossible3wa` – Match what3words address format;
- `isValid3wa` – Verify a what3words address with the API;
### isPossible3wa
Our API wrapper RegEx function “`isPossible3wa`” can be used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `isValid3wa` to verify validity.
**Ruby**
```ruby
require 'what3words'
def main
# Initialize the What3Words API with your API key
api_key = 'YOUR_API_KEY'
w3w = What3Words::API.new(:key => api_key)
# Example what3words addresses
addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"]
# Check if the addresses are possible what3words addresses
addresses.each do |address|
is_possible = w3w.isPossible3wa(address)
puts "Is '#{address}' a possible what3words address? #{is_possible}"
end
end
if __FILE__ == $0
main
end
```
#### Expected Output
- isPossible3wa(“filled.count.soap”) returns `true`
- isPossible3wa(“not a 3wa”) returns `false`
- isPossible3wa(“not.3wa address”)returns `false`
### isValid3wa
Our API wrapper RegEx function “`isValid3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**Ruby**
```ruby
require 'what3words'
def main
# Initialize the what3words API with your API key
api_key = 'YOUR_API_KEY'
w3w = What3Words::API.new(:key => api_key)
# Example addresses
addresses = [
"filled.count.soap",
"filled.count.",
"coding.is.cool"
]
# Check if the addresses are valid what3words addresses
addresses.each do |address|
is_valid = w3w.isValid3wa(address)
puts "Is '#{address}' a valid what3words address? #{is_valid}"
end
end
if __FILE__ == $0
main
end
```
#### Expected Outputs
- isValid3wa(“filled.count.soap”) returns `True`
- isValid3wa(“filled.count.”) returns `False`
- isValid3wa(“coding.is.cool”) returns `False`
Also make sure to replace `` with your actual API key. These functionalities provide different levels of validation for what3words addresses, from simply identifying potential addresses to verifying their existence on Earth.
## 7. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
## 8. Full example
The example below takes the concepts described above, and turns some of them into a complete example. Here we take a partial 3 word address and pass it into AutoSuggest – clipping the results to consider only addresses in Great Britain and Belgium, setting a focus, and returning a single result
We then take the result and convert the 3 word address to coordinates, and vice-versa.
**Ruby**
```ruby
# frozen_string_literal: true
#!/usr/bin/env
require 'what3words'
require 'json'
api_key = ENV['W3W_API_KEY']
what3words = What3Words::API.new(:key => api_key, :format => 'json')
# ## convert_to_coordinates #########
res = what3words.convert_to_coordinates 'prom.cape.pump'
puts '######### convert_to_coordinate #########'
puts res
# ## convert_to_3wa #########
res = what3words.convert_to_3wa [29.567041, 106.587875]
puts '######### convert_to_3wa #########'
puts res
# ## grid_section #########
res = what3words.grid_section '52.208867,0.117540,52.207988,0.116126'
puts '######### grid_section #########'
puts res
# ## available_languages #########
res = what3words.available_languages
puts '######### available_languages #########'
puts res
# ## Vanilla autosuggest, limiting the number of results to three #########
res = what3words.autosuggest 'disclose.strain.redefin', language: 'en', 'n-results': 10
puts '######### autosuggest n-results #########'
puts res
# ## autosuggest demonstrating clipping to polygon, circle, bounding box, and country #########
res_polygon = what3words.autosuggest 'disclose.strain.redefin', 'clip-to-polygon': [51.521, -0.343, 52.6, 2.3324, 54.234, 8.343, 51.521, -0.343]
res_circle = what3words.autosuggest 'disclose.strain.redefin', 'clip-to-circle': [51.521, -0.343, 142]
res_bbox = what3words.autosuggest 'disclose.strain.redefin', 'clip-to-bounding-box': [51.521, -0.343, 52.6, 2.3324]
res_country = what3words.autosuggest 'disclose.strain.redefin', 'clip-to-country': 'GB,BE'
puts '######### autosuggest clipping options #########'
puts res_polygon
puts res_circle
puts res_bbox
puts res_country
# ## autosuggest with a focus, with that focus only applied to the first result #########
res = what3words.autosuggest 'filled.count.soap', focus: [51.4243877, -0.34745], 'n-focus-results': 3, 'n-results': 10
puts '######### autosuggest with a focus ######### '
puts res
# ## autosuggest with an input type of Generic Voice #########
res = what3words.autosuggest 'fun with code', 'input-type': 'generic-voice', language: 'en'
puts '######### autosuggest with Generic Voice as input type ######### '
puts res
# ## isPossible3wa #########
addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"]
addresses.each do |address|
is_possible = what3words.isPossible3wa(address)
puts "Is '#{address}' a possible what3words address? #{is_possible}"
end
# ## isValid3wa #########
addresses = ["filled.count.soap", "filled.count.", "coding.is.cool"]
addresses.each do |address|
is_valid = what3words.isValid3wa(address)
puts "Is '#{address}' a valid what3words address? #{is_valid}"
end
```
---
# Rust
Getting started with the what3words Rust API wrapper.
Topics: Rust, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/rust
Updated: 2026-11-27
The Rust wrapper is useful for Rust developers who wish to seamlessly integrate the [what3words Public API](https://docs.what3words.com/api/v3/) into their Rust applications, without the hassle of managing the low-level API calls themselves.
A full example of how to integrate the what3words Rust wrapper is available in our
[Rust Github repository](https://github.com/what3words/w3w-rust-wrapper)
## 1. Get API key
You will need this API key for your installation. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
To install what3words, simply:
**Rust**
```rust
$ cargo add what3words-api
```
## 3. Setup
The functions are asynchronous by default, but this crate supports synchronous functions as well, simply enable `sync` feature when adding the crate to your project.
**Rust**
```rust
cargo add what3words-api --features=sync
```
> [!NOTE]
> **Note:** Ensure that you have an async runtime installed such as `tokio` except when `sync` feature is enabled.
## 4. Initialise
Once you have the API Key, you can initialise the wrapper like this:
**Rust**
```rust
let wrapper = what3words_api::What3words::new("YOUR_API_KEY_HERE");
```
You can also pass a different hostname if you have your own self-hosted what3words API.
**Rust**
```rust
let wrapper = what3words_api::What3words::new("YOUR_API_KEY_HERE").hostname("https://your.what3words.api/v3");
```
You can also set configure your own headers:
**Rust**
```rust
let wrapper = what3words_api::What3words::new("YOUR_API_KEY_HERE").header("X-Foo", "Bar");
```
## 5. Usage
### Convert to what3words address
This function converts coordinates (expressed as latitude and longitude) to a what3words address.
More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (`51.520847, -0.195405`):
**Rust**
```rust
let convert_to_3wa = what3words_api::ConvertTo3wa::new(51.520847, -0.195521).language("oo").locale("oo_cy");
```
Here is an example:
**Rust**
```rust
use what3words_api::{Address, AddressGeoJson, ConvertTo3wa, What3words};
let w3w = What3words::new("YOUR_API_KEY_HERE");
let convert_to_3wa = ConvertTo3wa::new(51.520847, -0.195521).language("mn").locale("mn_la");
let address_json: Address = w3w.convert_to_3wa::(&convert_to_3wa);
println!("{:?}", address_json.words); // "seruuhen.zemseg.dagaldah"
let convert_to_3wa = ConvertTo3wa::new(51.520847, -0.195521);
let address_geojson: Address = w3w.convert_to_3wa::(&convert_to_3wa);
println!("{:?}", address_geojson.features); // [Feature { bbox: Some[-0.195543, 51.520833], ..., }]
```
> [!NOTE]
> **Note:** It is required to specify the type annotation for this function which will allow you to choose between `json` and `geojson` format. Using `Address` will use `json` (default) and `AddressGeoJson` will use `geojson`.
### Convert to coordinates
This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of a what3words `'table.book.chair'`
More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///filled.count.soap`:
**Rust**
```rust
let convert_to_coordinates = what3words_api::ConvertToCoordinates::new("filled.count.soap").locale("zh_tr");
```
Here is an example:
**Rust**
```rust
use what3words_api::{Address, AddressGeoJson, ConvertToCoordinates, What3words};
let w3w = What3words::new("YOUR_API_KEY_HERE");
let convert_to_coordinates = ConvertToCoordinates::new("產權.絕緣.墨鏡").locale("zh_tr");
let address_json: Address = w3w.convert_to_coordinates::(&convert_to_coordinates);
println!("{:?}", address_json.coordinates); // Coordinates { lat: 51.520847, lng: -0.195521 }
let convert_to_coordinates = ConvertToCoordinates::new("filled.count.soap");
let address_geojson: AddressGeoJson = w3w.convert_to_coordinates::(&convert_to_coordinates);
println!("{:?}", address_geojson.features); // [Feature { bbox: Some[-0.195543, 51.520833], ..., }]
```
> [!NOTE]
> **Note:** It is required to specify the type annotation for this function which will allow you to choose between `json` and `geojson` format. Using `Address` will use `json` (default) and `AddressGeoJson` will use `geojson`.
### AutoSuggest
When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `Focus` to user’s current location. This will make `AutoSuggest` return results which are closer to the user.
More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Code example** Simple basic call:
**Rust**
```rust
let autosuggest = what3words_api::Autosuggest::new("filled.count.so");
```
**Code example** AutoSuggest, clipping the results returned to the United Kingdom and Belgium:
**Rust**
```rust
let autosuggest = what3words_api::Autosuggest::new("filled.count.so").clip_to_country(&["GB","BE"])
```
**Code example** AutoSuggest, Focus on (`51.4243877,-0.34745`).
**Rust**
```rust
let autosuggest = what3words_api::Autosuggest::new("filled.count.so").focus(&Coordinates::new(51.4243877, -0.34745));
```
**Code example** AutoSuggest, with Generic Voice input type.
**Rust**
```rust
use std::env;
use what3words_api::{Autosuggest, What3words};
fn main() {
let api_key = env::var("W3W_API_KEY").expect(
"Please ensure that W3W_API_KEY is added to your environment variables.\nRun `W3W_API_KEY= cargo run --example wrapper-demo` from bash/zsh or `$Env:W3W_API_KEY=; cargo run --example wrapper-demo` from PowerShell.",
);
let w3w = What3words::new(&api_key);
let autosuggest_option = Autosuggest::new("filled.count.soa")
.input_type("generic-voice")
.language("en");
let result = w3w.autosuggest(&autosuggest_option);
print!("Result: {:?}", result);
}
```
Here is a full AutoSuggest example:
**Rust**
```rust
use what3words_api::{Autosuggest, AutosuggestResult, What3words};
let w3w = What3words::new("YOUR_API_KEY_HERE");
let autosuggest_option = Autosuggest::new("filled.count.so").focus(&Coordinates::new(51.520847, -0.195521));
let autosuggest: AutosuggestResult = w3w.autosuggest(&autosuggest_option);
println!("{:?}", autosuggest.suggestions); // [Suggestion { words: "filled.count.soap", ..., ... }, ..., ...]
```
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for `52.207988,0.116126`) in the south west, and `52.208867,0.117540` in the north east:
**Rust**
```rust
use what3words_api::{BoundingBox, GridSection, GridSectionGeoJson, What3words};
let w3w: What3words = What3words::new("YOUR_API_KEY_HERE");
// json format
let grid_section_json: GridSection = w3w.grid_section::(&BoundingBox::new(52.207988,0.116126,52.208867,0.117540));
println!("{:?}", &grid_section_json.lines[0]); // Line { start: Coordinates { lat: 52.20801, lng: 0.116126 }, end: Coordinates { lat: 52.20801, lng: 0.11754 } }
// geojson format
let grid_section_geojson: GridSectionGeoJson = w3w.grid_section::(&BoundingBox::new(52.207988,0.116126,52.208867,0.117540));
println!("{:?}", &grid_section_geojson.features); // [Features { geometry: ..., }, ..., ..., kind: "Feature"]
```
> [!NOTE]
> **Note:** It is required to specify the type annotation for this function which will allow you to choose between `json` and `geojson` format. Using `GridSection` will use `json` (default) and `GridSectionGeoJson` will use `geojson`.
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**Rust**
```rust
use what3words_api::{AvailableLanguages, What3words};
let w3w: What3words = What3words::new("YOUR_API_KEY_HERE");
let available_languages: AvailableLanguages = w3w.available_languages();
println!("{:?}", available_languages.languages); // [Language { code: "en", ..., ... }, ..., ... ]
```
### Handling errors
In Rust, error handling is managed using the Result and Option types, which encapsulate potential success (Ok or Some) and failure (Err or None) outcomes. The `what3words-api` Rust crate adheres to this convention, returning a Result type for operations that may fail.
To handle errors effectively using this crate, you can utilize pattern matching to differentiate between successful and erroneous outcomes. Here’s an example demonstrating how to handle errors when converting a what3words address to coordinates:
**Rust**
```rust
use what3words_api::What3words;
fn main() {
// Initialize the what3words API with your API key
let api_key = "YOUR_API_KEY_HERE";
let w3w = What3words::new(api_key);
// Example 3-word address
let address = "filled.count.soap";
// Attempt to convert the 3-word address to coordinates
match w3w.convert_to_coordinates(address) {
Ok(coordinates) => {
println!("Coordinates for '{}': {:?}", address, coordinates);
}
Err(e) => {
eprintln!("Error converting '{}': {}", address, e);
}
}
}
```
**Explanation:**
**Initialisation:** The what3words struct is initialised with your API key. Ensure you replace “YOUR\_API\_KEY\_HERE” with your actual what3words API key.
**Conversion Attempt:** The convert\_to\_coordinates method is called with the what3words address. This method returns a Result, which can be either:
- Ok(coordinates): Contains the coordinates if the conversion is successful.
- Err(e): Contains the error if the conversion fails.
**Error Handling:** The match statement is used to handle both success and error cases:
- On success, the coordinates are printed.
- On error, the error’s code and message are accessed and printed to the standard error output.
This approach ensures that your application can handle potential errors gracefully, such as network issues, invalid API keys, or incorrect what3words addresses.
For more detailed information on error handling in Rust, you can refer to the official Rust documentation on [Error Handling](https://doc.rust-lang.org/book/ch09-00-error-handling.html).
## 6. RegEx Functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `is_possible_3wa` – Match what3words address format;
- `is_valid_3wa` – Verify a what3words address with the API;
### is\_possible\_3wa
Our API wrapper RegEx function “`is_possible_3wa`” can be used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `is_valid_3wa` to verify validity.
**Rust**
```rust
use what3words_api::What3words;
fn main() {
// Initialize the what3words API with your API key
let api_key = "YOUR_API_KEY_HERE";
let w3w = What3words::new(api_key);
// Example what3words addresses
let addresses = [
"filled.count.soap",
"not a 3wa",
"not.3wa address",
];
// Check if the addresses are possible what3words addresses
for address in &addresses {
let is_possible = w3w.is_possible_3wa(address);
println!("Is '{}' a possible what3words address? {}", address, is_possible);
}
}
```
#### Expected Output
- `is_possible_3wa`(“filled.count.soap”) returns `true`
- `is_possible_3wa`(“not a 3wa”) returns `false`
- `is_possible_3wa`(“not.3wa address”) returns `false`
### is\_valid\_3wa
Our API wrapper RegEx function “`is_valid_3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**Rust**
```rust
use what3words_api::What3words;
fn main() {
// Initialize the what3words API with your API key
let api_key = "YOUR_API_KEY_HERE";
let w3w = What3words::new(api_key);
// Example addresses
let addresses = vec![
"filled.count.soap",
"filled.count.",
"coding.is.cool",
];
// Check if each address is a valid what3words address
for address in addresses {
let is_valid = w3w.is_valid_3wa(address);
println!("Is '{}' a valid what3words address? {}", address, is_valid);
}
}
```
#### Expected Outputs
- `is_valid_3wa`(“filled.count.soap”) returns `True`
- `is_valid_3wa`(“filled.count.”) returns `False`
- `is_valid_3wa`(“coding.is.cool”) returns `False`
Also, make sure to replace `` with your actual API key. These functionalities provide different levels of validation for what3words addresses, from simply identifying potential addresses to verifying their existence on Earth.
## 7. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
## 8. Full example
Examples can be found in `/examples` directory of our , simply run the following to try it out:
[Rust Github repository](https://github.com/what3words/w3w-rust-wrapper)
**Rust (sync)**
```rust
# Blocking
$ W3W_API_KEY= cargo run --example sync --features="sync"
```
**Rust (async)**
```rust
# Non-blocking
$ W3W_API_KEY= cargo run --example async --features="async"
```
**Rust (sync)**
```rust
use std::env;
use what3words_api::{
Address, AddressGeoJson, Autosuggest, AutosuggestSelection, BoundingBox, ConvertTo3wa,
ConvertToCoordinates, Coordinates, Error, GridSection, GridSectionGeoJson, What3words,
};
fn main() -> Result<(), Error> {
let api_key = env::var("W3W_API_KEY").expect(
"Please ensure that W3W_API_KEY is added to your environment variables.\nRun `W3W_API_KEY= cargo run --example wrapper-demo` from bash/zsh or `$Env:W3W_API_KEY=; cargo run --example wrapper-demo` from PowerShell.",
);
let w3w = What3words::new(&api_key).header("X-Foo", "Bar");
let words = "filled.count.soap";
// ------ CONVERT TO COORDINATES/3WA ------
// ------ Error ------
let address = w3w.convert_to_coordinates::(&ConvertToCoordinates::new("filled.count"));
match address {
Ok(address) => println!("Address {:?}", address),
Err(error) => println!("Error {:?}", error),
}
// -------------------
let convert_to_coordinates = ConvertToCoordinates::new(words);
let address: Address = w3w.convert_to_coordinates(&convert_to_coordinates)?;
println!("Convert to Coordinates Json Format");
println!("{:?}", address);
let convert_to_coordinates = ConvertToCoordinates::new(words);
let address: AddressGeoJson = w3w.convert_to_coordinates(&convert_to_coordinates)?;
println!("Convert to Coordinates GeoJson Format");
println!("{:?}", address);
let convert_to_3wa = ConvertTo3wa::new(51.520847, -0.195521);
let address: Address = w3w.convert_to_3wa(&convert_to_3wa)?;
println!("Convert to 3WA Json Format");
println!("{:?}", address);
let convert_to_3wa = ConvertTo3wa::new(51.520847, -0.195521);
let address: AddressGeoJson = w3w.convert_to_3wa(&convert_to_3wa)?;
println!("Convert to 3WA GeoJson Format");
println!("{:?}", address);
// ------ ALL AVAILABLE LANGUAGES ------
let languages = w3w.available_languages()?;
println!("Available Languages");
println!("{:?}", languages.languages);
// ------ GRID SECTION ------
let grid_section_json: GridSection =
w3w.grid_section(&BoundingBox::new(52.207988, 0.116126, 52.208867, 0.117540))?;
println!("Grid Section Json Format");
println!("{:?}", grid_section_json);
let grid_section_geojson: GridSectionGeoJson =
w3w.grid_section(&BoundingBox::new(52.207988, 0.116126, 52.208867, 0.117540))?;
println!("Grid Section GeoJson Format");
println!("{:?}", grid_section_geojson);
// ------ AUTOSUGGEST ------
let autosuggest_option =
Autosuggest::new("filled.count.so").focus(&Coordinates::new(51.520847, -0.195521));
let autosuggest = w3w.autosuggest(&autosuggest_option)?;
println!("Autosuggest");
println!("{:?} ", autosuggest);
// ------ AUTOSUGGEST WITH COORDINATES ------
let autosuggest_with_coordinates = w3w.autosuggest_with_coordinates(&autosuggest_option);
println!("Autosuggest with Coordinates");
match autosuggest_with_coordinates {
Ok(autosuggest_with_coordinates) => println!("{:?}", autosuggest_with_coordinates),
Err(err) => println!("{:?}", err),
}
// ------ AUTOSUGGEST SELECTION ------
let selected = autosuggest.suggestions.first().expect("Not found");
match w3w.autosuggest_selection(
&AutosuggestSelection::new("f.f.f", selected).options(&autosuggest_option),
) {
Ok(_) => println!("Suggested selection sent"),
Err(err) => println!("{:?}", err),
};
// ------ HELPER FUNCTIONS ------
let is_valid_3wa: bool = w3w.is_valid_3wa("filled.count.soap");
println!("is_valid_3wa [1]: {}", is_valid_3wa);
let is_valid_3wa: bool = w3w.is_valid_3wa("filled.count");
println!("is_valid_3wa [2]: {}", is_valid_3wa);
let is_valid_3wa: bool = w3w.is_valid_3wa("rust.is.cool");
println!("is_valid_3wa [3]: {}", is_valid_3wa);
let did_you_mean: bool = w3w.did_you_mean("filled count soap");
println!("did_you_mean [1]: {}", did_you_mean);
let did_you_mean: bool = w3w.did_you_mean("filled-count-soap");
println!("did_you_mean [2]: {}", did_you_mean);
let did_you_mean: bool = w3w.did_you_mean("filledcountsoap");
println!("did_you_mean [3]: {}", did_you_mean);
let is_possible_3wa: bool = w3w.is_possible_3wa("filled.count.soap");
println!("is_possible_3wa [1]: {}", is_possible_3wa);
let is_possible_3wa: bool = w3w.is_possible_3wa("not a 3wa");
println!("is_possible_3wa [2]: {}", is_possible_3wa);
let is_possible_3wa: bool = w3w.is_possible_3wa("not.a 3wa");
println!("is_possible_3wa [3]: {}", is_possible_3wa);
Ok(())
}
```
---
# Swift
Getting started with the what3words Swift API wrapper.
Topics: Swift, Mobile App, Server and Scripting
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [API Wrappers](https://developer.what3words.com/docs/api-sdk-reference/api-wrappers.md)
Source: https://developer.what3words.com/tutorial/swift
Updated: 2026-11-27
This what3words Swift wrapper gives you programmatic access to the what3Words public API v3.
The what3words API is a fast, simple interface which allows you to convert 3 word addresses such as ///filled.count.soap to latitude and longitude coordinates such as (`-0.203586, 51.521251`) and vice versa. It features a powerful AutoSuggest function, which can validate and autocorrect user input and limit it to certain geographic areas (this powers the search box on our map site). It allows you to request a section of the what3words grid (which can be requested as GeoJSON for easy display on online maps), and to request the list of all languages supported by what3words. For advanced users, AutoSuggest can be used to post-process voice output. See links on the left to navigate.
All coordinates are latitude,longitude pairs in standard WGS-84 (as commonly used worldwide in GPS systems). All latitudes must be in the range of -90 to 90 (inclusive).
Full sample apps for the wrapper can be found in our Github repo
[iOS Sample Apps](https://github.com/what3words/w3w-swift-samples)
## 1. Get API key
You will need this API key for your installation. [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
## 2. Installation
### Swift Package Manager
You can install this with [Swift Package Manager](https://swift.org/package-manager) by adding the URL below under **Swift Packages** under your project settings:
**Swift**
```swift
Swift Package Manager
```
### CocoaPods (iOS 9+, OS X 10.10+)
You can use CocoaPods to install w3w-swift-wrapper by adding it to the target in your Podfile:
**Swift**
```swift
pod 'what3words', :git => 'https://github.com/what3words/w3w-swift-wrapper.git'
```

Don’t forget, if you are running on a device you need to set the `App Transport Security Settings` in your `Info.plist` as you would any app communicating with a server

Also, if you are using the Voice API on device, you should include Microphone permissions
## 3. Setup
In any swift file you use the what3words API, import the following:
**Swift**
```swift
import W3WSwiftApi
import CoreLocation
```
## 4. Initialise
Use the following code with your API key to initialize the API:
**Swift**
```swift
# Using the Public API:
let api = What3WordsV4(apiKey: "YourApiKey")
```
**Swift**
```swift
# Using the API Server:
let api = What3WordsV4(apiKey: "YourApiKey", apiUrl: "https://api.yourserver.com")
```
Additionally, if you run the Enterprise Suite API Server there is another optional `setup()` parameter: `customHeaders`. Use this if you need to send custom headers to your own server:
**Swift**
```swift
let api = What3WordsV4(apiKey: "YourApiKey", apiUrl: "https://api.yourserver.com", customHeaders: ["x-header-1":"value-1", "x-header-2":"value-2"])
```
## 5. Usage
Each call takes a completion block as the last parameter. This allows Swift’s trailing closure syntax to be used. The closure’s parameters contain the results. If there is a problem with any call, it will be indicated by the [error object](https://github.com/what3words/w3w-swift-wrapper/tree/v4#errors).
### Convert to what3words address
This function converts coordinates (expressed as latitude and longitude) to a what3words address.
More information about `ConvertTo3wa`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-3wa).
Find the words for (`51.484463, -0.195405`):
**Swift**
```swift
let coords = CLLocationCoordinate2D(latitude: 51.484463, longitude: -0.195405)
api.convertTo3wa(coordinates: coords, language: W3WApiLanguage(locale: "en")) { square, error in
print(square?.words ?? "")
}
```
### Convert to coordinates
This function converts a what3words address to a position, expressed as coordinates of latitude and longitude.
It takes the words parameter as a string of a what3words `'table.book.chair'`
More information about `ConvertToCoordinates`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#convert-to-coordinates).
Find the words for `///prom.cape.pump`:
**Swift**
```swift
api.convertToCoordinates(words: "prom.cape.pump") { square, error in
print(square?.coordinates ?? "")
}
```
### AutoSuggest
When presented with a what3words address which may be incorrectly entered, AutoSuggest returns a list of potential correct 3 word addresses. It needs the first two words plus at least the first character of the third word to produce suggestions.
This method provides corrections for mis-typed words (including plural VS singular), and words being in the wrong order.
Optionally, clipping can narrow down the possibilities, and limit results to:
- One or more countries
- A geographic area (a circle, box or polygon)
This dramatically improves results, so we recommend that you use clipping if possible.
To improve results even further, set the `Focus` to user’s current location. This will make `AutoSuggest` return results which are closer to the user.
More information about `AutoSuggest`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#autosuggest).
**Code example** for an AutoSuggest basic call, the first parameter is the partial three words, or voice data. The second optional parameter is the options for the autosuggest function. The last parameter is the completion block.
**Swift**
```swift
api.autosuggest(text: "filled.count.soa") { (suggestions, error) in
for suggestion in suggestions ?? [] {
print("\(suggestion.words ?? "") is near \(suggestion.nearestPlace ?? "")")
}
}
```
**Code example** an AutoSuggest Focus on one particular place:
**Swift**
```swift
let coords = CLLocationCoordinate2D(latitude: 51.4243877, longitude: -0.34745)
api.autosuggest(text: "flottons.annulons.garço", options: W3WOption.focus(coords)) { (suggestions, error) in
print(suggestions ?? "")
}
```
**Code example** AutoSuggest, Focus on (51.4243877,-0.34745) and ask for suggestions from a French three word fragment:
**Swift**
```swift
let coords = CLLocationCoordinate2D(latitude: 51.4243877, longitude: -0.34745)
let options = W3WOptions().focus(coords).clip(to: W3WApiCountry(code: "GB"))
api.autosuggest(text: "flottons.annulons.garço", options: options) { (suggestions, error) in
print(suggestions ?? "")
}
```
**Code example** AutoSuggest, Voice API example.
The what3words Voice API allows a user to say three words into any application or service, with it returning a configurable list of what3words address suggestions, all through a single API call.
For this to work, you must add a Voice API plan to [your account](https://accounts.what3words.com/billing).
This example instantiates a `W3WMicrophone` which provides an audio stream to `autosuggest(audio:)` which begins recording when `autosuggest` is called. For information on `W3WMicrophone` and customizing your own `W3WAudioStream` for `autosuggest(audio:)` see the [Voice API readme file](https://github.com/what3words/w3w-swift-wrapper/blob/v4/Documentation/README.voiceAPI.md).
**Swift**
```swift
// make a microphone
let microphone = W3WMicrophone()
// call autosuggest
api.autosuggest(audio: microphone, options: .voiceLanguage(W3WApiLanguage(locale: "en"))) { suggestions, error in
for suggestion in suggestions ?? [] {
print(suggestion.words ?? "no suggestions")
}
}
```
Also, `W3WMicrophone` has a callback closure `W3WMicrophone.volumeUpdate: (Double) -> ()` that provides amplitude information useful for animating user feedback. See the [Voice API example](https://github.com/what3words/w3w-swift-wrapper/blob/v4/Examples/VoiceAPI/VoiceAPI.xcodeproj), and more information is available in the [Voice API readme file](https://github.com/what3words/w3w-swift-wrapper/blob/v4/Documentation/README.voiceAPI.md).
### Grid section
Grid section returns a section of the what3words 3m x 3m grid as a set of horizontal and vertical lines covering the requested area, which can then be drawn onto a map.
The requested box must not exceed 4km from corner to corner, or a `BadBoundingBoxTooBig` error will be returned.
More information about `GridSection`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#grid-section).
Get a grid for `52.207988,0.116126`) in the south west, and `52.208867,0.117540` in the north east:
**Swift**
```swift
let southWest = CLLocationCoordinate2D(latitude: 52.208867, longitude: 0.117540)
let northEast = CLLocationCoordinate2D(latitude: 52.207988, longitude: 0.116126)
api.gridSection(southWest: southWest, northEast: northEast) { (lines, error) in
print("Line count: ", lines?.count ?? "zero")
}
```
### Available languages
This function returns the currently supported languages. It will return the two letter code, and the name of the language both in that language and in English.
More information about `AvailableLanguages`, including returned results is available in the [what3words REST API documentation](https://docs.what3words.com/api/v3/#available-languages).
**Swift**
```swift
api.availableLanguages() { (languages, error) in
for language in languages ?? [] {
print(language.code)
}
}
```
### Handling errors
All functions call the completion block with `error` as the second parameter. All Swift what3words `error` types are of `enum` type and conform to [CustomStringConvertible](https://developer.apple.com/documentation/swift/customstringconvertible), so they can be used with `String(describing: error)`:
**Swift**
```swift
api.convertTo3wa(coordinates: CLLocationCoordinate2D(latitude: 51.4243877, longitude: -0.34745)) { square, error in
if let e = error {
print(String(describing: e))
} else {
print(square?.words ?? "")
}
}
```
Api call errors are of type `W3WError` enum and the voice `autosuggest` call returns a `W3WVoiceError` enum.
## 6. RegEx Functions
This section introduces RegEx functions that can assist with checking and finding possible what3words addresses in strings. The three main functions covered are:
- `isPossible3wa` – Match what3words address format;
- `isValid3wa` – Verify a what3words address with the API;
### isPossible3wa
Our API wrapper RegEx function “`isPossible3wa`” can be used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
**Note**: This function checks the text format but not the validity of a what3words address. Use `isValid3wa` to verify validity.
**Swift**
```swift
import W3WSwiftApi
import CoreLocation
func main() {
// Initialize the What3Words API with your API key
let api = What3WordsV4(apiKey: "YOUR_API_KEY")
// Example what3words addresses
let addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"]
// Check if the addresses are possible what3words addresses
for address in addresses {
let isPossible = api.isPossible3wa(text: address)
print("Is '\(address)' a possible what3words address? \(isPossible)")
}
}
main()
```
#### Expected Output
- isPossible3wa(“filled.count.soap”) returns `true`
- isPossible3wa(“not a 3wa”) returns `false`
- isPossible3wa(“not.3wa address”)returns `false`
### isValid3wa
Our API wrapper RegEx function “`isValid3wa`” can be used to determine if a string is a valid what3words address by checking it against the what3words RegEx filter and verifying it with the what3words API.
**Swift**
```swift
import W3WSwiftApi
import CoreLocation
func main() {
// Initialize the what3words API with your API key
let apiKey = "YOUR_API_KEY"
let api = What3WordsV4(apiKey: apiKey)
// Example addresses
let addresses = [
"filled.count.soap",
"filled.count.",
"coding.is.cool"
]
// Check if the addresses are valid what3words addresses
for address in addresses {
api.isValid3wa(words: address) { result in
if result == true {
print("'\(address)' is a valid what3words address")
} else {
print("'\(address)' is NOT a valid what3words address")
}
}
}
}
main()
```
#### Expected Outputs
- isValid3wa(“filled.count.soap”) returns `True`
- isValid3wa(“filled.count.”) returns `False`
- isValid3wa(“coding.is.cool”) returns `False`
Also make sure to replace `` with your actual API key. These functionalities provide different levels of validation for what3words addresses, from simply identifying potential addresses to verifying their existence on Earth.
## 7. Troubleshooting
If you encounter errors or issues related to convert-to-coordinate, convert-to-3wa and grid-section requests while using the Free plan, please check the network panel for the following error message `Error 402 payment required` and its response, indicating the need to upgrade to a higher plan:
**JSON**
```json
{
"error": {
"code": "QuotaExceeded",
"message": "Quota exceeded or API plan does not have access to this feature. Please change your plan at https://accounts.what3words.com/select-plan, or contact support@what3words.com"
}
}
```
For more information, visit our [API plans page](https://accounts.what3words.com/select-plan). If you need further assistance, contact [support@what3words.com](mailto:support@what3words.com).
## 8. Full example
A complete example using AutoSuggest to find a place and `convertToCoordinates` to get its coordinates:
**Swift**
```swift
W3wGeocoder.setup(with: "")
let france = ClipToCountry(country: "FR")
let place = Focus(focus: CLLocationCoordinate2D(latitude: 48.856618, longitude: 2.3522411))
let count = NumberResults(numberOfResults: 4)
// Find some suggestions for a partial address
W3wGeocoder.shared.autosuggest(input: "freshen.overlook.clo", options: france, place, count) { (suggestions, error) in
// if there was an error, print it
if let e = error {
print(e.code, e.message)
// on success print the results
} else {
for suggestion in suggestions ?? [] {
print("\(suggestion.words) is near \(suggestion.nearestPlace) - Country Code:\(suggestion.country)")
}
}
// Find coordinates for the first suggestion
if let suggestion = suggestions?.first {
print("\nFinding the coordinates for: \(suggestion.words)")
W3wGeocoder.shared.convertToCoordinates(words: suggestion.words) { (place, error) in
// if there was an error, print it
if let e = error {
print(e.code, e.message)
// on success print the result
} else if let p = place {
print("The coordinates for \(p.words) are (\(p.coordinates.latitude),\(p.coordinates.longitude))")
}
}
}
}
```
---
# API v3
The what3words API is a fast and simple interface that allows you to convert 3 word addresses to coordinates and vice versa.
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md)
Source: https://developer.what3words.com/public-api/docs
OpenAPI: [openapi.yaml](https://developer.what3words.com/public-api/openapi.yaml) · [openapi.json](https://developer.what3words.com/public-api/openapi.json) · [Postman collection](https://developer.what3words.com/public-api/what3words.postman_collection.json)
It features a powerful AutoSuggest function, which can validate and autocorrect user input and limit it to certain geographic areas (this powers the search box on our map site). It allows you to request a section of the what3words grid (which can be requested as GeoJSON for easy display on online maps), and to request an up-to-date list of all languages supported by what3words. For advanced users, AutoSuggest can be used to post-process voice output.
All coordinates are latitude,longitude pairs in standard WGS-84 as commonly used worldwide in GPS systems. All latitudes must be in the range of -90 to 90 (inclusive).
| Endpoint | Name | Description |
| --- | --- | --- |
| [`GET /convert-to-3wa`](https://developer.what3words.com/public-api/docs#convert-to-3wa) | Convert to what3words address | This function will convert a latitude and longitude to a what3words address, in the language of your choice. |
| [`GET /convert-to-coordinates`](https://developer.what3words.com/public-api/docs#convert-to-coords) | Convert to coordinates | This function converts a what3words address to a latitude and longitude. |
| [`GET /autosuggest`](https://developer.what3words.com/public-api/docs#autosuggest) | AutoSuggest | AutoSuggest can take a slightly incorrect what3words address and suggest a list of valid what3words addresses. |
| [`GET /autosuggest-with-coordinates`](https://developer.what3words.com/public-api/docs#autosuggest-with-coordinates) | AutoSuggest with Coordinates | Similar to the AutoSuggest endpoint, but returns coordinates in the response. |
| [`GET /grid-section`](https://developer.what3words.com/public-api/docs#grid-section) | Grid section | Returns a section of the 3m x 3m what3words grid for a bounding box. |
| [`GET /available-languages`](https://developer.what3words.com/public-api/docs#available-languages) | Available languages | Retrieves all available what3words address languages and locale/script variants, including language code, English name and native name. |
Every operation, parameter and response on this page comes from the what3words OpenAPI definition. Browse it in the [OpenAPI reference](https://developer.what3words.com/public-api/openapi), or download it above.
## Overview
### Get started
1. [Get your free API key.](https://accounts.what3words.com/select-plan?referrer=/public-api/docs)
2. Check out our wrappers for [JavaScript](https://developer.what3words.com/tutorial/javascript), [Android](https://developer.what3words.com/tutorial/android), [C++](https://developer.what3words.com/tutorial/cpp), [Java](https://developer.what3words.com/tutorial/java), [Python](https://developer.what3words.com/tutorial/python), [PHP](https://developer.what3words.com/tutorial/php), [Swift](https://developer.what3words.com/tutorial/swift) and [Objective-C](https://developer.what3words.com/tutorial/objective-c).
3. Or start using the what3words API directly by requesting a URL:
#### 3 word address to coordinates
**URL**
```
https://api.what3words.com/v3/convert-to-coordinates?words=filled.count.soap&key=YOUR_API_KEY
```
#### Coordinates to 3 word address
**URL**
```
https://api.what3words.com/v3/convert-to-3wa?coordinates=51.521251%2C-0.203586&key=YOUR_API_KEY
```
### Tips
- Use HTTPS GET method only.
- Remember to always URL encode your parameters.
- Always include a valid API key in the `key=YOUR_API_KEY` parameter, or in the request header as `X-Api-Key: YOUR_API_KEY`.
- We support [CORS](http://enable-cors.org/index.html), which allows JavaScript requests to be made across domains. Each response contains the `Access-Control-Allow-Origin: *` header, that enables CORS.
### Locales
For some of our supported languages, a what3words locale can be specified within the API request using either the parameter `locale` or using the `language` parameter. The locale allows the what3words address to be displayed in a variant of a language. For example, Mongolian what3words addresses can be displayed in either Cyrillic or Latin characters and therefore by specifying the locale in the API request you can return either variant. The locale will also be included in the API response to show which variant has been returned.
Bosnian-Croatian-Montenegrin-Serbian is available using the language code `oo` with Cyrillic and Latin locales (`oo_cy` and `oo_la`).
Supported locales:
| Language/Locale code | Language variant |
| --- | --- |
| `oo_cy` | Bosnian-Croatian-Montenegrin-Serbian (Cyrillic) |
| `oo_la` | Bosnian-Croatian-Montenegrin-Serbian (Latin) |
| `kk_cy` | Kazakh (Cyrillic) |
| `kk_la` | Kazakh (Latin) |
| `mn_cy` | Mongolian (Cyrillic) |
| `mn_la` | Mongolian (Latin) |
| `zh_tr` | Chinese (Traditional) |
| `zh_si` | Chinese (Simplified) |
If a locale is not specified for these languages the default locale for the language will be returned. If a language does not have multiple locales, the response does not include a locale. For more information on how to pass in the locale please see the parameters for each API feature.
### Error handling
If all went well, you will get a 200 HTTP status code. If something went wrong, such as trying `convert-to-coordinates` with an invalid 3 word address such as `no.address.here`, you will get the appropriate HTTP error status (`400` in this case). Also, the body will contain an `error` block with a `code` and a `message`. `code` can be used programmatically so you can respond appropriately. `message` is intended as a helpful message to help you understand how to fix what went wrong. See [Error handling](https://developer.what3words.com/public-api/docs#error-handling) for every status and code.
## Convert to 3 word address
`GET https://api.what3words.com/v3/convert-to-3wa`
This function will convert a latitude and longitude to a what3words address, in the language of your choice. It also returns country, the bounds of the grid square, a nearby place (such as a local town) and a link to our map site.
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
| `coordinates` | query | string | required | Coordinates as a comma separated string of latitude and longitude. Example `coordinates=51.521251,-0.203586`. |
| `language` | query | string | optional | A supported what3words language code from `/available-languages`. You can pass base language codes (for example `fr`) or script-specific codes where available (for example `mn_la`, `zh_tr`, `oo_la`). Defaults to `en` (English) if not specified. For Bosnian-Croatian-Montenegrin-Serbian use `oo`. See [Available languages](https://developer.what3words.com/public-api/docs#available-languages) for every code. Default `en`. Example `language=fr`. |
| `format` | query | string | optional | Return data format type; can be either `json` (the default) or `geojson`. One of `json`, `geojson`. Default `json`. |
| `locale` | query | string | optional | Optional locale/script-specific code. Can be passed on its own. If provided with `language`, both values must be identical strings (for example `language=mn_la&locale=mn_la`). See [Locales](https://developer.what3words.com/public-api/docs#locales) for more details. Example `locale=mn_la`. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/convert-to-3wa?coordinates=51.520847,-0.195521&key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
coordinates: '51.520847,-0.195521',
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/convert-to-3wa?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/convert-to-3wa",
params={"coordinates": "51.520847,-0.195521", "key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"country": "GB",
"square": {
"southwest": {
"lng": -0.195543,
"lat": 51.520833
},
"northeast": {
"lng": -0.195499,
"lat": 51.52086
}
},
"nearestPlace": "Bayswater, London",
"coordinates": {
"lng": -0.195521,
"lat": 51.520847
},
"words": "filled.count.soap",
"language": "en",
"map": "https://w3w.co/filled.count.soap"
}
```
**GeoJSON**
```json
{
"features": [
{
"bbox": [
-0.195543,
51.520833,
-0.195499,
51.52086
],
"geometry": {
"coordinates": [
-0.195521,
51.520847
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "GB",
"nearestPlace": "Bayswater, London",
"words": "filled.count.soap",
"language": "en",
"map": "https://w3w.co/filled.count.soap"
}
}
],
"type": "FeatureCollection"
}
```
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `square` | object (Square) | |
| `square.southwest` | object (Coordinates) | |
| `square.southwest.lat` | number | Latitude |
| `square.southwest.lng` | number | Longitude |
| `square.northeast` | object (Coordinates) | |
| `square.northeast.lat` | number | Latitude |
| `square.northeast.lng` | number | Longitude |
| `nearestPlace` | string | The nearest place to the what3words address |
| `coordinates` | object (Coordinates) | |
| `coordinates.lat` | number | Latitude |
| `coordinates.lng` | number | Longitude |
| `words` | string | The what3words address |
| `language` | string | The language of the what3words address |
| `locale` | string | The locale of the what3words address, if returned |
| `map` | string | URL to view the what3words address on the what3words map |
### Errors
| Status | Code | Message |
| --- | --- | --- |
| 400 | `BadLanguage` | language must be a supported what3words language code, such as 'en', 'fr' or 'mn_la' |
| 400 | `BadCoordinates` | failed to parse one of the coordinates as a valid decimal number |
| 400 | `BadFormat` | Format must be one of json,geojson |
| 400 | `BadLanguage` | language and locale must not be different |
| 400 | `DuplicateParameter` | Duplicate parameter 'coordinates'. Please only pass in one of each parameter. |
| 401 | `InvalidKey` | Authentication failed; invalid API key |
| 401 | `MissingKey` | Authentication failed; missing required API key parameter or header |
## Convert to coordinates
`GET https://api.what3words.com/v3/convert-to-coordinates`
This function converts a what3words address to a latitude and longitude. It also returns country, the bounds of the grid square, a nearest place (such as a local town) and a link to our map site.
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
| `words` | query | string | required | A what3words address. Input parsing is case-insensitive, accepts an optional leading `///`, and accepts supported dot-like delimiters (. 。 。 ・ ・ ︒ ។ ։ ။ ۔ ። ।). Vietnamese addresses must be supplied either with no internal spaces or with 1 to 3 internal spaces in every word (spaces are URL-encoded as `%20`); the two Vietnamese styles cannot be mixed in a single address. Example `words=filled.count.soap`. |
| `format` | query | string | optional | Return data format type; can be either `json` (the default) or `geojson`. One of `json`, `geojson`. Default `json`. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/convert-to-coordinates?words=filled.count.soap&key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
words: 'filled.count.soap',
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/convert-to-coordinates?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/convert-to-coordinates",
params={"words": "filled.count.soap", "key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"country": "GB",
"square": {
"southwest": {
"lng": -0.195543,
"lat": 51.520833
},
"northeast": {
"lng": -0.195499,
"lat": 51.52086
}
},
"nearestPlace": "Bayswater, London",
"coordinates": {
"lng": -0.195521,
"lat": 51.520847
},
"words": "filled.count.soap",
"language": "en",
"map": "https://w3w.co/filled.count.soap"
}
```
**GeoJSON**
```json
{
"features": [
{
"bbox": [
-0.195543,
51.520833,
-0.195499,
51.52086
],
"geometry": {
"coordinates": [
-0.195521,
51.520847
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "GB",
"nearestPlace": "Bayswater, London",
"words": "filled.count.soap",
"language": "en",
"map": "https://w3w.co/filled.count.soap"
}
}
],
"type": "FeatureCollection"
}
```
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `square` | object (Square) | |
| `square.southwest` | object (Coordinates) | |
| `square.southwest.lat` | number | Latitude |
| `square.southwest.lng` | number | Longitude |
| `square.northeast` | object (Coordinates) | |
| `square.northeast.lat` | number | Latitude |
| `square.northeast.lng` | number | Longitude |
| `nearestPlace` | string | The nearest place to the what3words address |
| `coordinates` | object (Coordinates) | |
| `coordinates.lat` | number | Latitude |
| `coordinates.lng` | number | Longitude |
| `words` | string | The what3words address |
| `language` | string | The language of the what3words address |
| `locale` | string | The locale of the what3words address, if returned |
| `map` | string | URL to view the what3words address on the what3words map |
### Errors
| Status | Code | Message |
| --- | --- | --- |
| 400 | `MissingWords` | words must be specified |
| 400 | `BadWords` | words must be a valid 3 word address, such as filled.count.soap or ///filled.count.soap |
| 400 | `BadFormat` | Format must be one of json,geojson |
| 400 | `DuplicateParameter` | Duplicate parameter 'words'. Please only pass in one of each parameter. |
| 401 | `InvalidKey` | Authentication failed; invalid API key |
| 401 | `MissingKey` | Authentication failed; missing required API key parameter or header |
## AutoSuggest
`GET https://api.what3words.com/v3/autosuggest`
AutoSuggest can take a slightly incorrect what3words address and suggest a list of valid what3words addresses. It has powerful features that can, for example, optionally limit results to a country or area, and prioritize results that are near the user.
It provides corrections for the following types of input error:
- Typing errors
- Spelling errors
- Misremembered words (for example, singular vs. plural)
- Words in the wrong order
### Input 3 word address
AutoSuggest accepts either a full or partial 3 word address (it will be partial if the user is still typing in a search box, for example). A partial 3 word address must contain at least the first two words and first character of the third word. For example `filled.count.s` will return results, but anything shorter will not.
### Clipping and focus
Our clipping allows you to specify a country (or list of countries) and/or geographic area to exclude results that are not likely to be relevant to your users. To give a more targeted, shorter set of results to your users, we recommend you use the clipping parameters. If you know your user’s current location, we also strongly recommend that you use the `focus` to return results that are likely to be more relevant (that is, results near the user).
In summary, the clipping policy is used to optionally restrict the list of candidate AutoSuggest results, after which, if `focus` has been supplied, this will be used to weight the results in order of relevance to the `focus`.
Multiple clipping policies can be specified, though only one of each type. For example you can clip to country and clip to circle in the same AutoSuggest call, and it will clip to the intersection of the two (results must be in the circle AND in the country). However, you can't specify two `clip-to-circle` policies in the same call.
### Language
AutoSuggest will search in all languages. However, you can additionally specify a fallback language, to help the API in situations where the input is particularly messy. For normal text input, the `language` parameter is optional, and AutoSuggest will work well even without a `language` parameter. However, for voice input the `language` should always be specified.
### Voice input
As well as Cerence-based speech recognition systems, AutoSuggest also supports a Generic Voice option. This supports output from any speech recognition software. This input type handles spaces between words, for example, 'filled count soap'. Users should not pronounce 'dot' when speaking a 3 word address, and this input type cannot handle text in languages in which words are not separated by spaces, such as Chinese. Language detection should be disabled, so `language` must always be set. See [Using AutoSuggest with voice](https://developer.what3words.com/public-api/docs#speech-recognition).
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
| `input` | query | string | required | The full or partial what3words address to obtain suggestions for. At minimum this must be the first two complete words plus at least one character from the third word. Input parsing is case-insensitive, accepts an optional leading `///`, and accepts supported dot-like delimiters (. 。 。 ・ ・ ︒ ។ ։ ။ ۔ ። ।). Example `input=filled.count.s`. |
| `focus` | query | string | optional | This is a location, specified as latitude,longitude (often where the user making the query is). If specified, the results will be weighted to give preference to those near the focus. For convenience, longitude is allowed to wrap around the 180 line, so 361 is equivalent to 1. Example `focus=51.521251,-0.203586`. |
| `n-focus-results` | query | integer | optional | Controls how many top suggestions are strongly biased towards the `focus` coordinate. Defaults to `n-results` when omitted. Non-numeric values return `BadNFocusResults`. Default `3`. Maximum 100. Example `n-focus-results=5`. |
| `clip-to-country` | query | string | optional | Restricts results to the specified country or countries, specified as comma-separated ISO 3166-1 alpha-2 country codes (for example `GB,US`). Parsing is case-insensitive, though uppercase is recommended. Entries must be two a-z letters. If the two-letter code does not correspond to a country, there is no error: the API simply returns no results. Example `clip-to-country=GB,US`. |
| `clip-to-circle` | query | string | optional | Restricts results to a circle, specified by `latitude,longitude,kilometres`. For example, `51.4243877,-0.3474524,10` constrains results to those within 10 km of the point 51.4243877,-0.3474524. Example `clip-to-circle=51.4243877,-0.3474524,10`. |
| `clip-to-bounding-box` | query | string | optional | Restricts results to a bounding box, specified by `southwest latitude,southwest longitude,northeast latitude,northeast longitude`. Latitudes and longitudes should be specified in order of increasing size. Longitude is allowed to wrap, so that you can specify bounding boxes which cross the ante-meridian, e.g., `-4,178.2,22,195.4`. Example `clip-to-bounding-box=51.515900,-0.212517,51.527649,-0.191746`. |
| `clip-to-polygon` | query | string | optional | Restricts results to a polygon, specified by a comma-separated list of `lat,lng` pairs. The polygon should be closed, i.e. the first element should be repeated as the last element; also the list should contain at least 4 entries. The API is currently limited to accepting up to 25 pairs. Example `clip-to-polygon=51.521,-0.343,52.6,2.3324,54.234,8.343,51.521,-0.343`. |
| `language` | query | string | optional | For text input, adds a preferred language or locale to the set Autosuggest considers. Exact whole-word matches in the input can also add languages or locales. If omitted for text input, English is added as the default backstop. For voice input (`input-type` != `text`), this must be provided. Use a supported what3words code from `/available-languages`, including locale/script-specific codes where available (for example `mn_la`, `zh_tr`, `oo_la`). For Bosnian-Croatian-Montenegrin-Serbian use `oo`. See [Available languages](https://developer.what3words.com/public-api/docs#available-languages). Default `en`. |
| `locale` | query | string | optional | Optional locale/script-specific code. Can be passed on its own. If provided with `language`, both values must be identical strings (for example `language=mn_la&locale=mn_la`). See [Locales](https://developer.what3words.com/public-api/docs#locales) for more details. Example `locale=mn_la`. |
| `input-type` | query | string | optional | For power users, used to specify voice input mode. Can be `text` (default), `vocon-hybrid`, `nmdp-asr`, `generic-voice`, `speechmatics`, or `vin-big-data`. Voice modes require `language`. If `input` is not in the expected format for a selected voice mode, the API may return `BadInput`. See [Using AutoSuggest with voice](https://developer.what3words.com/public-api/docs#speech-recognition) for more details. One of `text`, `vocon-hybrid`, `nmdp-asr`, `generic-voice`, `speechmatics`, `vin-big-data`. Default `text`. |
| `n-results` | query | integer | optional | The number of AutoSuggest results to return. Non-numeric values return `BadNResults`. Values greater than 100 are truncated to 100. Values less than or equal to 0 return an empty suggestions list. The default is 3. Default `3`. Maximum 100. |
| `prefer-land` | query | boolean | optional | Makes AutoSuggest prefer results on land to those in the sea. This setting is on by default. Use false to disable this setting and receive more suggestions in the sea. Default `true`. |
| `format` | query | string | optional | Return data format type; can be either `json` (the default) or `geojson`. One of `json`, `geojson`. Default `json`. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/autosuggest?input=film.crunchy.spiri&focus=50.842404,4.361177&key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
input: 'film.crunchy.spiri',
focus: '50.842404,4.361177',
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/autosuggest?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/autosuggest",
params={"input": "film.crunchy.spiri", "focus": "50.842404,4.361177", "key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"suggestions": [
{
"country": "BE",
"nearestPlace": "Brussels, Brussels Capital",
"words": "film.crunchy.spirits",
"rank": 1,
"distanceToFocusKm": 1,
"language": "en"
},
{
"country": "ES",
"nearestPlace": "Caldes de Montbui, Catalonia",
"words": "film.crunchy.spirit",
"rank": 2,
"distanceToFocusKm": 1039,
"language": "en"
},
{
"country": "NL",
"nearestPlace": "Weert, Limburg",
"words": "firm.crunchy.spires",
"rank": 3,
"distanceToFocusKm": 105,
"language": "en"
}
]
}
```
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `suggestions[]` | array of AutosuggestSuggestion | List of suggested what3words addresses |
| `suggestions[].words` | string | The suggested what3words address |
| `suggestions[].country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `suggestions[].nearestPlace` | string | The nearest place to the what3words address |
| `suggestions[].language` | string | The language of the what3words address |
| `suggestions[].locale` | string | The locale of the what3words address, if applicable |
| `suggestions[].rank` | integer | The relative ranking of this suggestion |
| `suggestions[].distanceToFocusKm` | number | The distance in kilometers from the focus point to this suggestion's coordinates |
### Errors
| Status | Code | Message |
| --- | --- | --- |
| 400 | `MissingInput` | input must be specified |
| 400 | `BadFocus` | focus must be a lat,lng |
| 400 | `BadClipToCountry` | Countries are specified as a comma separated list of uppercase ISO 3166-1 alpha-2 country codes, such as US,CA |
| 400 | `BadClipToBoundingBox` | Must be four lat,lng,lat,lng coordinates such as 50,-2,53.12,2.34 |
| 400 | `BadClipToCircle` | clip-to-circle needs to be lat,lng,km. Example: 51.453,0.344,112 |
| 400 | `BadClipToPolygon` | Failed to parse one of the coordinates as a valid decimal number |
| 400 | `MissingLanguage` | for voice input. language must be specified |
| 400 | `BadLanguage` | language must be a supported what3words language code, such as 'en', 'fr' or 'mn_la' |
| 400 | `BadInputType` | prefer-land must be one of true or false |
| 400 | `BadLanguage` | language and locale must not be different |
| 400 | `BadNResults` | n-results must be a valid integer |
| 400 | `BadNFocusResults` | n-focus-results must be a valid integer |
| 400 | `BadInput` | Invalid autosuggest input |
| 400 | `DuplicateParameter` | Duplicate parameter 'input'. Please only pass in one of each parameter. |
| 401 | `InvalidKey` | Authentication failed; invalid API key |
| 401 | `MissingKey` | Authentication failed; missing required API key parameter or header |
### More example requests
#### AutoSuggest
This example returns AutoSuggest results for the partial 3 word address `film.crunchy.spiri`; the results are not clipped and not ranked for proximity to a given location.
**URL**
```
https://api.what3words.com/v3/autosuggest?input=film.crunchy.spiri&key=YOUR_API_KEY
```
#### AutoSuggest with focus only
This example returns AutoSuggest results for the partial 3 word address `film.crunchy.spiri`; the results are ranked for proximity relevance to the `focus` point of 50.842404,4.361177.
**URL**
```
https://api.what3words.com/v3/autosuggest?input=film.crunchy.spiri&focus=50.842404,4.361177&key=YOUR_API_KEY
```
#### AutoSuggest with clip-to-circle
This example searches for `plan.clips.a`; the results are constrained to those that are within 10 km of the point 51.4243877,-0.3474524.
**URL**
```
https://api.what3words.com/v3/autosuggest?input=plan.clips.a&clip-to-circle=51.4243877,-0.3474524,10&key=YOUR_API_KEY
```
#### AutoSuggest with focus and clip-to-country
**URL**
```
https://api.what3words.com/v3/autosuggest?input=plan.clips.a&focus=51.4243877,-0.3474524&clip-to-country=GB&key=YOUR_API_KEY
```
#### AutoSuggest with clip-to-bounding-box
This searches for `plan.clips.a` in the bounding box described by a NE corner of 54,2 and a SW corner of 50,-4.
**URL**
```
https://api.what3words.com/v3/autosuggest?input=plan.clips.a&clip-to-bounding-box=50,-4,54,2&key=YOUR_API_KEY
```
## AutoSuggest with coordinates
> [!NOTE]
> This endpoint needs special permissions on your API key. Contact [support@what3words.com](mailto:support@what3words.com) or your account manager to enable it. Without them, it returns `401` with the code `InvalidKey`.
It takes the same parameters as [AutoSuggest](https://developer.what3words.com/public-api/docs#autosuggest) and also returns the coordinates, grid square and map link of each suggestion.
`GET https://api.what3words.com/v3/autosuggest-with-coordinates`
Similar to the AutoSuggest endpoint, but returns coordinates in the response. This endpoint requires special permissions.
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
| `input` | query | string | required | The full or partial what3words address to obtain suggestions for. At minimum this must be the first two complete words plus at least one character from the third word. Input parsing is case-insensitive, accepts an optional leading `///`, and accepts supported dot-like delimiters (. 。 。 ・ ・ ︒ ។ ։ ။ ۔ ። ।). Example `input=filled.count.s`. |
| `focus` | query | string | optional | This is a location, specified as latitude,longitude (often where the user making the query is). If specified, the results will be weighted to give preference to those near the focus. For convenience, longitude is allowed to wrap around the 180 line, so 361 is equivalent to 1. Example `focus=51.521251,-0.203586`. |
| `n-focus-results` | query | integer | optional | Controls how many top suggestions are strongly biased towards the `focus` coordinate. Defaults to `n-results` when omitted. Non-numeric values return `BadNFocusResults`. Default `3`. Maximum 100. Example `n-focus-results=5`. |
| `clip-to-country` | query | string | optional | Restricts results to the specified country or countries, specified as comma-separated ISO 3166-1 alpha-2 country codes (for example `GB,US`). Parsing is case-insensitive, though uppercase is recommended. Example `clip-to-country=GB,US`. |
| `clip-to-circle` | query | string | optional | Restricts results to a circle, specified by `latitude,longitude,kilometres`. For example, `51.4243877,-0.3474524,10` constrains results to those within 10 km of the point 51.4243877,-0.3474524. Example `clip-to-circle=51.4243877,-0.3474524,10`. |
| `clip-to-bounding-box` | query | string | optional | Restricts results to a bounding box, specified by `southwest latitude,southwest longitude,northeast latitude,northeast longitude`. Latitudes and longitudes should be specified in order of increasing size. Longitude is allowed to wrap, so that you can specify bounding boxes which cross the ante-meridian, e.g., `-4,178.2,22,195.4`. Example `clip-to-bounding-box=51.515900,-0.212517,51.527649,-0.191746`. |
| `clip-to-polygon` | query | string | optional | Restricts results to a polygon, specified by a comma-separated list of `lat,lng` pairs. The polygon should be closed, i.e. the first element should be repeated as the last element; also the list should contain at least 4 entries. The API is currently limited to accepting up to 25 pairs. Example `clip-to-polygon=51.521,-0.343,52.6,2.3324,54.234,8.343,51.521,-0.343`. |
| `language` | query | string | optional | For text input, adds a preferred language or locale to the set Autosuggest considers. Exact whole-word matches in the input can also add languages or locales. If omitted for text input, English is added as the default backstop. For voice input (`input-type` != `text`), this must be provided. Use a supported what3words code from `/available-languages`, including locale/script-specific codes where available (for example `mn_la`, `zh_tr`, `oo_la`). Default `en`. |
| `locale` | query | string | optional | Optional locale/script-specific code. Can be passed on its own. If provided with `language`, both values must be identical strings (for example `language=mn_la&locale=mn_la`). Example `locale=mn_la`. |
| `input-type` | query | string | optional | For power users, used to specify voice input mode. Can be `text` (default), `vocon-hybrid`, `nmdp-asr`, `generic-voice`, `speechmatics`, or `vin-big-data`. Voice modes require `language`. If `input` is not in the expected format for a selected voice mode, the API may return `BadInput`. One of `text`, `vocon-hybrid`, `nmdp-asr`, `generic-voice`, `speechmatics`, `vin-big-data`. Default `text`. |
| `n-results` | query | integer | optional | The number of AutoSuggest results to return. Non-numeric values return `BadNResults`. Values greater than 100 are truncated to 100. Values less than or equal to 0 return an empty suggestions list. The default is 3. Default `3`. Maximum 100. |
| `prefer-land` | query | boolean | optional | Makes AutoSuggest prefer results on land to those in the sea. This setting is on by default. Use false to disable this setting and receive more suggestions in the sea. Default `true`. |
| `format` | query | string | optional | Return data format type; can be either `json` (the default) or `geojson`. One of `json`, `geojson`. Default `json`. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/autosuggest-with-coordinates?input=film.crunchy.spiri&focus=50.842404,4.361177&key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
input: 'film.crunchy.spiri',
focus: '50.842404,4.361177',
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/autosuggest-with-coordinates?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/autosuggest-with-coordinates",
params={"input": "film.crunchy.spiri", "focus": "50.842404,4.361177", "key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"suggestions": [
{
"country": "BE",
"square": {
"southwest": {
"lng": 4.347436,
"lat": 50.848237
},
"northeast": {
"lng": 4.347479,
"lat": 50.848264
}
},
"nearestPlace": "Brussels, Brussels Capital",
"words": "film.crunchy.spirits",
"coordinates": {
"lng": 4.347457,
"lat": 50.848251
},
"rank": 1,
"distanceToFocusKm": 1,
"language": "en",
"map": "https://w3w.co/film.crunchy.spirits"
},
{
"country": "ES",
"square": {
"southwest": {
"lng": 2.164394,
"lat": 41.625835
},
"northeast": {
"lng": 2.16443,
"lat": 41.625862
}
},
"nearestPlace": "Caldes de Montbui, Catalonia",
"words": "film.crunchy.spirit",
"coordinates": {
"lng": 2.164412,
"lat": 41.625849
},
"rank": 2,
"distanceToFocusKm": 1039,
"language": "en",
"map": "https://w3w.co/film.crunchy.spirit"
},
{
"country": "NL",
"square": {
"southwest": {
"lng": 5.681058,
"lat": 51.289807
},
"northeast": {
"lng": 5.681101,
"lat": 51.289834
}
},
"nearestPlace": "Weert, Limburg",
"words": "firm.crunchy.spires",
"coordinates": {
"lng": 5.68108,
"lat": 51.289821
},
"rank": 3,
"distanceToFocusKm": 105,
"language": "en",
"map": "https://w3w.co/firm.crunchy.spires"
}
]
}
```
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `suggestions[]` | array of AutosuggestWithCoordinatesSuggestion | List of suggested what3words addresses including coordinates |
| `suggestions[].words` | string | The suggested what3words address |
| `suggestions[].country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `suggestions[].square` | object (Square) | |
| `suggestions[].square.southwest` | object (Coordinates) | |
| `suggestions[].square.southwest.lat` | number | Latitude |
| `suggestions[].square.southwest.lng` | number | Longitude |
| `suggestions[].square.northeast` | object (Coordinates) | |
| `suggestions[].square.northeast.lat` | number | Latitude |
| `suggestions[].square.northeast.lng` | number | Longitude |
| `suggestions[].nearestPlace` | string | The nearest place to the what3words address |
| `suggestions[].coordinates` | object (Coordinates) | |
| `suggestions[].coordinates.lat` | number | Latitude |
| `suggestions[].coordinates.lng` | number | Longitude |
| `suggestions[].language` | string | The language of the what3words address |
| `suggestions[].locale` | string | The locale of the what3words address, if returned |
| `suggestions[].rank` | integer | The relative ranking of this suggestion |
| `suggestions[].distanceToFocusKm` | number | The distance in kilometers from the focus point to this suggestion's coordinates |
| `suggestions[].map` | string | URL to view the what3words address on the what3words map |
### Errors
| Status | Code | Message |
| --- | --- | --- |
| 400 | `MissingInput` | input must be specified |
| 400 | `BadFocus` | focus must be a lat,lng |
| 400 | `BadClipToCountry` | Countries are specified as a comma separated list of uppercase ISO 3166-1 alpha-2 country codes, such as US,CA |
| 400 | `BadClipToBoundingBox` | Must be four lat,lng,lat,lng coordinates such as 50,-2,53.12,2.34 |
| 400 | `BadClipToCircle` | clip-to-circle needs to be lat,lng,km. Example: 51.453,0.344,112 |
| 400 | `BadClipToPolygon` | Failed to parse one of the coordinates as a valid decimal number |
| 400 | `MissingLanguage` | for voice input. language must be specified |
| 400 | `BadLanguage` | language must be a supported what3words language code, such as 'en', 'fr' or 'mn_la' |
| 400 | `BadInputType` | prefer-land must be one of true or false |
| 400 | `BadLanguage` | language and locale must not be different |
| 400 | `BadNResults` | n-results must be a valid integer |
| 400 | `BadNFocusResults` | n-focus-results must be a valid integer |
| 400 | `BadInput` | Invalid autosuggest input |
| 400 | `DuplicateParameter` | Duplicate parameter 'input'. Please only pass in one of each parameter. |
| 401 | `InvalidKey` | Authentication failed; invalid API key |
| 401 | `InvalidKey` | Auth failed; /v3/autosuggest-with-coordinates. Contact support@what3words.com or your account manager to enable your account |
| 401 | `MissingKey` | Authentication failed; missing required API key parameter or header |
## Grid section
`GET https://api.what3words.com/v3/grid-section`
Returns a section of the 3m x 3m what3words grid for a bounding box. The bounding box is specified by lat,lng,lat,lng as south,west,north,east. You can request the grid in GeoJSON format, making it very simple to display on a map.
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
| `bounding-box` | query | string | required | Bounding box, as a `lat,lng,lat,lng`, for which the grid should be returned. The requested box must not exceed `4km` from corner to corner, or a `BadBoundingBoxTooBig` error will be returned. Latitudes must be `>= -90` and `<= 90`, but longitudes are allowed to wrap around 180. To specify a bounding-box that crosses the anti-meridian, use longitude greater than 180. e.g.: `bounding-box=50.0,179.995,50.01,180.0005`. Example `bounding-box=52.207988,0.116126,52.208867,0.117540`. |
| `format` | query | string | optional | Return data format type; can be either `json` (the default) or `geojson`. One of `json`, `geojson`. Default `json`. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/grid-section?bounding-box=52.207988,0.116126,52.208867,0.117540&key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
'bounding-box': '52.207988,0.116126,52.208867,0.117540',
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/grid-section?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/grid-section",
params={"bounding-box": "52.207988,0.116126,52.208867,0.117540", "key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"lines": [
{
"start": {
"lng": 0.116126,
"lat": 52.20801
},
"end": {
"lng": 0.11754,
"lat": 52.20801
}
},
{
"start": {
"lng": 0.116126,
"lat": 52.208037
},
"end": {
"lng": 0.11754,
"lat": 52.208037
}
}
]
}
```
**GeoJSON**
```json
{
"features": [
{
"geometry": {
"coordinates": [
[
[
0.116126,
52.20801
],
[
0.11754,
52.20801
]
],
[
[
0.116126,
52.208037
],
[
0.11754,
52.208037
]
]
],
"type": "MultiLineString"
},
"type": "Feature",
"properties": {}
}
],
"type": "FeatureCollection"
}
```
*Shortened to the first two lines of the grid; the full response has a line for every grid row and column in the bounding box.*
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `lines[]` | array of object | Array of line objects that make up the grid |
| `lines[].start` | object (Coordinates) | |
| `lines[].start.lat` | number | Latitude |
| `lines[].start.lng` | number | Longitude |
| `lines[].end` | object (Coordinates) | |
| `lines[].end.lat` | number | Latitude |
| `lines[].end.lng` | number | Longitude |
### Errors
| Status | Code | Message |
| --- | --- | --- |
| 400 | `BadBoundingBox` | bounding-box must be specified as south_lat,west_lng,north_lat,east_lng |
| 400 | `BadBoundingBoxTooBig` | Bounding box too large (exceeds 4km from corner to corner) |
| 400 | `BadFormat` | Format must be one of json,geojson |
| 400 | `DuplicateParameter` | Duplicate parameter 'bounding-box'. Please only pass in one of each parameter. |
| 401 | `InvalidKey` | Authentication failed; invalid API key |
| 401 | `MissingKey` | Authentication failed; missing required API key parameter or header |
## Available languages
Bosnian-Croatian-Montenegrin-Serbian is available using the language code `oo` with Cyrillic and Latin locales (`oo_cy` and `oo_la`).
`GET https://api.what3words.com/v3/available-languages`
Retrieves all available what3words address languages and locale/script variants, including language code, English name and native name. Use top-level `code` values as base `language` codes, and use nested `locales[].code` values where explicit locale/script selection is needed (for example `en`, `mn`, `mn_la`, `zh_tr`, `oo_cy`).
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/available-languages?key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/available-languages?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/available-languages",
params={"key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"languages": [
{
"nativeName": "Deutsch",
"code": "de",
"name": "German"
},
{
"nativeName": "English",
"code": "en",
"name": "English"
},
{
"nativeName": "Français",
"code": "fr",
"name": "French"
},
{
"nativeName": "Монгол хэл",
"code": "mn",
"name": "Mongolian",
"locales": [
{
"nativeName": "Монгол хэл (Латинаар)",
"name": "Mongolian (Latin)",
"code": "mn_la"
},
{
"nativeName": "Монгол хэл (Криллээр)",
"name": "Mongolian (Cyrillic)",
"code": "mn_cy"
}
]
},
{
"nativeName": "中文",
"code": "zh",
"name": "Chinese",
"locales": [
{
"nativeName": "中文(繁體)",
"name": "Chinese (Traditional)",
"code": "zh_tr"
},
{
"nativeName": "中文(简体)",
"name": "Chinese (Simplified)",
"code": "zh_si"
}
]
}
]
}
```
*Shortened to five languages; the full response lists all 58 languages.*
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `languages[]` | array of Language | List of available languages |
| `languages[].code` | string | The what3words language code for the language or language family (for example `en`, `mn`, `oo`). |
| `languages[].name` | string | The English name of the language |
| `languages[].nativeName` | string | The name of the language in that language |
| `languages[].locales[]` | array of Locale | List of available locales for this language, if applicable |
| `languages[].locales[].code` | string | The locale code |
| `languages[].locales[].name` | string | The name of the locale |
| `languages[].locales[].nativeName` | string | The native name of the locale |
### Errors
| Status | Code | Message |
| --- | --- | --- |
| 401 | `InvalidKey` | Authentication failed; invalid API key |
| 401 | `MissingKey` | Authentication failed; missing required API key parameter or header |
## Using AutoSuggest with voice
By default, AutoSuggest accepts text input. However, AutoSuggest also has powerful routines specifically optimised to post-process output from speech recognition systems.
As well as Cerence-based speech recognition systems, AutoSuggest also supports a Generic Voice option. This supports output from any speech recognition software. This input type handles spaces between words, for example, 'filled count soap'. Users should not pronounce 'dot' when speaking a 3 word address, and this input type cannot handle text in languages in which words are not separated by spaces, such as Chinese. Language detection is disabled, so `language` must always be set.
Currently, we support two Cerence-based speech recognition systems: NMDP-ASR and VoCon Hybrid. To use speech recognition, you will first need to process your audio using one of Cerence's Automated Speech Recognition systems, then pass the output into our `autosuggest` function. Use the `input-type` parameter to specify which system's output you are processing. For non-English languages, you must also always specify a `language` parameter.
The OpenAPI definition also lists the `speechmatics` and `vin-big-data` input types. Like the other voice modes, they require `language`.
### Generic Voice
AutoSuggest can post-process output for any speech recognition software. All of [AutoSuggest's parameters](https://developer.what3words.com/public-api/docs#autosuggest) such as clipping and focus can be used as normal. To use AutoSuggest in Generic Voice mode, set `input-type=generic-voice`, set `input` to the space separated 3 word address output, and set `language` to the appropriate language value, for example `language=en`.
### Cerence VoCon Hybrid
AutoSuggest can post-process output for [Cerence's VoCon Hybrid](https://www.cerence.com/cerence-products/core-technologies). All of [AutoSuggest's parameters](https://developer.what3words.com/public-api/docs#autosuggest) such as clipping and focus can be used as normal. To use AutoSuggest in VoCon Hybrid mode, set `input-type=vocon-hybrid` and set `input` to the URL-encoded JSON output from VoCon Hybrid.
#### AutoSuggest with focus (VoCon Hybrid)
This example returns Voice AutoSuggest results for the supplied Cerence VoCon Hybrid JSON; the results are ranked for proximity relevance to the `focus` point of 51.4243877,-0.3474524.
**cURL**
```shellscript
curl --request GET --url 'https://api.what3words.com/v3/autosuggest?input=%7B%22_isInGrammar%22%3A%22yes%22%2C%22_isSpeech%22%3A%22yes%22%2C%22_hypotheses%22%3A%5B%7B%22_score%22%3A342516%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6546%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34225%2C%22_orthography%22%3A%22tend%22%2C%22_conf%22%3A6964%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A43800%2C%22_orthography%22%3A%22poached%22%2C%22_conf%22%3A6181%2C%22_endTimeMs%22%3A4060%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342631%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6498%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34340%2C%22_orthography%22%3A%22tent%22%2C%22_conf%22%3A6772%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A43800%2C%22_orthography%22%3A%22poached%22%2C%22_conf%22%3A6181%2C%22_endTimeMs%22%3A4060%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342668%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6474%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34225%2C%22_orthography%22%3A%22tend%22%2C%22_conf%22%3A6964%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A41696%2C%22_orthography%22%3A%22perch%22%2C%22_conf%22%3A5950%2C%22_endTimeMs%22%3A4020%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342670%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6474%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34379%2C%22_orthography%22%3A%22tinge%22%2C%22_conf%22%3A6705%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A43800%2C%22_orthography%22%3A%22poached%22%2C%22_conf%22%3A6181%2C%22_endTimeMs%22%3A4060%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342783%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6426%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34340%2C%22_orthography%22%3A%22tent%22%2C%22_conf%22%3A6772%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A41696%2C%22_orthography%22%3A%22perch%22%2C%22_conf%22%3A5950%2C%22_endTimeMs%22%3A4020%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342822%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6402%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34379%2C%22_orthography%22%3A%22tinge%22%2C%22_conf%22%3A6705%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A41696%2C%22_orthography%22%3A%22perch%22%2C%22_conf%22%3A5950%2C%22_endTimeMs%22%3A4020%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%5D%2C%22_resultType%22%3A%22NBest%22%7D&language=en&focus=51.4243877,-0.3474524&input-type=vocon-hybrid&key=YOUR_API_KEY'
```
### Cerence NMDP ASR
AutoSuggest can post-process output for [Cerence's NMDP ASR](https://www.cerence.com/cerence-products/core-technologies). Please contact Cerence before attempting to use this server. Use with text from any other source is unsupported and results may not be as expected. Does not handle text in languages in which words are not separated by spaces, such as Chinese. All of [AutoSuggest's parameters](https://developer.what3words.com/public-api/docs#autosuggest) such as clipping and focus can be used as normal. To pass in NMDP-ASR output, simply set `input-type=nmdp-asr` and set `input` to the NMDP ASR output.
## Error handling
A successful API call will return an HTTP status code of 200. However, your code should always also handle potential errors. The most common error is a `BadWords`, which occurs when you call `convert-to-coordinates` with an invalid 3 word address. In this case you will get the appropriate HTTP error status (`400` in this case). Also, the body will contain an `error` block with a `code` and a `message`. `code` can be used programmatically so you can respond appropriately. `message` is intended as a helpful message to help you understand what went wrong.
### Example error
**URL**
```
https://api.what3words.com/v3/convert-to-coordinates?words=no.address.here&key=YOUR_API_KEY
```
The response will be an HTTP 400, with the following body:
Status: `400 Bad Request`
**JSON**
```json
{
"error": {
"code": "BadWords",
"message": "words must be a valid 3 word address, such as filled.count.soap or ///filled.count.soap"
}
}
```
### HTTP status codes
Below is a list of all HTTP error codes. This is not an exhaustive list; new error codes may be added in future.
| Code | Description |
| --- | --- |
| `200` | Successful |
| `400` | Bad request. This could be caused by an invalid character (make sure you [URL encode](https://en.wikipedia.org/wiki/Percent-encoding) all parameters); a bad parameter, where the `code` will be set to, for example, `BadWords`, `BadCoordinates`, `BadLanguage`, `BadFormat`, `BadClipToPolygon` and so on; a missing parameter, where a required parameter was missing, for example `MissingWords`, `MissingInput` or `MissingBoundingBox`; or a duplicate parameter: a parameter must only be specified once, or you will see a `DuplicateParameter` error code. |
| `401` | `MissingKey` or `InvalidKey`. Check your API key is supplied as `key=YOUR_API_KEY`. If not supplied as a parameter, a key must be supplied as a request header `X-Api-Key`. |
| `402` | For API accounts on the Free tier, the requested feature is not available. For accounts on a Business plan, the `convert-to-coordinates` quota has been exceeded. Go to [accounts.what3words.com/select-plan](https://accounts.what3words.com/select-plan) to adjust your API plan. |
| `404` | URL not found. Check the URL of the endpoint you're trying to reach. |
| `405` | Method not allowed. You must use a GET request. |
| `429` | Too many requests. See [Rate limits](https://developer.what3words.com/public-api/docs#rate-limits). |
| `50x` | Internal Server Error. |
### Error codes
Every error code in the OpenAPI definition, with the endpoints that return it.
| Code | HTTP status | Returned by |
| --- | --- | --- |
| `MissingWords` | 400 | `/convert-to-coordinates` |
| `BadWords` | 400 | `/convert-to-coordinates` |
| `BadFormat` | 400 | `/convert-to-3wa`, `/convert-to-coordinates`, `/grid-section` |
| `BadCoordinates` | 400 | `/convert-to-3wa` |
| `BadBoundingBox` | 400 | `/grid-section` |
| `BadBoundingBoxTooBig` | 400 | `/grid-section` |
| `BadFocus` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadClipToCountry` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadClipToBoundingBox` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadClipToCircle` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadClipToPolygon` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `MissingLanguage` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadLanguage` | 400 | `/convert-to-3wa`, `/autosuggest`, `/autosuggest-with-coordinates` |
| `InvalidKey` | 401 | `/convert-to-3wa`, `/convert-to-coordinates`, `/autosuggest`, `/autosuggest-with-coordinates`, `/grid-section`, `/available-languages` |
| `InvalidKeyNoPermissions` | 401 | `/autosuggest-with-coordinates` |
| `BadInputType` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `MissingInput` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `MissingKey` | 401 | `/convert-to-3wa`, `/convert-to-coordinates`, `/autosuggest`, `/autosuggest-with-coordinates`, `/grid-section`, `/available-languages` |
| `DuplicateParameter` | 400 | `/convert-to-3wa`, `/convert-to-coordinates`, `/autosuggest`, `/autosuggest-with-coordinates`, `/grid-section` |
| `BadNResults` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadNFocusResults` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadInput` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
## Quota and usage limits
### API plans
When signing up for the what3words API you will need to select a [what3words API plan](https://accounts.what3words.com/select-plan).
The Free plan only has access to the `autosuggest` and `available-languages` API functions.
Each Business plan has a quota for the number of `convert-to-coordinates` requests that can be made during your account’s billing period. If you exceed your quota during your billing period, any subsequent `convert-to-coordinates` requests will receive an `HTTP 402` response until either the API plan is upgraded or the billing period resets. Other API functions are covered by our [Fair Usage Policy](https://what3words.com/api-licence-agreement).
If you need a higher quota than specified by our plans then please discuss with the [what3words team](mailto:support@what3words.com) so we can advise on the best product for your use case. We also offer free and discounted plans for qualifying NGOs, charities and emergency services. [Get in touch](mailto:support@what3words.com) to find out more.
### Rate limits
Each API function has a rate limit that restricts the frequency that requests can be sent to the API. If you exceed the rate limit, subsequent requests will be throttled and will receive a `HTTP 429 (Too Many Requests)` response from the API until your request rate drops below the limit.
The what3words Free plan has a restriction of 10 requests per second for the `autosuggest` function. We recommend selecting one of our business plans to increase the rate limit.
If you need a higher rate than specified for a plan then please discuss with the [what3words team](mailto:support@what3words.com) so we can advise on the best product for your use case.
Plan rate limits (requests per second) are as follows:
| Plan | AutoSuggest | Convert to coordinates | Convert to 3 word address | Grid | Available languages |
| --- | --- | --- | --- | --- | --- |
| Free | 10 | N/A | N/A | N/A | 200 |
| Basic | 200 | 200 | 200 | 200 | 200 |
| Standard | 200 | 200 | 200 | 200 | 200 |
| Plus | 200 | 200 | 200 | 200 | 200 |
| Premium | 200 | 200 | 200 | 200 | 200 |
### Terms of use
Use of the what3words API is covered by the [API licence agreement](https://what3words.com/api-licence-agreement).
---
# OpenAPI reference
Every endpoint in the what3words OpenAPI definition, with its parameters, responses, examples and schemas. The guide to each one is in the [API reference](https://developer.what3words.com/public-api/docs).
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md)
Source: https://developer.what3words.com/public-api/openapi
OpenAPI: [openapi.yaml](https://developer.what3words.com/public-api/openapi.yaml) · [openapi.json](https://developer.what3words.com/public-api/openapi.json) · [Postman collection](https://developer.what3words.com/public-api/what3words.postman_collection.json)
The what3words API provides a simple and powerful interface to interact with the what3words addressing system.
It allows you to convert between what3words addresses and geographic coordinates, validate and autocorrect user input,
and retrieve information about supported languages and the what3words grid.
Key features include:
- **Convert to what3words address**: Convert latitude and longitude coordinates into a what3words address.
- **Convert to coordinates**: Convert a what3words address into latitude and longitude coordinates.
- **AutoSuggest**: Suggest valid what3words addresses based on partial or incorrect input, with options to prioritize results by location or restrict results to specific areas.
- **AutoSuggest with Coordinates**: Similar to AutoSuggest, but returns coordinates in the response. This endpoint requires special permissions, please contact [support@what3words.com](mailto:support@what3words.com) for more information.
- **Grid Section**: Retrieve a section of the what3words grid for a specified bounding box, useful for map visualizations.
- **Available Languages**: Get a list of all supported languages, including language codes (including script-specific variants) and native names.
For more details, visit the [what3words Public API Documentation](https://developer.what3words.com/public-api/docs#overview).
**Additional resources:**
- [API Authentication](https://accounts.what3words.com/select-plan?referrer=/public-api/docs)
- [Error Codes](https://developer.what3words.com/public-api/docs#error-handling)
- [Supported Languages](https://developer.what3words.com/public-api/docs#available-languages)
- [Rate Limits](https://developer.what3words.com/public-api/docs#rate-limits)
- [API Terms of Use](https://developer.what3words.com/public-api/docs#terms-of-use)
- [API Pricing](https://accounts.what3words.com/select-plan?referrer=/public-api/docs)
- [Postman Collection](https://openapi.what3words.com/what3words.postman_collection.json)
- [Blog: Minimum word and address lengths (code points vs characters)](https://what3words.com/news/blog/minimum-word-and-address-lengths-in-what3words-code-points-vs-characters)
- [Blog: Understanding locales in what3words](https://what3words.com/news/blog/understanding-locales-in-what3words)
- [Blog: Demystifying the alias parameter](https://what3words.com/news/blog/demystifying-the-alias-parameter-in-what3words-address-urls)
- [Blog: LTR and RTL scripts](https://what3words.com/news/blog/how-what3words-addresses-work-in-left-to-right-ltr-and-right-to-left-rtl-scripts)
- [Blog: Secondary words across languages](https://what3words.com/news/blog/how-what3words-supports-natural-variants-across-languages-using-secondary-words)
- [Blog: Understanding the what3words regex](https://what3words.com/news/general/understanding-the-what3words-regex-a-human-friendly-guide)
## Endpoints
| Endpoint | Name | Description |
| --- | --- | --- |
| [`GET /convert-to-3wa`](https://developer.what3words.com/public-api/openapi#convertTo3wa) | Convert to what3words address | This function will convert a latitude and longitude to a what3words address, in the language of your choice. |
| [`GET /convert-to-coordinates`](https://developer.what3words.com/public-api/openapi#convertToCoordinates) | Convert to coordinates | This function converts a what3words address to a latitude and longitude. |
| [`GET /autosuggest`](https://developer.what3words.com/public-api/openapi#autosuggest) | AutoSuggest | AutoSuggest can take a slightly incorrect what3words address and suggest a list of valid what3words addresses. |
| [`GET /autosuggest-with-coordinates`](https://developer.what3words.com/public-api/openapi#autosuggestWithCoordinates) | AutoSuggest with Coordinates | Similar to the AutoSuggest endpoint, but returns coordinates in the response. |
| [`GET /grid-section`](https://developer.what3words.com/public-api/openapi#gridSection) | Grid section | Returns a section of the 3m x 3m what3words grid for a bounding box. |
| [`GET /available-languages`](https://developer.what3words.com/public-api/openapi#availableLanguages) | Available languages | Retrieves all available what3words address languages and locale/script variants, including language code, English name and native name. |
## Authentication
Every request needs an API key, sent as the `key` query parameter or the `X-Api-Key` header. [Get your free API key.](https://accounts.what3words.com/select-plan?referrer=/public-api/openapi)
| Scheme | Where | Name | Description |
| --- | --- | --- | --- |
| ApiKeyAuth | query | `key` | API key for authentication. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
| ApiKeyHeader | header | `X-Api-Key` | API key for authentication. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
## Errors
Errors return an HTTP status and a JSON body with a stable `code` and a readable `message`. Use the code to decide how to handle the error. See the [error handling guide](https://developer.what3words.com/public-api/docs#error-handling) for an example.
### Error codes
| Code | HTTP status | Returned by |
| --- | --- | --- |
| `MissingWords` | 400 | `/convert-to-coordinates` |
| `BadWords` | 400 | `/convert-to-coordinates` |
| `BadFormat` | 400 | `/convert-to-3wa`, `/convert-to-coordinates`, `/grid-section` |
| `BadCoordinates` | 400 | `/convert-to-3wa` |
| `BadBoundingBox` | 400 | `/grid-section` |
| `BadBoundingBoxTooBig` | 400 | `/grid-section` |
| `BadFocus` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadClipToCountry` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadClipToBoundingBox` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadClipToCircle` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadClipToPolygon` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `MissingLanguage` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadLanguage` | 400 | `/convert-to-3wa`, `/autosuggest`, `/autosuggest-with-coordinates` |
| `InvalidKey` | 401 | `/convert-to-3wa`, `/convert-to-coordinates`, `/autosuggest`, `/autosuggest-with-coordinates`, `/grid-section`, `/available-languages` |
| `InvalidKeyNoPermissions` | 401 | `/autosuggest-with-coordinates` |
| `BadInputType` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `MissingInput` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `MissingKey` | 401 | `/convert-to-3wa`, `/convert-to-coordinates`, `/autosuggest`, `/autosuggest-with-coordinates`, `/grid-section`, `/available-languages` |
| `DuplicateParameter` | 400 | `/convert-to-3wa`, `/convert-to-coordinates`, `/autosuggest`, `/autosuggest-with-coordinates`, `/grid-section` |
| `BadNResults` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadNFocusResults` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
| `BadInput` | 400 | `/autosuggest`, `/autosuggest-with-coordinates` |
## Convert to what3words address
`GET https://api.what3words.com/v3/convert-to-3wa`
This function will convert a latitude and longitude to a what3words address, in the language of your choice. It also returns country, the bounds of the grid square, a nearby place (such as a local town) and a link to our map site.
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
| `coordinates` | query | string | required | Coordinates as a comma separated string of latitude and longitude. Example `coordinates=51.521251,-0.203586`. |
| `language` | query | string | optional | A supported what3words language code from `/available-languages`. You can pass base language codes (for example `fr`) or script-specific codes where available (for example `mn_la`, `zh_tr`, `oo_la`). Defaults to `en` (English) if not specified. Default `en`. Example `language=fr`. |
| `format` | query | string | optional | Return data format type; can be either `json` (the default) or `geojson`. One of `json`, `geojson`. Default `json`. |
| `locale` | query | string | optional | Optional locale/script-specific code. Can be passed on its own. If provided with `language`, both values must be identical strings (for example `language=mn_la&locale=mn_la`). Example `locale=mn_la`. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/convert-to-3wa?coordinates=51.520847,-0.195521&key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
coordinates: '51.520847,-0.195521',
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/convert-to-3wa?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/convert-to-3wa",
params={"coordinates": "51.520847,-0.195521", "key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"country": "GB",
"square": {
"southwest": {
"lng": -0.195543,
"lat": 51.520833
},
"northeast": {
"lng": -0.195499,
"lat": 51.52086
}
},
"nearestPlace": "Bayswater, London",
"coordinates": {
"lng": -0.195521,
"lat": 51.520847
},
"words": "filled.count.soap",
"language": "en",
"map": "https://w3w.co/filled.count.soap"
}
```
**GeoJSON**
```json
{
"features": [
{
"bbox": [
-0.195543,
51.520833,
-0.195499,
51.52086
],
"geometry": {
"coordinates": [
-0.195521,
51.520847
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "GB",
"nearestPlace": "Bayswater, London",
"words": "filled.count.soap",
"language": "en",
"map": "https://w3w.co/filled.count.soap"
}
}
],
"type": "FeatureCollection"
}
```
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `square` | object (Square) | |
| `square.southwest` | object (Coordinates) | |
| `square.southwest.lat` | number | Latitude |
| `square.southwest.lng` | number | Longitude |
| `square.northeast` | object (Coordinates) | |
| `square.northeast.lat` | number | Latitude |
| `square.northeast.lng` | number | Longitude |
| `nearestPlace` | string | The nearest place to the what3words address |
| `coordinates` | object (Coordinates) | |
| `coordinates.lat` | number | Latitude |
| `coordinates.lng` | number | Longitude |
| `words` | string | The what3words address |
| `language` | string | The language of the what3words address |
| `locale` | string | The locale of the what3words address, if returned |
| `map` | string | URL to view the what3words address on the what3words map |
### Responses
**200** Successful conversion to what3words address (application/json). Schema: ConvertTo3waResponse
**400** Bad request (application/json). Schema: ErrorResponse
**BadLanguage**
```json
{
"error": {
"code": "BadLanguage",
"message": "language must be a supported what3words language code, such as 'en', 'fr' or 'mn_la'"
}
}
```
**BadCoordinates**
```json
{
"error": {
"code": "BadCoordinates",
"message": "failed to parse one of the coordinates as a valid decimal number"
}
}
```
**BadFormat**
```json
{
"error": {
"code": "BadFormat",
"message": "Format must be one of json,geojson"
}
}
```
**BadLanguageLocaleMismatch**
```json
{
"error": {
"code": "BadLanguage",
"message": "language and locale must not be different"
}
}
```
**DuplicateParameter**
```json
{
"error": {
"code": "DuplicateParameter",
"message": "Duplicate parameter 'coordinates'. Please only pass in one of each parameter."
}
}
```
**401** Unauthorized - Invalid API key (application/json). Schema: ErrorResponse
**InvalidKey**
```json
{
"error": {
"code": "InvalidKey",
"message": "Authentication failed; invalid API key"
}
}
```
**MissingKey**
```json
{
"error": {
"code": "MissingKey",
"message": "Authentication failed; missing required API key parameter or header"
}
}
```
[Read the guide](https://developer.what3words.com/public-api/docs#convert-to-3wa) · [Try it in the Playground](https://developer.what3words.com/public-api/playground#convert-to-3wa)
## Convert to coordinates
`GET https://api.what3words.com/v3/convert-to-coordinates`
This function converts a what3words address to a latitude and longitude. It also returns country, the bounds of the grid square, a nearest place (such as a local town) and a link to our map site.
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
| `words` | query | string | required | A what3words address. Input parsing is case-insensitive, accepts an optional leading `///`, and accepts supported dot-like delimiters (. 。 。 ・ ・ ︒ ។ ։ ။ ۔ ። ।). Example `words=filled.count.soap`. |
| `format` | query | string | optional | Return data format type; can be either `json` (the default) or `geojson`. One of `json`, `geojson`. Default `json`. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/convert-to-coordinates?words=filled.count.soap&key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
words: 'filled.count.soap',
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/convert-to-coordinates?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/convert-to-coordinates",
params={"words": "filled.count.soap", "key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"country": "GB",
"square": {
"southwest": {
"lng": -0.195543,
"lat": 51.520833
},
"northeast": {
"lng": -0.195499,
"lat": 51.52086
}
},
"nearestPlace": "Bayswater, London",
"coordinates": {
"lng": -0.195521,
"lat": 51.520847
},
"words": "filled.count.soap",
"language": "en",
"map": "https://w3w.co/filled.count.soap"
}
```
**GeoJSON**
```json
{
"features": [
{
"bbox": [
-0.195543,
51.520833,
-0.195499,
51.52086
],
"geometry": {
"coordinates": [
-0.195521,
51.520847
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "GB",
"nearestPlace": "Bayswater, London",
"words": "filled.count.soap",
"language": "en",
"map": "https://w3w.co/filled.count.soap"
}
}
],
"type": "FeatureCollection"
}
```
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `square` | object (Square) | |
| `square.southwest` | object (Coordinates) | |
| `square.southwest.lat` | number | Latitude |
| `square.southwest.lng` | number | Longitude |
| `square.northeast` | object (Coordinates) | |
| `square.northeast.lat` | number | Latitude |
| `square.northeast.lng` | number | Longitude |
| `nearestPlace` | string | The nearest place to the what3words address |
| `coordinates` | object (Coordinates) | |
| `coordinates.lat` | number | Latitude |
| `coordinates.lng` | number | Longitude |
| `words` | string | The what3words address |
| `language` | string | The language of the what3words address |
| `locale` | string | The locale of the what3words address, if returned |
| `map` | string | URL to view the what3words address on the what3words map |
### Responses
**200** Successful conversion to coordinates (application/json). Schema: ConvertToCoordinatesResponse
**400** Bad request (application/json). Schema: ErrorResponse
**MissingWords**
```json
{
"error": {
"code": "MissingWords",
"message": "words must be specified"
}
}
```
**BadWords**
```json
{
"error": {
"code": "BadWords",
"message": "words must be a valid 3 word address, such as filled.count.soap or ///filled.count.soap"
}
}
```
**BadFormat**
```json
{
"error": {
"code": "BadFormat",
"message": "Format must be one of json,geojson"
}
}
```
**DuplicateParameter**
```json
{
"error": {
"code": "DuplicateParameter",
"message": "Duplicate parameter 'words'. Please only pass in one of each parameter."
}
}
```
**401** Unauthorized - Invalid API key (application/json). Schema: ErrorResponse
**InvalidKey**
```json
{
"error": {
"code": "InvalidKey",
"message": "Authentication failed; invalid API key"
}
}
```
**MissingKey**
```json
{
"error": {
"code": "MissingKey",
"message": "Authentication failed; missing required API key parameter or header"
}
}
```
[Read the guide](https://developer.what3words.com/public-api/docs#convert-to-coords) · [Try it in the Playground](https://developer.what3words.com/public-api/playground#convert-to-coordinates)
## AutoSuggest
`GET https://api.what3words.com/v3/autosuggest`
AutoSuggest can take a slightly incorrect what3words address and suggest a list of valid what3words addresses. It has powerful features that can, for example, optionally limit results to a country or area, and prioritize results that are near the user.
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
| `input` | query | string | required | The full or partial what3words address to obtain suggestions for. At minimum this must be the first two complete words plus at least one character from the third word. Input parsing is case-insensitive, accepts an optional leading `///`, and accepts supported dot-like delimiters (. 。 。 ・ ・ ︒ ។ ։ ။ ۔ ። ।). Example `input=filled.count.s`. |
| `focus` | query | string | optional | This is a location, specified as latitude,longitude (often where the user making the query is). If specified, the results will be weighted to give preference to those near the focus. For convenience, longitude is allowed to wrap around the 180 line, so 361 is equivalent to 1. Example `focus=51.521251,-0.203586`. |
| `n-focus-results` | query | integer | optional | Controls how many top suggestions are strongly biased towards the `focus` coordinate. Defaults to `n-results` when omitted. Non-numeric values return `BadNFocusResults`. Default `3`. Maximum 100. Example `n-focus-results=5`. |
| `clip-to-country` | query | string | optional | Restricts results to the specified country or countries, specified as comma-separated ISO 3166-1 alpha-2 country codes (for example `GB,US`). Parsing is case-insensitive, though uppercase is recommended. Example `clip-to-country=GB,US`. |
| `clip-to-circle` | query | string | optional | Restricts results to a circle, specified by `latitude,longitude,kilometres`. For example, `51.4243877,-0.3474524,10` constrains results to those within 10 km of the point 51.4243877,-0.3474524. Example `clip-to-circle=51.4243877,-0.3474524,10`. |
| `clip-to-bounding-box` | query | string | optional | Restricts results to a bounding box, specified by `southwest latitude,southwest longitude,northeast latitude,northeast longitude`. Latitudes and longitudes should be specified in order of increasing size. Longitude is allowed to wrap, so that you can specify bounding boxes which cross the ante-meridian, e.g., `-4,178.2,22,195.4`. Example `clip-to-bounding-box=51.515900,-0.212517,51.527649,-0.191746`. |
| `clip-to-polygon` | query | string | optional | Restricts results to a polygon, specified by a comma-separated list of `lat,lng` pairs. The polygon should be closed, i.e. the first element should be repeated as the last element; also the list should contain at least 4 entries. The API is currently limited to accepting up to 25 pairs. Example `clip-to-polygon=51.521,-0.343,52.6,2.3324,54.234,8.343,51.521,-0.343`. |
| `language` | query | string | optional | For text input, adds a preferred language or locale to the set Autosuggest considers. Exact whole-word matches in the input can also add languages or locales. If omitted for text input, English is added as the default backstop. For voice input (`input-type` != `text`), this must be provided. Use a supported what3words code from `/available-languages`, including locale/script-specific codes where available (for example `mn_la`, `zh_tr`, `oo_la`). Default `en`. |
| `locale` | query | string | optional | Optional locale/script-specific code. Can be passed on its own. If provided with `language`, both values must be identical strings (for example `language=mn_la&locale=mn_la`). Example `locale=mn_la`. |
| `input-type` | query | string | optional | For power users, used to specify voice input mode. Can be `text` (default), `vocon-hybrid`, `nmdp-asr`, `generic-voice`, `speechmatics`, or `vin-big-data`. Voice modes require `language`. If `input` is not in the expected format for a selected voice mode, the API may return `BadInput`. One of `text`, `vocon-hybrid`, `nmdp-asr`, `generic-voice`, `speechmatics`, `vin-big-data`. Default `text`. |
| `n-results` | query | integer | optional | The number of AutoSuggest results to return. Non-numeric values return `BadNResults`. Values greater than 100 are truncated to 100. Values less than or equal to 0 return an empty suggestions list. The default is 3. Default `3`. Maximum 100. |
| `prefer-land` | query | boolean | optional | Makes AutoSuggest prefer results on land to those in the sea. This setting is on by default. Use false to disable this setting and receive more suggestions in the sea. Default `true`. |
| `format` | query | string | optional | Return data format type; can be either `json` (the default) or `geojson`. One of `json`, `geojson`. Default `json`. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/autosuggest?input=film.crunchy.spiri&focus=50.842404,4.361177&key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
input: 'film.crunchy.spiri',
focus: '50.842404,4.361177',
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/autosuggest?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/autosuggest",
params={"input": "film.crunchy.spiri", "focus": "50.842404,4.361177", "key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"suggestions": [
{
"country": "BE",
"nearestPlace": "Brussels, Brussels Capital",
"words": "film.crunchy.spirits",
"rank": 1,
"distanceToFocusKm": 1,
"language": "en"
},
{
"country": "ES",
"nearestPlace": "Caldes de Montbui, Catalonia",
"words": "film.crunchy.spirit",
"rank": 2,
"distanceToFocusKm": 1039,
"language": "en"
},
{
"country": "NL",
"nearestPlace": "Weert, Limburg",
"words": "firm.crunchy.spires",
"rank": 3,
"distanceToFocusKm": 105,
"language": "en"
}
]
}
```
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `suggestions[]` | array of AutosuggestSuggestion | List of suggested what3words addresses |
| `suggestions[].words` | string | The suggested what3words address |
| `suggestions[].country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `suggestions[].nearestPlace` | string | The nearest place to the what3words address |
| `suggestions[].language` | string | The language of the what3words address |
| `suggestions[].locale` | string | The locale of the what3words address, if applicable |
| `suggestions[].rank` | integer | The relative ranking of this suggestion |
| `suggestions[].distanceToFocusKm` | number | The distance in kilometers from the focus point to this suggestion's coordinates |
### Responses
**200** Successful autosuggest results (application/json). Schema: AutosuggestResponse
**400** Bad request (application/json). Schema: ErrorResponse
**MissingInput**
```json
{
"error": {
"code": "MissingInput",
"message": "input must be specified"
}
}
```
**BadFocus**
```json
{
"error": {
"code": "BadFocus",
"message": "focus must be a lat,lng"
}
}
```
**BadClipToCountry**
```json
{
"error": {
"code": "BadClipToCountry",
"message": "Countries are specified as a comma separated list of uppercase ISO 3166-1 alpha-2 country codes, such as US,CA"
}
}
```
**BadClipToBoundingBox**
```json
{
"error": {
"code": "BadClipToBoundingBox",
"message": "Must be four lat,lng,lat,lng coordinates such as 50,-2,53.12,2.34"
}
}
```
**BadClipToCircle**
```json
{
"error": {
"code": "BadClipToCircle",
"message": "clip-to-circle needs to be lat,lng,km. Example: 51.453,0.344,112"
}
}
```
**BadClipToPolygon**
```json
{
"error": {
"code": "BadClipToPolygon",
"message": "Failed to parse one of the coordinates as a valid decimal number"
}
}
```
**MissingLanguage**
```json
{
"error": {
"code": "MissingLanguage",
"message": "for voice input. language must be specified"
}
}
```
**BadLanguage**
```json
{
"error": {
"code": "BadLanguage",
"message": "language must be a supported what3words language code, such as 'en', 'fr' or 'mn_la'"
}
}
```
**BadInputType**
```json
{
"error": {
"code": "BadInputType",
"message": "prefer-land must be one of true or false"
}
}
```
**BadLanguageLocaleMismatch**
```json
{
"error": {
"code": "BadLanguage",
"message": "language and locale must not be different"
}
}
```
**BadNResults**
```json
{
"error": {
"code": "BadNResults",
"message": "n-results must be a valid integer"
}
}
```
**BadNFocusResults**
```json
{
"error": {
"code": "BadNFocusResults",
"message": "n-focus-results must be a valid integer"
}
}
```
**BadInput**
```json
{
"error": {
"code": "BadInput",
"message": "Invalid autosuggest input"
}
}
```
**DuplicateParameter**
```json
{
"error": {
"code": "DuplicateParameter",
"message": "Duplicate parameter 'input'. Please only pass in one of each parameter."
}
}
```
**401** Unauthorized - Invalid API key (application/json). Schema: ErrorResponse
**InvalidKey**
```json
{
"error": {
"code": "InvalidKey",
"message": "Authentication failed; invalid API key"
}
}
```
**MissingKey**
```json
{
"error": {
"code": "MissingKey",
"message": "Authentication failed; missing required API key parameter or header"
}
}
```
[Read the guide](https://developer.what3words.com/public-api/docs#autosuggest) · [Try it in the Playground](https://developer.what3words.com/public-api/playground#autosuggest)
## AutoSuggest with Coordinates
`GET https://api.what3words.com/v3/autosuggest-with-coordinates`
Similar to the AutoSuggest endpoint, but returns coordinates in the response. This endpoint requires special permissions.
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
| `input` | query | string | required | The full or partial what3words address to obtain suggestions for. At minimum this must be the first two complete words plus at least one character from the third word. Input parsing is case-insensitive, accepts an optional leading `///`, and accepts supported dot-like delimiters (. 。 。 ・ ・ ︒ ។ ։ ။ ۔ ። ।). Example `input=filled.count.s`. |
| `focus` | query | string | optional | This is a location, specified as latitude,longitude (often where the user making the query is). If specified, the results will be weighted to give preference to those near the focus. For convenience, longitude is allowed to wrap around the 180 line, so 361 is equivalent to 1. Example `focus=51.521251,-0.203586`. |
| `n-focus-results` | query | integer | optional | Controls how many top suggestions are strongly biased towards the `focus` coordinate. Defaults to `n-results` when omitted. Non-numeric values return `BadNFocusResults`. Default `3`. Maximum 100. Example `n-focus-results=5`. |
| `clip-to-country` | query | string | optional | Restricts results to the specified country or countries, specified as comma-separated ISO 3166-1 alpha-2 country codes (for example `GB,US`). Parsing is case-insensitive, though uppercase is recommended. Example `clip-to-country=GB,US`. |
| `clip-to-circle` | query | string | optional | Restricts results to a circle, specified by `latitude,longitude,kilometres`. For example, `51.4243877,-0.3474524,10` constrains results to those within 10 km of the point 51.4243877,-0.3474524. Example `clip-to-circle=51.4243877,-0.3474524,10`. |
| `clip-to-bounding-box` | query | string | optional | Restricts results to a bounding box, specified by `southwest latitude,southwest longitude,northeast latitude,northeast longitude`. Latitudes and longitudes should be specified in order of increasing size. Longitude is allowed to wrap, so that you can specify bounding boxes which cross the ante-meridian, e.g., `-4,178.2,22,195.4`. Example `clip-to-bounding-box=51.515900,-0.212517,51.527649,-0.191746`. |
| `clip-to-polygon` | query | string | optional | Restricts results to a polygon, specified by a comma-separated list of `lat,lng` pairs. The polygon should be closed, i.e. the first element should be repeated as the last element; also the list should contain at least 4 entries. The API is currently limited to accepting up to 25 pairs. Example `clip-to-polygon=51.521,-0.343,52.6,2.3324,54.234,8.343,51.521,-0.343`. |
| `language` | query | string | optional | For text input, adds a preferred language or locale to the set Autosuggest considers. Exact whole-word matches in the input can also add languages or locales. If omitted for text input, English is added as the default backstop. For voice input (`input-type` != `text`), this must be provided. Use a supported what3words code from `/available-languages`, including locale/script-specific codes where available (for example `mn_la`, `zh_tr`, `oo_la`). Default `en`. |
| `locale` | query | string | optional | Optional locale/script-specific code. Can be passed on its own. If provided with `language`, both values must be identical strings (for example `language=mn_la&locale=mn_la`). Example `locale=mn_la`. |
| `input-type` | query | string | optional | For power users, used to specify voice input mode. Can be `text` (default), `vocon-hybrid`, `nmdp-asr`, `generic-voice`, `speechmatics`, or `vin-big-data`. Voice modes require `language`. If `input` is not in the expected format for a selected voice mode, the API may return `BadInput`. One of `text`, `vocon-hybrid`, `nmdp-asr`, `generic-voice`, `speechmatics`, `vin-big-data`. Default `text`. |
| `n-results` | query | integer | optional | The number of AutoSuggest results to return. Non-numeric values return `BadNResults`. Values greater than 100 are truncated to 100. Values less than or equal to 0 return an empty suggestions list. The default is 3. Default `3`. Maximum 100. |
| `prefer-land` | query | boolean | optional | Makes AutoSuggest prefer results on land to those in the sea. This setting is on by default. Use false to disable this setting and receive more suggestions in the sea. Default `true`. |
| `format` | query | string | optional | Return data format type; can be either `json` (the default) or `geojson`. One of `json`, `geojson`. Default `json`. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/autosuggest-with-coordinates?input=film.crunchy.spiri&focus=50.842404,4.361177&key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
input: 'film.crunchy.spiri',
focus: '50.842404,4.361177',
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/autosuggest-with-coordinates?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/autosuggest-with-coordinates",
params={"input": "film.crunchy.spiri", "focus": "50.842404,4.361177", "key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"suggestions": [
{
"country": "BE",
"square": {
"southwest": {
"lng": 4.347436,
"lat": 50.848237
},
"northeast": {
"lng": 4.347479,
"lat": 50.848264
}
},
"nearestPlace": "Brussels, Brussels Capital",
"words": "film.crunchy.spirits",
"coordinates": {
"lng": 4.347457,
"lat": 50.848251
},
"rank": 1,
"distanceToFocusKm": 1,
"language": "en",
"map": "https://w3w.co/film.crunchy.spirits"
},
{
"country": "ES",
"square": {
"southwest": {
"lng": 2.164394,
"lat": 41.625835
},
"northeast": {
"lng": 2.16443,
"lat": 41.625862
}
},
"nearestPlace": "Caldes de Montbui, Catalonia",
"words": "film.crunchy.spirit",
"coordinates": {
"lng": 2.164412,
"lat": 41.625849
},
"rank": 2,
"distanceToFocusKm": 1039,
"language": "en",
"map": "https://w3w.co/film.crunchy.spirit"
},
{
"country": "NL",
"square": {
"southwest": {
"lng": 5.681058,
"lat": 51.289807
},
"northeast": {
"lng": 5.681101,
"lat": 51.289834
}
},
"nearestPlace": "Weert, Limburg",
"words": "firm.crunchy.spires",
"coordinates": {
"lng": 5.68108,
"lat": 51.289821
},
"rank": 3,
"distanceToFocusKm": 105,
"language": "en",
"map": "https://w3w.co/firm.crunchy.spires"
}
]
}
```
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `suggestions[]` | array of AutosuggestWithCoordinatesSuggestion | List of suggested what3words addresses including coordinates |
| `suggestions[].words` | string | The suggested what3words address |
| `suggestions[].country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `suggestions[].square` | object (Square) | |
| `suggestions[].square.southwest` | object (Coordinates) | |
| `suggestions[].square.southwest.lat` | number | Latitude |
| `suggestions[].square.southwest.lng` | number | Longitude |
| `suggestions[].square.northeast` | object (Coordinates) | |
| `suggestions[].square.northeast.lat` | number | Latitude |
| `suggestions[].square.northeast.lng` | number | Longitude |
| `suggestions[].nearestPlace` | string | The nearest place to the what3words address |
| `suggestions[].coordinates` | object (Coordinates) | |
| `suggestions[].coordinates.lat` | number | Latitude |
| `suggestions[].coordinates.lng` | number | Longitude |
| `suggestions[].language` | string | The language of the what3words address |
| `suggestions[].locale` | string | The locale of the what3words address, if returned |
| `suggestions[].rank` | integer | The relative ranking of this suggestion |
| `suggestions[].distanceToFocusKm` | number | The distance in kilometers from the focus point to this suggestion's coordinates |
| `suggestions[].map` | string | URL to view the what3words address on the what3words map |
### Responses
**200** Successful autosuggest results (application/json). Schema: AutosuggestWithCoordinatesResponse
**400** Bad request (application/json). Schema: ErrorResponse
**MissingInput**
```json
{
"error": {
"code": "MissingInput",
"message": "input must be specified"
}
}
```
**BadFocus**
```json
{
"error": {
"code": "BadFocus",
"message": "focus must be a lat,lng"
}
}
```
**BadClipToCountry**
```json
{
"error": {
"code": "BadClipToCountry",
"message": "Countries are specified as a comma separated list of uppercase ISO 3166-1 alpha-2 country codes, such as US,CA"
}
}
```
**BadClipToBoundingBox**
```json
{
"error": {
"code": "BadClipToBoundingBox",
"message": "Must be four lat,lng,lat,lng coordinates such as 50,-2,53.12,2.34"
}
}
```
**BadClipToCircle**
```json
{
"error": {
"code": "BadClipToCircle",
"message": "clip-to-circle needs to be lat,lng,km. Example: 51.453,0.344,112"
}
}
```
**BadClipToPolygon**
```json
{
"error": {
"code": "BadClipToPolygon",
"message": "Failed to parse one of the coordinates as a valid decimal number"
}
}
```
**MissingLanguage**
```json
{
"error": {
"code": "MissingLanguage",
"message": "for voice input. language must be specified"
}
}
```
**BadLanguage**
```json
{
"error": {
"code": "BadLanguage",
"message": "language must be a supported what3words language code, such as 'en', 'fr' or 'mn_la'"
}
}
```
**BadInputType**
```json
{
"error": {
"code": "BadInputType",
"message": "prefer-land must be one of true or false"
}
}
```
**BadLanguageLocaleMismatch**
```json
{
"error": {
"code": "BadLanguage",
"message": "language and locale must not be different"
}
}
```
**BadNResults**
```json
{
"error": {
"code": "BadNResults",
"message": "n-results must be a valid integer"
}
}
```
**BadNFocusResults**
```json
{
"error": {
"code": "BadNFocusResults",
"message": "n-focus-results must be a valid integer"
}
}
```
**BadInput**
```json
{
"error": {
"code": "BadInput",
"message": "Invalid autosuggest input"
}
}
```
**DuplicateParameter**
```json
{
"error": {
"code": "DuplicateParameter",
"message": "Duplicate parameter 'input'. Please only pass in one of each parameter."
}
}
```
**401** Unauthorized - Invalid API key (application/json). Schema: ErrorResponse
**InvalidKey**
```json
{
"error": {
"code": "InvalidKey",
"message": "Authentication failed; invalid API key"
}
}
```
**InvalidKeyNoPermissions**
```json
{
"error": {
"code": "InvalidKey",
"message": "Auth failed; /v3/autosuggest-with-coordinates. Contact support@what3words.com or your account manager to enable your account"
}
}
```
**MissingKey**
```json
{
"error": {
"code": "MissingKey",
"message": "Authentication failed; missing required API key parameter or header"
}
}
```
[Read the guide](https://developer.what3words.com/public-api/docs#autosuggest-with-coordinates)
## Grid section
`GET https://api.what3words.com/v3/grid-section`
Returns a section of the 3m x 3m what3words grid for a bounding box. The bounding box is specified by lat,lng,lat,lng as south,west,north,east. You can request the grid in GeoJSON format, making it very simple to display on a map.
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
| `bounding-box` | query | string | required | Bounding box, as a `lat,lng,lat,lng`, for which the grid should be returned. The requested box must not exceed `4km` from corner to corner, or a `BadBoundingBoxTooBig` error will be returned. Latitudes must be `>= -90` and `<= 90`, but longitudes are allowed to wrap around 180. To specify a bounding-box that crosses the anti-meridian, use longitude greater than 180. e.g.: `bounding-box=50.0,179.995,50.01,180.0005`. Example `bounding-box=52.207988,0.116126,52.208867,0.117540`. |
| `format` | query | string | optional | Return data format type; can be either `json` (the default) or `geojson`. One of `json`, `geojson`. Default `json`. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/grid-section?bounding-box=52.207988,0.116126,52.208867,0.117540&key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
'bounding-box': '52.207988,0.116126,52.208867,0.117540',
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/grid-section?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/grid-section",
params={"bounding-box": "52.207988,0.116126,52.208867,0.117540", "key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"lines": [
{
"start": {
"lng": 0.116126,
"lat": 52.20801
},
"end": {
"lng": 0.11754,
"lat": 52.20801
}
},
{
"start": {
"lng": 0.116126,
"lat": 52.208037
},
"end": {
"lng": 0.11754,
"lat": 52.208037
}
}
]
}
```
**GeoJSON**
```json
{
"features": [
{
"geometry": {
"coordinates": [
[
[
0.116126,
52.20801
],
[
0.11754,
52.20801
]
],
[
[
0.116126,
52.208037
],
[
0.11754,
52.208037
]
]
],
"type": "MultiLineString"
},
"type": "Feature",
"properties": {}
}
],
"type": "FeatureCollection"
}
```
*Shortened to the first two lines of the grid; the full response has a line for every grid row and column in the bounding box.*
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `lines[]` | array of object | Array of line objects that make up the grid |
| `lines[].start` | object (Coordinates) | |
| `lines[].start.lat` | number | Latitude |
| `lines[].start.lng` | number | Longitude |
| `lines[].end` | object (Coordinates) | |
| `lines[].end.lat` | number | Latitude |
| `lines[].end.lng` | number | Longitude |
### Responses
**200** Successful grid section retrieval (application/json, application/geo+json). Schema: GridSectionResponse
**400** Bad request (application/json)
**BadBoundingBox**
```json
{
"error": {
"code": "BadBoundingBox",
"message": "bounding-box must be specified as south_lat,west_lng,north_lat,east_lng"
}
}
```
**BadBoundingBoxTooBig**
```json
{
"error": {
"code": "BadBoundingBoxTooBig",
"message": "Bounding box too large (exceeds 4km from corner to corner)"
}
}
```
**BadFormat**
```json
{
"error": {
"code": "BadFormat",
"message": "Format must be one of json,geojson"
}
}
```
**DuplicateParameter**
```json
{
"error": {
"code": "DuplicateParameter",
"message": "Duplicate parameter 'bounding-box'. Please only pass in one of each parameter."
}
}
```
**401** Unauthorized - Invalid API key (application/json). Schema: ErrorResponse
**InvalidKey**
```json
{
"error": {
"code": "InvalidKey",
"message": "Authentication failed; invalid API key"
}
}
```
**MissingKey**
```json
{
"error": {
"code": "MissingKey",
"message": "Authentication failed; missing required API key parameter or header"
}
}
```
[Read the guide](https://developer.what3words.com/public-api/docs#grid-section) · [Try it in the Playground](https://developer.what3words.com/public-api/playground#grid-section)
## Available languages
`GET https://api.what3words.com/v3/available-languages`
Retrieves all available what3words address languages and locale/script variants, including language code, English name and native name. Use top-level `code` values as base `language` codes, and use nested `locales[].code` values where explicit locale/script selection is needed (for example `en`, `mn`, `mn_la`, `zh_tr`, `oo_cy`).
### Parameters
| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `key` | query | string | optional | A valid API key. Provide it as query parameter `key`; `X-Api-Key` header is also supported. |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v3/available-languages?key=YOUR_API_KEY'
```
**JavaScript**
```javascript
const params = new URLSearchParams({
key: 'YOUR_API_KEY',
});
const response = await fetch(`https://api.what3words.com/v3/available-languages?${params}`);
const data = await response.json();
console.log(data);
```
**Python**
```python
import requests
response = requests.get(
"https://api.what3words.com/v3/available-languages",
params={"key": "YOUR_API_KEY"},
)
print(response.json())
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"languages": [
{
"nativeName": "Deutsch",
"code": "de",
"name": "German"
},
{
"nativeName": "English",
"code": "en",
"name": "English"
},
{
"nativeName": "Français",
"code": "fr",
"name": "French"
},
{
"nativeName": "Монгол хэл",
"code": "mn",
"name": "Mongolian",
"locales": [
{
"nativeName": "Монгол хэл (Латинаар)",
"name": "Mongolian (Latin)",
"code": "mn_la"
},
{
"nativeName": "Монгол хэл (Криллээр)",
"name": "Mongolian (Cyrillic)",
"code": "mn_cy"
}
]
},
{
"nativeName": "中文",
"code": "zh",
"name": "Chinese",
"locales": [
{
"nativeName": "中文(繁體)",
"name": "Chinese (Traditional)",
"code": "zh_tr"
},
{
"nativeName": "中文(简体)",
"name": "Chinese (Simplified)",
"code": "zh_si"
}
]
}
]
}
```
*Shortened to five languages; the full response lists all 58 languages.*
### Response fields
| Field | Type | Description |
| --- | --- | --- |
| `languages[]` | array of Language | List of available languages |
| `languages[].code` | string | The what3words language code for the language or language family (for example `en`, `mn`, `oo`). |
| `languages[].name` | string | The English name of the language |
| `languages[].nativeName` | string | The name of the language in that language |
| `languages[].locales[]` | array of Locale | List of available locales for this language, if applicable |
| `languages[].locales[].code` | string | The locale code |
| `languages[].locales[].name` | string | The name of the locale |
| `languages[].locales[].nativeName` | string | The native name of the locale |
### Responses
**200** Successful retrieval of available languages (application/json). Schema: AvailableLanguagesResponse
**401** Unauthorized - Invalid API key (application/json). Schema: ErrorResponse
**InvalidKey**
```json
{
"error": {
"code": "InvalidKey",
"message": "Authentication failed; invalid API key"
}
}
```
**MissingKey**
```json
{
"error": {
"code": "MissingKey",
"message": "Authentication failed; missing required API key parameter or header"
}
}
```
[Read the guide](https://developer.what3words.com/public-api/docs#available-languages)
## Schemas
The objects the endpoints return.
### Coordinates
| Field | Type | Description |
| --- | --- | --- |
| `lat` | number | Latitude |
| `lng` | number | Longitude |
### Square
| Field | Type | Description |
| --- | --- | --- |
| `southwest` | object (Coordinates) | |
| `southwest.lat` | number | Latitude |
| `southwest.lng` | number | Longitude |
| `northeast` | object (Coordinates) | |
| `northeast.lat` | number | Latitude |
| `northeast.lng` | number | Longitude |
### ConvertTo3waResponse
| Field | Type | Description |
| --- | --- | --- |
| `country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `square` | object (Square) | |
| `square.southwest` | object (Coordinates) | |
| `square.southwest.lat` | number | Latitude |
| `square.southwest.lng` | number | Longitude |
| `square.northeast` | object (Coordinates) | |
| `square.northeast.lat` | number | Latitude |
| `square.northeast.lng` | number | Longitude |
| `nearestPlace` | string | The nearest place to the what3words address |
| `coordinates` | object (Coordinates) | |
| `coordinates.lat` | number | Latitude |
| `coordinates.lng` | number | Longitude |
| `words` | string | The what3words address |
| `language` | string | The language of the what3words address |
| `locale` | string | The locale of the what3words address, if returned |
| `map` | string | URL to view the what3words address on the what3words map |
### ConvertToCoordinatesResponse
| Field | Type | Description |
| --- | --- | --- |
| `country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `square` | object (Square) | |
| `square.southwest` | object (Coordinates) | |
| `square.southwest.lat` | number | Latitude |
| `square.southwest.lng` | number | Longitude |
| `square.northeast` | object (Coordinates) | |
| `square.northeast.lat` | number | Latitude |
| `square.northeast.lng` | number | Longitude |
| `nearestPlace` | string | The nearest place to the what3words address |
| `coordinates` | object (Coordinates) | |
| `coordinates.lat` | number | Latitude |
| `coordinates.lng` | number | Longitude |
| `words` | string | The what3words address |
| `language` | string | The language of the what3words address |
| `locale` | string | The locale of the what3words address, if returned |
| `map` | string | URL to view the what3words address on the what3words map |
### AutosuggestResponse
| Field | Type | Description |
| --- | --- | --- |
| `suggestions[]` | array of AutosuggestSuggestion | List of suggested what3words addresses |
| `suggestions[].words` | string | The suggested what3words address |
| `suggestions[].country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `suggestions[].nearestPlace` | string | The nearest place to the what3words address |
| `suggestions[].language` | string | The language of the what3words address |
| `suggestions[].locale` | string | The locale of the what3words address, if applicable |
| `suggestions[].rank` | integer | The relative ranking of this suggestion |
| `suggestions[].distanceToFocusKm` | number | The distance in kilometers from the focus point to this suggestion's coordinates |
### GridSectionResponse
| Field | Type | Description |
| --- | --- | --- |
| `lines[]` | array of object | Array of line objects that make up the grid |
| `lines[].start` | object (Coordinates) | |
| `lines[].start.lat` | number | Latitude |
| `lines[].start.lng` | number | Longitude |
| `lines[].end` | object (Coordinates) | |
| `lines[].end.lat` | number | Latitude |
| `lines[].end.lng` | number | Longitude |
### GridSectionGeoJsonResponse
GeoJSON representation of the grid section
### Locale
| Field | Type | Description |
| --- | --- | --- |
| `code` | string | The locale code |
| `name` | string | The name of the locale |
| `nativeName` | string | The native name of the locale |
### Language
| Field | Type | Description |
| --- | --- | --- |
| `code` | string | The what3words language code for the language or language family (for example `en`, `mn`, `oo`). |
| `name` | string | The English name of the language |
| `nativeName` | string | The name of the language in that language |
| `locales[]` | array of Locale | List of available locales for this language, if applicable |
| `locales[].code` | string | The locale code |
| `locales[].name` | string | The name of the locale |
| `locales[].nativeName` | string | The native name of the locale |
### AvailableLanguagesResponse
| Field | Type | Description |
| --- | --- | --- |
| `languages[]` | array of Language | List of available languages |
| `languages[].code` | string | The what3words language code for the language or language family (for example `en`, `mn`, `oo`). |
| `languages[].name` | string | The English name of the language |
| `languages[].nativeName` | string | The name of the language in that language |
| `languages[].locales[]` | array of Locale | List of available locales for this language, if applicable |
| `languages[].locales[].code` | string | The locale code |
| `languages[].locales[].name` | string | The name of the locale |
| `languages[].locales[].nativeName` | string | The native name of the locale |
### Error
| Field | Type | Description |
| --- | --- | --- |
| `code` | string | Error code that can be used programmatically |
| `message` | string | A helpful message explaining what went wrong |
### ErrorResponse
| Field | Type | Description |
| --- | --- | --- |
| `error` | object (Error) | |
| `error.code` | string | Error code that can be used programmatically |
| `error.message` | string | A helpful message explaining what went wrong |
### AutosuggestSuggestion
| Field | Type | Description |
| --- | --- | --- |
| `words` | string | The suggested what3words address |
| `country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `nearestPlace` | string | The nearest place to the what3words address |
| `language` | string | The language of the what3words address |
| `locale` | string | The locale of the what3words address, if applicable |
| `rank` | integer | The relative ranking of this suggestion |
| `distanceToFocusKm` | number | The distance in kilometers from the focus point to this suggestion's coordinates |
### AutosuggestWithCoordinatesSuggestion
| Field | Type | Description |
| --- | --- | --- |
| `words` | string | The suggested what3words address |
| `country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `square` | object (Square) | |
| `square.southwest` | object (Coordinates) | |
| `square.southwest.lat` | number | Latitude |
| `square.southwest.lng` | number | Longitude |
| `square.northeast` | object (Coordinates) | |
| `square.northeast.lat` | number | Latitude |
| `square.northeast.lng` | number | Longitude |
| `nearestPlace` | string | The nearest place to the what3words address |
| `coordinates` | object (Coordinates) | |
| `coordinates.lat` | number | Latitude |
| `coordinates.lng` | number | Longitude |
| `language` | string | The language of the what3words address |
| `locale` | string | The locale of the what3words address, if returned |
| `rank` | integer | The relative ranking of this suggestion |
| `distanceToFocusKm` | number | The distance in kilometers from the focus point to this suggestion's coordinates |
| `map` | string | URL to view the what3words address on the what3words map |
### AutosuggestWithCoordinatesResponse
| Field | Type | Description |
| --- | --- | --- |
| `suggestions[]` | array of AutosuggestWithCoordinatesSuggestion | List of suggested what3words addresses including coordinates |
| `suggestions[].words` | string | The suggested what3words address |
| `suggestions[].country` | string | The country in which the what3words address is located, as an ISO 3166-1 alpha-2 country code |
| `suggestions[].square` | object (Square) | |
| `suggestions[].square.southwest` | object (Coordinates) | |
| `suggestions[].square.southwest.lat` | number | Latitude |
| `suggestions[].square.southwest.lng` | number | Longitude |
| `suggestions[].square.northeast` | object (Coordinates) | |
| `suggestions[].square.northeast.lat` | number | Latitude |
| `suggestions[].square.northeast.lng` | number | Longitude |
| `suggestions[].nearestPlace` | string | The nearest place to the what3words address |
| `suggestions[].coordinates` | object (Coordinates) | |
| `suggestions[].coordinates.lat` | number | Latitude |
| `suggestions[].coordinates.lng` | number | Longitude |
| `suggestions[].language` | string | The language of the what3words address |
| `suggestions[].locale` | string | The locale of the what3words address, if returned |
| `suggestions[].rank` | integer | The relative ranking of this suggestion |
| `suggestions[].distanceToFocusKm` | number | The distance in kilometers from the focus point to this suggestion's coordinates |
| `suggestions[].map` | string | URL to view the what3words address on the what3words map |
---
# Partner API Docs
The what3words Partner API allows Partners to create and manage what3words API keys programmatically.
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md)
Source: https://developer.what3words.com/tutorial/partner-api-docs-what3words
Updated: 2025-11-14
The what3words Partner API allows Partners to create and manage what3words API keys programmatically. The following tasks can be performed using the Partner API
1. Create an API key
2. Get a list of all of an accounts API keys
3. Change status of an API key (disable/enable)
## 1. Get Started
- Create a what3words account by signing up to a plan
You will need a what3words API key to complete this tutorial [Get an API Key](https://accounts.what3words.com/select-plan) or [sign in](https://accounts.what3words.com/).
- Contact your account manager to request access to the Partner API
- Once enabled, obtain your Partner API key from your account manager
- Use your Partner API key in requests to the API
### Tips
1. Use HTTPS GET, POST and PATCH methods only
2. Remember to always URL encode your parameters
3. Always include a valid Partner API key in the key=\[YOUR\_API\_KEY\] parameter
### Authentication
The what3words Partner API uses [API keys](https://accounts.what3words.com/overview) to authenticate requests. Partner API Keys differ from keys for our main API with keys being 12 characters and prefixed “PK”.
All API requests must be made over [HTTPS](http://en.wikipedia.org/wiki/HTTP_Secure). Calls made over HTTP will fail. API requests without authentication will also fail.
### Error handling
If all went well, you will get a **200 HTTP** status code. If something went wrong, such as trying `application` POST without a key you will get the appropriate HTTP error status (403 in this case). Also, the body will contain a `message_code` which can be used programmatically so you can respond appropriately. `message` is intended as a helpful message to help you understand how to fix what went wrong.
### Response Codes
1. **200 OK**: The client application has been successfully linked with the partner application.
2. **400 Bad Request**: There was an issue with the request, typically due to:
- Missing partner api key `key` in the request query
- The provided `key` is not a partner application or it has been suspended
- Missing client api key `client_api_key` in the request body
- The provided `client_api_key` has already been linked.
**Response**
```json
{
"message_code": 894,
"message": "Client key not provided"
}
```
## 2. POST application
Create a what3words API key for use in an application. The key can then be used to make requests to the what3words Main API. A key can be created for each end client and can be used as a way to segment usage. When creating a new key the request must specify a name and description to identify the key.
**cURL**
```shellscript
curl --location --request POST 'https://accountsapi.what3words.com/partner/v1/application?key=PK2D3j230291' \
--header 'Content-Type: application/json' \
--data-raw '{"name": "name of app", "description": "description of app"}'
```
### Resource URL
[https://accountsapi.what3words.com/partner/v1/application](https://accountsapi.what3words.com/partner/v1/application)
### Parameters
| Parameters | Required/Optional | Description | Example |
| --- | --- | --- | --- |
| key | Required | Partner API key | key=PK2D3J230291 |
### Request body
| Request Body | Required/Optional | Description | Example |
| --- | --- | --- | --- |
| name | Required | Name of API key. Could be the account name or an ID. | "name": "My app" |
| description | Required | Description of API key. Could be the account name or an ID or type of account | "description": "My test app" |
### Example Request
#### POST
- [https://accountsapi.what3words.com/partner/v1/application?key=PK2D3J230291](https://accountsapi.what3words.com/partner/v1/application?key=PK2D3j230291)
- `{"name": "name of app", "description": "description of app"}`
### Example Result
**JSON**
```json
{
"api_key": "PG122LFC4W98",
"name": "name of app",
"description": "description of app",
"suspended": false
}
```
## 3. GET application
Obtain either one or all of the API keys connected to your partner account. Pass in a key to the request to return just a specific key details. The response will return the name and description of the key, along with it’s status (enabled/disabled).
**cURL**
```shellscript
curl --location --request GET 'https://accountsapi.what3words.com/partner/v1/application?key=PK2D3j230291&page=1&per_page=10'
```
### Resource URL
[https://accountsapi.what3words.com/partner/v1/application](https://accountsapi.what3words.com/partner/v1/application)
### Parameters
| Parameters | Required/Optional | Description | Example |
| --- | --- | --- | --- |
| key | Required | Partner API key | key=PK2D3J230291 |
| api\_key | Optional | API key | api\_key=LFC4W98R |
### Example Request
#### GET
- [https://accountsapi.what3words.com/partner/v1/application?key=PK2D3J230291&page=1&per\_page=10](https://accountsapi.what3words.com/partner/v1/application?key=PK2D3j230291&page=1&per_page=10)
### Example Result
**JSON**
```json
{
"message": "OK",
"page": 1,
"per_page": 10,
"total": 3,
"applications": [
{
"api_key": "D0O8DQAR",
"name": "app1",
"description": "desc1",
"suspended": false
},
{
"api_key": "U8KB3NZR",
"name": "app2",
"description": "desc2",
"suspended": false
},
{
"api_key": "LFC4W98R",
"name": "app3",
"description": "desc3",
"suspended": false
}
]
}
```
## 4. PATCH application
Enable or disable an API key. Disabling a key prevents the application from being able to make requests to the what3words Main API.
**cURL**
```shellscript
curl --location --request PATCH 'https://accountsapi.what3words.com/partner/v1/application?key=PK2D3j230291' \
--header 'Content-Type: application/json' \
--data-raw '{"suspended": false, "api_key": "PGLFC4W98R"}'
```
### Resource URL
[https://accountsapi.what3words.com/partner/v1/application](https://accountsapi.what3words.com/partner/v1/application)
### Parameters
| Parameters | Required/Optional | Description | Example |
| --- | --- | --- | --- |
| key | Required | Partner API key | key=PK2D3J230291 |
### Request body
| Request Body | Required/Optional | Description | Example |
| --- | --- | --- | --- |
| api\_key | Required | Key to be changed | "api\_key": "PGLFC4W98R" |
| suspended | Required | Suspended - true/false | "suspended": false |
### Example Request
#### PATCH
- https://accountsapi.what3words.com/partner/v1/application?key=PK2D3J230291
### Example Result
**JSON**
```json
{
"api_key": "PGLFC4W98R",
"name": "name of app",
"description": "description of app",
"suspended": false
}
```
## 5. POST application/link
Link an API key that was created “manually” (outside of the Partner API through accounts.what3words.com) to a Partner account for revenue share agreements.
**cURL**
```shellscript
curl --location --request POST 'https://accountsapi.what3words.com/partner/v1/application/link?key=PK2D3J230291' \
--header 'Content-Type: application/json' \
--data-raw '{"client_api_key": ""}'
```
### Resource URL
[https://accountsapi.what3words.com/partner/v1/application/link](https://accountsapi.what3words.com/partner/v1/application/link)
### Parameters
| Parameters | Required/Optional | Description | Example |
| --- | --- | --- | --- |
| key | Required | Partner API key | key=PK2D3J230291 |
### Request body
| Request Body | Required/Optional | Description | Example |
| --- | --- | --- | --- |
| client\_api\_key | Required | API key created through accounts.what3words.com | { "client\_api\_key": "" } |
### Example Request
#### POST
- https://accountsapi.what3words.com/partner/v1/application/link?key= Content-Type: application/json { “client\_api\_key”: “” }
---
# Detecting if text is in the format of a what3words address using RegEx
How to check if text is in the format of a what3words address, without having to ask the API.
Topics: .NET, Android, Angular, Dart, Flutter, Java, JavaScript, NodeJS, Objective-C, PHP, Python, React, Ruby, Rust, Swift, Vue, Mobile App, Server and Scripting, Website
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md)
Source: https://developer.what3words.com/tutorial/detecting-if-text-is-in-the-format-of-a-3-word-address
Updated: 2026-11-27
This tutorial aims to guide you through the process of using Regular Expressions (RegEx) to identify and verify what3words addresses in text strings. For a human-friendly guide explaining how the RegEx works, see [here](https://what3words.com/news/blog/understanding-the-what3words-regex-a-human-friendly-guide).
## 1. AI & LLMs (no real-time autosuggest)
**JavaScript**
```javascript
var regex = /(?:\b(?:https?:\/\/)?(?:www\.)?(?:what3words\.com|w3w\.co)\/((?:(?:\p{L}\p{M}*)+[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)){2}(?:\p{L}\p{M}*)+|(?:\p{L}\p{M}*)+(?:[\u0020\u00A0](?:\p{L}\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+(?:[\u0020\u00A0](?:\p{L}\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+(?:[\u0020\u00A0](?:\p{L}\p{M}*)+){1,3})(?!\/)(?=$|[?#]|[^\p{L}\p{M}]))|(?:(?:^|(??/";:£§º©®\s/.。。・・︒។։။۔።।]))(?:/{0,3})((?:(?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+(?:[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){2})|(?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+(?:[\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){1,3}(?:[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+(?:[\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){1,3}){2})))(?![/.。。・・︒។։။۔።।]|[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s])""");
```
**Rust**
```rust
N/A: Rust doesn't support look-ahead and look-behind.
```
**Go**
```go
N/A: Go doesn't support look-ahead and look-behind.
```
**C++**
```cpp
wstring regex_search_url_vi = LR"rx((?:\b(?:what3words\.com|w3w\.co)/((?:(?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+)[.。。・・︒។։။۔።।](?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+)[.。。・・︒។։။۔።।](?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+))|(?:(?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+(?:[ \u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){1,3})[.。。・・︒។։။۔።।](?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+(?:[ \u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){1,3})[.。。・・︒។։။۔።।](?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+(?:[ \u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){1,3})))(?![/])(?=$|[0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]))|(?:(?:^|[0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s])/{0,3}((?:(?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+)[.。。・・︒។։။۔።।](?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+)[.。。・・︒។։။۔።।](?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+))|(?:(?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+(?:[ \u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){1,3})[.。。・・︒។։။۔።।](?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+(?:[ \u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){1,3})[.。。・・︒។։။۔።।](?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+(?:[ \u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s]+){1,3})))(?![/])(?=$|[0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/";:£§º©®\s])))rx";
```
## 2. Exact match of what3words
**JavaScript**
```javascript
var regex = /^\/{0,}(?:[\p{L}\p{M}]+[.。。・・︒។։။۔።।][\p{L}\p{M}]+[.。。・・︒។։။۔።।][\p{L}\p{M}]+|[\p{L}\p{M}]+([\u0020\u00A0][\p{L}\p{M}]+){1,3}[.。。・・︒។։။۔።।][\p{L}\p{M}]+([\u0020\u00A0][\p{L}\p{M}]+){1,3}[.。。・・︒។։။۔።।][\p{L}\p{M}]+([\u0020\u00A0][\p{L}\p{M}]+){1,3})$/gu;
```
**Java**
```java
String regex_string = "^/*(?:(?:\\p{L}\\p{M}*)+[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+|(?:\\p{L}\\p{M}*)+([\u0020\u00A0](?:\\p{L}\\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+([\u0020\u00A0](?:\\p{L}\\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+([\u0020\u00A0](?:\\p{L}\\p{M}*)+){1,3})$";
```
**Python**
```python
regex_match = r"^/*(?:[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]{1,}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]+[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]+|[^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]+){1,3}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]+){1,3}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]+([\u0020\u00A0][^0-9`~!@#$%^&*()+\-_=[{\]}\\|'<,.>?/\";:£§º©®\s]+){1,3})$"
```
**Swift**
```swift
regex_string = "^/*(?:[\\p{L}\\p{M}]+[.。。・・︒។։။۔።।][\\p{L}\\p{M}]+[.。。・・︒។։။۔።।][\\p{L}\\p{M}]+|[\\p{L}\\p{M}]+([\u{20}\u{A0}][\\p{L}\\p{M}]+){1,3}[.。。・・︒។։။۔።।][\\p{L}\\p{M}]+([\u{20}\u{A0}][\\p{L}\\p{M}]+){1,3}[.。。・・︒។։။۔።।][\\p{L}\\p{M}]+([\u{20}\u{A0}][\\p{L}\\p{M}]+){1,3})$"
```
**Objective-C**
```objective-c
NSString *regex_string = @"^/*(?:[\\p{L}\\p{M}]+[.。。・・︒។։။۔።।][\\p{L}\\p{M}]+[.。。・・︒។։။۔።।][\\p{L}\\p{M}]+|[\\p{L}\\p{M}]+([ \u00A0][\\p{L}\\p{M}]+){1,3}[.。。・・︒។։။۔።।][\\p{L}\\p{M}]+([ \u00A0][\\p{L}\\p{M}]+){1,3}[.。。・・︒។։။۔።।][\\p{L}\\p{M}]+([ \u00A0][\\p{L}\\p{M}]+){1,3})$";
```
**PHP**
```php
$regex_match = "/^\/*((?:\p{L}\p{M}*){1,}[.。。・・︒។։။۔።।](?:\p{L}\p{M}*){1,}[.。。・・︒។։။۔።।](?:\p{L}\p{M}*){1,}|\/*((?:\p{L}\p{M}*){1,}([\u{0020}\u{00A0}](?:\p{L}\p{M}*){1,}){1,3})[.。。・・︒។։။۔።।]((?:\p{L}\p{M}*){1,}([\u{0020}\u{00A0}](?:\p{L}\p{M}*){1,}){1,3})[.。。・・︒។։။۔።।]((?:\p{L}\p{M}*){1,}([\u{0020}\u{00A0}](?:\p{L}\p{M}*){1,}){1,3}))$/u";
```
**.NET**
```csharp
var regexExact = new Regex("^/*(?:(?:\\p{L}\\p{M}*)+[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+|(?:\\p{L}\\p{M}*)+([\u0020\u00A0](?:\\p{L}\\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+([\u0020\u00A0](?:\\p{L}\\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+([\u0020\u00A0](?:\\p{L}\\p{M}*)+){1,3})$");
```
**Ruby**
```ruby
regex_match = /^\/*(?:(?:\p{L}\p{M}*)+[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+|(?:\p{L}\p{M}*)+(?:[ \u{00A0}](?:\p{L}\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+(?:[ \u{00A0}](?:\p{L}\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+(?:[ \u{00A0}](?:\p{L}\p{M}*)+){1,3})$/
```
**Dart**
```dart
var regexExact = Regex("^/*(?:(?:\\p{L}\\p{M}*)+[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+|(?:\\p{L}\\p{M}*)+([\u0020\u00A0](?:\\p{L}\\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+([\u0020\u00A0](?:\\p{L}\\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\\p{L}\\p{M}*)+([\u0020\u00A0](?:\\p{L}\\p{M}*)+){1,3})$");
```
**Rust**
```rust
let regex_match = r#"^\/*(?:(?:\p{L}\p{M}*)+[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+|(?:\p{L}\p{M}*)+(?:[ \u{00A0}](?:\p{L}\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+(?:[ \u{00A0}](?:\p{L}\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+(?:[ \u{00A0}](?:\p{L}\p{M}*)+){1,3})$"#;
```
**Go**
```go
regexMatch := `^\/*(?:(?:\p{L}\p{M}*)+[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+|(?:\p{L}\p{M}*)+(?:[ \x{00A0}](?:\p{L}\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+(?:[ \x{00A0}](?:\p{L}\p{M}*)+){1,3}[.。。・・︒។։။۔።।](?:\p{L}\p{M}*)+(?:[ \x{00A0}](?:\p{L}\p{M}*)+){1,3})$`
```
**C++**
```cpp
wstring regex_match = L"(^/*(?:[^0-9`~!@#$%^&*()+\\-_=\\]\\[{\\}\\\\|'<,.>?/\";:£§º©®\\s]{1,}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\\-_=\\]\\[{\\}\\\\|'<,.>?/\";:£§º©®\\s]{1,}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\\-_=\\]\\[{\\}\\\\|'<,.>?/\";:£§º©®\\s]{1,}|[^0-9`~!@#$%^&*()+\\-_=\\]\\[{\\}\\\\|'<,.>?/\";:£§º©®\\s]{1,}([\u0020\u00A0][^0-9`~!@#$%^&*()+\\-_=[{\\]}\\\\|'<,.>?/\";:£§º©®\\s]+){1,3}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\\-_=\\]\\[{\\}\\\\|'<,.>?/\";:£§º©®\\s]{1,}([\u0020\u00A0][^0-9`~!@#$%^&*()+\\-_=[{\\]}\\\\|'<,.>?/\";:£§º©®\\s]+){1,3}[.。。・・︒។։။۔።।][^0-9`~!@#$%^&*()+\\-_=\\]\\[{\\}\\\\|'<,.>?/\";:£§º©®\\s]{1,}([\u0020\u00A0][^0-9`~!@#$%^&*()+\\-_=[{\\]}\\\\|'<,.>?/\";:£§º©®\\s]+){1,3})$)";
```
## 3. Matching what3words address format
### Overview
Our API wrapper RegEx function “`isPossible3wa`” (“is\_possible\_3wa” for Python & Rust API wrapper) can be used to detect if a text string (like “`filled.count.soap`“) in the format of a what3words address without having to ask the API. This functionality checks if a given string could be a what3words address. It returns **true** if it could be, otherwise **false**.
### Benefits
- **Quick Validation**: Rapidly determine if a string resembles a what3words address.
- **Error Prevention**: Helps avoid errors by flagging potential what3words addresses for further validation.
**JavaScript**
```javascript
import { AutosuggestClient } from "@what3words/api";
// Initialise the What3Words API with your API key
const API_KEY = 'YOUR_API_KEY';
const client = AutosuggestClient.init(API_KEY);
// Example what3words addresses
const addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"];
// Function to check if the address is a possible what3words address
const checkPossible3wa = (address) => {
const isPossible = client.isPossible3wa(address);
console.log(`Is '${address}' a possible what3words address? ${isPossible}`);
};
// Check each address
addresses.forEach(checkPossible3wa);
```
**Java**
```java
public class What3WordsExample {
public static void main(String[] args) {
// Example what3words addresses
String[] addresses = {"filled.count.soap", "not a 3wa", "not.3wa address"};
// Check if the addresses are possible what3words addresses
for (String address : addresses) {
boolean isPossible = What3WordsV3.isPossible3wa(address);
System.out.println("Is '" + address + "' a possible what3words address? " + isPossible);
}
}
}
```
**Python**
```python
import what3words
def main():
# Initialize the What3Words API with your API key
api_key = 'YOUR_API_KEY'
w3w = what3words.Geocoder(api_key)
# Example what3words addresses
addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"]
# Check if the addresses are possible what3words addresses
for address in addresses:
is_possible = w3w.is_possible_3wa(address)
print(f"Is '{address}' a possible what3words address? {is_possible}")
if __name__ == "__main__":
main()
```
**Swift**
```swift
import W3WSwiftApi
import CoreLocation
func main() {
// Initialize the What3Words API with your API key
let api = What3WordsV4(apiKey: "YOUR_API_KEY")
// Example what3words addresses
let addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"]
// Check if the addresses are possible what3words addresses
for address in addresses {
let isPossible = api.isPossible3wa(text: address)
print("Is '\(address)' a possible what3words address? \(isPossible)")
}
}
main()
```
**PHP**
```php
isPossible3wa($address);
echo "Is '{$address}' a possible what3words address? " . ($isPossible ? "true" : "false") . "\n";
}
}
main();
?>
```
**.NET**
```csharp
using System;
using what3words.dotnet.wrapper;
namespace What3WordsExample
{
class Program
{
static void Main(string[] args)
{
// Initialize the What3Words API with your API key
var api = new What3WordsV3("YOUR_API_KEY");
// Example what3words addresses
string[] addresses = { "filled.count.soap", "not a 3wa", "not.3wa address" };
// Check if the addresses are possible what3words addresses
foreach (var address in addresses)
{
bool isPossible = api.IsPossible3wa(address);
Console.WriteLine($"Is '{address}' a possible what3words address? {isPossible}");
}
}
}
}
```
**Ruby**
```ruby
require 'what3words'
def main
# Initialize the What3Words API with your API key
api_key = 'YOUR_API_KEY'
w3w = What3Words::API.new(:key => api_key)
# Example what3words addresses
addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"]
# Check if the addresses are possible what3words addresses
addresses.each do |address|
is_possible = w3w.isPossible3wa(address)
puts "Is '#{address}' a possible what3words address? #{is_possible}"
end
end
if __FILE__ == $0
main
end
```
**Dart**
```dart
void main() async {
// Replace 'what3words-api-key' with your actual API key
var api = What3WordsV3('what3words-api-key');
List addresses = ["filled.count.soap", "not a 3wa", "not.3wa address"];
// Check if the addresses are possible what3words addresses
for (String address in addresses) {
bool isPossible = api.isPossible3wa(address);
print("Is '$address' a possible what3words address? $isPossible");
}
}
```
**Rust**
```rust
use what3words_api::What3words;
fn main() {
// Initialize the what3words API with your API key
let api_key = "YOUR_API_KEY_HERE";
let w3w = What3words::new(api_key);
// Example what3words addresses
let addresses = [
"filled.count.soap",
"not a 3wa",
"not.3wa address",
];
// Check if the addresses are possible what3words addresses
for address in &addresses {
let is_possible = w3w.is_possible_3wa(address);
println!("Is '{}' a possible what3words address? {}", address, is_possible);
}
}
```
**Go**
```go
package main
import (
"fmt"
w3w "github.com/what3words/w3w-go-wrapper"
)
func main() {
// Initialize the What3Words API with your API key
apiKey := ""
service := w3w.NewService(apiKey)
// Example what3words addresses
addresses := []string{"filled.count.soap", "not a 3wa", "not.3wa address"}
// Check if the addresses are possible what3words addresses
for _, address := range addresses {
isPossible := service.IsPossible3wa(address)
fmt.Printf("Is '%s' a possible what3words address? %t\n", address, isPossible)
}
}
```
### Expected Output
- isPossible3wa(“filled.count.soap”) returns `true`
- isPossible3wa(“not a 3wa”) returns `false`
- isPossible3wa(“not.3wa address”) returns `false`
### Steps
1. **Initialise** the API with your What3Words API key. \[**Note**: *Not applicable for Java wrapper*\]
2. **Check** if each address is a possible what3words address using `isPossible3wa`.
3. **Print** the result for each address.
### Dependencies
Ensure you have the necessary dependencies installed for the what3words API Wrapper that you have chosen. For more information, refer to our [what3words API Wrappers](https://developer.what3words.com/public-api).
## 4. Verifying what3words addresses
### Overview
Our API wrapper RegEx function “`isValid3wa`” (“`is_valid_3wa`” for our Python & Rust API wrapper) can be used to determine if a string is a valid what3words address by checking it against the what3words regex filter and verifying it with the what3words API.
### Benefits
- **Reliable Validation**: Ensure the accuracy of what3words addresses by confirming their existence.
- **Integration with What3Words API**: Seamlessly integrate address verification with the what3words API.
**JavaScript**
```javascript
import { AutosuggestClient } from "@what3words/api";
const API_KEY = 'YOUR_API_KEY';
const client = AutosuggestClient.init(API_KEY);
// Example addresses
const addresses = [
"filled.count.soap",
"filled.count.",
"coding.is.cool"
];
// Function to check if the address is valid
const checkIsValid3wa = async (address) => {
try {
const isValid = await client.isValid3wa(address);
console.log(`Is '${address}' a valid what3words address? ${isValid}`);
} catch (error) {
console.error(`Error validating address '${address}':`, error);
}
};
// Check each address for validity
addresses.forEach(checkIsValid3wa);
```
**Java**
```java
public class What3WordsExample {
public static void main(String[] args) {
// Initialize the What3Words API with your API key
What3WordsV3 api = new What3WordsV3("YOUR_API_KEY");
// Example addresses
String[] addresses = {
"filled.count.soap",
"filled.count.",
"coding.is.cool"
};
// Check if the addresses are valid what3words addresses
for (String address : addresses) {
boolean response = api.isValid3wa(address);
if (response.isSuccessful() && response.getIsValid()) {
System.out.println(address + " is a valid what3words address");
} else if (response.isSuccessful() && !response.getIsValid()) {
System.out.println(address + " is an invalid what3words address");
} else {
System.out.println("isValid3wa error: " + response.getError().getKey() + " " + response.getError().getMessage());
}
}
}
}
```
**Python**
```python
import what3words
def main():
# Initialize the what3words API with your API key
api_key = 'YOUR_API_KEY'
w3w = what3words.Geocoder(api_key)
# Example addresses
addresses = [
"filled.count.soap",
"filled.count.",
"coding.is.cool"
]
# Check if the addresses are valid what3words addresses
for address in addresses:
is_valid = w3w.is_valid_3wa(address)
print(f"Is '{address}' a valid what3words address? {is_valid}")
if __name__ == "__main__":
main()
```
**Swift**
```swift
import W3WSwiftApi
import CoreLocation
func main() {
// Initialize the what3words API with your API key
let apiKey = "YOUR_API_KEY"
let api = What3WordsV4(apiKey: apiKey)
// Example addresses
let addresses = [
"filled.count.soap",
"filled.count.",
"coding.is.cool"
]
// Check if the addresses are valid what3words addresses
for address in addresses {
api.isValid3wa(words: address) { result in
if result == true {
print("'\(address)' is a valid what3words address")
} else {
print("'\(address)' is NOT a valid what3words address")
}
}
}
}
main()
```
**PHP**
```php
isValid3wa($address);
echo "Is '$address' a valid what3words address? " . ($isValid ? 'True' : 'False') . "\n";
}
}
main();
```
**.NET**
```csharp
using System;
using what3words.dotnet.wrapper;
namespace What3WordsExample
class Program
{
static void Main(string[] args)
{
// Initialize the what3words API with your API key
var api = new What3WordsV3("YOUR_API_KEY");
// Example addresses
string[] addresses = {
"filled.count.soap",
"filled.count.",
"coding.is.cool"
};
// Check if the addresses are valid what3words addresses
foreach (var address in addresses)
{
bool isValid = api.IsValid3wa(address);
Console.WriteLine($"Is '{address}' a valid what3words address? {isValid}");
}
}
}
```
**Ruby**
```ruby
require 'what3words'
def main
# Initialize the what3words API with your API key
api_key = 'YOUR_API_KEY'
w3w = What3Words::API.new(:key => api_key)
# Example addresses
addresses = [
"filled.count.soap",
"filled.count.",
"coding.is.cool"
]
# Check if the addresses are valid what3words addresses
addresses.each do |address|
is_valid = w3w.isValid3wa(address)
puts "Is '#{address}' a valid what3words address? #{is_valid}"
end
end
if __FILE__ == $0
main
end
```
**Dart**
```dart
void main() async {
// Replace 'what3words-api-key' with your actual API key
var api = What3WordsV3('what3words-api-key');
List w3w_addresses = [
"filled.count.soap",
"filled.count.",
"coding.is.cool"
];
// Iterate over the list and check if each address is valid
for (String w3w_address in w3w_addresses) {
var response = await api.isValid3wa(w3w_address);
if (response.isSuccessful() && response.isValid == true) {
print("$w3w_address is a valid what3words address");
} else if (response.isSuccessful() && response.isValid == false) {
print("$w3w_address is an invalid what3words address");
} else {
print("isValid3wa error: ${response.error?.code} - ${response.error?.message}");
}
}
}
```
**Rust**
```rust
use what3words_api::What3words;
fn main() {
// Initialize the what3words API with your API key
let api_key = "YOUR_API_KEY_HERE";
let w3w = What3words::new(api_key);
// Example addresses
let addresses = vec![
"filled.count.soap",
"filled.count.",
"coding.is.cool",
];
// Check if each address is a valid what3words address
for address in addresses {
let is_valid = w3w.is_valid_3wa(address);
println!("Is '{}' a valid what3words address? {}", address, is_valid);
}
}
```
**Go**
```go
package main
import (
"context"
"fmt"
w3w "github.com/what3words/w3w-go-wrapper"
)
func main() {
// Initialize the What3Words API with your API key
apiKey := ""
service := w3w.NewService(apiKey)
// Example addresses
addresses := []string{
"filled.count.soap",
"filled.count.",
"coding.is.cool",
}
// Check if the addresses are valid what3words addresses
for _, address := range addresses {
isValid, err := service.IsValid3wa(context.Background(), address)
if err != nil {
fmt.Printf("Error validating address '%s': %v\n", address, err)
} else {
fmt.Printf("Is '%s' a valid what3words address? %t\n", address, isValid)
}
}
}
```
### Expected Outputs
- isValid3wa(“filled.count.soap”) returns `True`
- isValid3wa(“filled.count.”) returns `False`
- isValid3wa(“coding.is.cool”) returns `False`
### Steps
1. **Initialise** the API with your What3Words API key.
2. **Define** example addresses to validate.
3. **Use** the `isValid3wa` function to check if each address is valid.
4. **Print** the validation results for each address.
### Dependencies
Ensure you have the necessary dependencies installed for the what3words API Wrapper that you have chosen. For more information, refer to our [what3words API Wrappers](https://developer.what3words.com/public-api).
## 5. Contact Support
### Have any questions?
We’re here to support you! If you have any questions while using our what3words Regex expressions, get in touch with us by writing us an email at [support@what3words.com](mailto:support@what3words.com).
---
# API v2
The what3words API allows you to convert a 3 word address to coordinates (forward geocoding), to convert coordinates to a 3 word address (reverse geocoding), to obtain suggestions based on a full or partial 3 word address (AutoSuggest, Voice AutoSuggest and StandardBlend), to obtain a geographically bounded section of the 3m x 3m what3words grid and to determine the languages that the API currently supports.
Section: [API & SDK Reference](https://developer.what3words.com/docs/api-sdk-reference.md) > [Cloud REST API](https://developer.what3words.com/public-api/docs.md)
Source: https://developer.what3words.com/public-api/docsv2
> [!WARNING]
> This page describes version 2 of the API which was officially deprecated in March 2019 and will no longer be available after the 1st February 2021. Please use the [latest version](https://developer.what3words.com/public-api/docs).
| Endpoint | Name | Description |
| --- | --- | --- |
| [`GET /v2/forward`](https://developer.what3words.com/public-api/docsv2#forward) | Forward geocoding | Forward geocodes a 3 word address to a position, expressed as coordinates of latitude and longitude. |
| [`GET /v2/reverse`](https://developer.what3words.com/public-api/docsv2#reverse) | Reverse geocoding | Reverse geocodes coordinates, expressed as latitude and longitude to a 3 word address. |
| [`GET /v2/autosuggest`](https://developer.what3words.com/public-api/docsv2#autosuggest) | AutoSuggest | Returns a list of 3 word addresses based on user input and other parameters. |
| [`GET /v2/voice-autosuggest`](https://developer.what3words.com/public-api/docsv2#voice-autosuggest) | Voice AutoSuggest | Returns a list of 3 word addresses based on an input string from a Cerence speech recognition system. |
| [`GET /v2/standardblend`](https://developer.what3words.com/public-api/docsv2#standardblend) | StandardBlend | Returns a blend of the three most relevant 3 word address candidates for a given location. |
| [`GET /v2/voice-standardblend`](https://developer.what3words.com/public-api/docsv2#voice-standardblend) | Voice StandardBlend | Returns a blend of the three most relevant candidates from Cerence VoCon Hybrid JSON. |
| [`GET /v2/grid`](https://developer.what3words.com/public-api/docsv2#grid-section) | Grid section | Returns a section of the 3m x 3m what3words grid for a given area. |
| [`GET /v2/languages`](https://developer.what3words.com/public-api/docsv2#available-languages) | Get languages | Retrieves a list of the currently loaded and available 3 word address languages. |
## Overview
### Get started
1. [Get your free API key.](https://accounts.what3words.com/select-plan)
2. Start using the what3words API by requesting a URL:
### 3 word address to coordinates
**URL**
```
https://api.what3words.com/v2/forward?addr=index.home.raft&key=YOUR_API_KEY
```
### Coordinates to 3 word address
**URL**
```
https://api.what3words.com/v2/reverse?coords=51.521251%2C-0.203586&key=YOUR_API_KEY
```
### Key points
- Use HTTPS GET method only
- Remember to always URL encode your parameters
- Always include a valid API key in the `key=api-key` parameter, or in the request header as `X-Api-Key: YOUR_API_KEY`
- We support [CORS](http://enable-cors.org/index.html), which allows Javascript requests to be made across domains. Each response contains the `Access-Control-Allow-Origin: *` header, that enables CORS.
### Error handling
Wherever possible, the what3words API tries to use the appropriate HTTP status code to indicate problems or errors when invoking an API resource; the status code and reason message are additionally returned in the `status` section of the response body as `status` and `reason` respectively.
Both the HTTP status and the API status should be checked; it is entirely possible to have an HTTP status of `200` returned because the API request was well formed but to have an API error code returned because the request generated an error or contained an invalid parameter.
For example, attempting to forward geocode an invalid 3 word address such as `no.address.here` would return an HTTP status of `200` and an API error code of `300`.
### Example error
```json
{
"status": {
"status": 200,
"reason": "OK",
"code": 300,
"message": "Invalid or non-existent 3 word address"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
```
| Code | Description |
| --- | --- |
| `200` | The API resource call was well formed and successfully handled; additional information may also be available in the `status` section of the response body. |
| `400` | An attempt was made to access an SSL only API endpoint via vanilla HTTP. |
| `400` | A required parameter was missing or contained an invalid value. |
| `401` | An invalid what3words API key was supplied or the what3words API key was missing. |
| `404` | An invalid or unknown API resource was invoked. |
| `405` | An invalid HTTP request method was used to access an API resource. |
| `50x` | A problem has occurred with the what3words API. |
Additional what3words specific error details are also provided in the `status` section of the response body as follows.
Authentication Failures:
| Code | Description |
| --- | --- |
| `1` | Authentication failed; missing required `key` parameter or header. |
| `2` | Authentication failed; invalid `key` parameter value or header value. |
| `3` | Authentication failed, the specified key is inactive. |
Optional Parameter Validation Failures:
| Code | Description |
| --- | --- |
| `100` | The `display` parameter is invalid or missing a display type. |
| `101` | The `format` parameter is invalid or missing a format type. |
| `102` | The `addr` parameter is invalid or missing a 3 word address. |
| `103` | The `lang` parameter is invalid or missing a language code. |
| `104` | The `coords` parameter is invalid or missing coordinates. |
| `105` | The `focus` parameter is invalid or missing coordinates or a 3 word address. |
| `106` | The `clip` parameter is invalid or missing the clip type and parameters. |
| `107` | The `count` parameter is invalid. |
| `108` | The `bbox` parameter is invalid. |
Mandatory Parameter Validation Failures
| Code | Description |
| --- | --- |
| `200` | Missing required `addr` parameter. |
| `201` | Missing required `coords` parameter. |
| `202` | Missing required `lang` parameter. |
| `203` | Missing required `bbox` parameter. |
Geocoding Failures
| Code | Description |
| --- | --- |
| `300` | Invalid or non-existent 3 word address. |
| `301` | Invalid or non-existent coordinates. |
Grid Failures
| Code | Description |
| --- | --- |
| `400` | The area described by the bounding box is too large; the distance between the NE and SW corners should be less than or equal to 2 km. |
## Forward geocoding
Forward geocodes a 3 word address to a position, expressed as coordinates of latitude and longitude.
`GET https://api.what3words.com/v2/forward`
### Parameters
| Parameter | Required | Description | Example |
| --- | --- | --- | --- |
| `addr` | required | A 3 word address as a string | `addr=index.home.raft` |
| `key` | required | A valid API key; if not supplied as a parameter, a key must be supplied as a request header | `key=YOUR_API_KEY` |
| `lang` | optional | A supported 3 word address language as an [ISO 639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) 2 letter code. Defaults to `en` (English). | `lang=fr` |
| `display` | optional | Return display type; can be one of `full` (the default), `terse` (less output) or `minimal` (the bare minimum) | `display=full` |
| `format` | optional | Return data format type; can be one of `json` (the default), `geojson` or `xml` | `format=geojson` |
| `callback` | optional | Specifies that the response should be JSONP wrapped as a function; supplying a `callback` parameter is only supported for JSON and GeoJSON format responses. | `callback=jsonp` |
### Example request
**cURL**
```shellscript
curl --request GET --url 'https://api.what3words.com/v2/forward?addr=index.home.raft&key=YOUR_API_KEY&lang=en&format=json&display=full'
```
**URL**
```
https://api.what3words.com/v2/forward?addr=index.home.raft&display=full&format=json&key=YOUR_API_KEY
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"crs": {
"properties": {
"type": "ogcwkt",
"href": "http://spatialreference.org/ref/epsg/4326/ogcwkt/"
},
"type": "link"
},
"bounds": {
"southwest": {
"lng": -0.203607,
"lat": 51.521238
},
"northeast": {
"lng": -0.203564,
"lat": 51.521265
}
},
"words": "index.home.raft",
"map": "http://w3w.co/index.home.raft",
"language": "en",
"geometry": {
"lng": -0.203586,
"lat": 51.521251
},
"status": {
"code": 200,
"message": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
```
**GeoJSON**
```json
{
"crs": {
"properties": {
"type": "ogcwkt",
"href": "http://spatialreference.org/ref/epsg/4326/ogcwkt/"
},
"type": "link"
},
"bbox": [
-0.203607,
51.521238,
-0.203564,
51.521265
],
"properties": {
"words": "index.home.raft",
"map": "http://w3w.co/index.home.raft",
"language": "en",
"status": {
"code": 200,
"message": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-0.203586,
51.521251
]
}
}
```
**XML**
```xml
index.home.raft
51.521251
-0.203586
51.521265
-0.203564
51.521238
-0.203607
en
http://spatialreference.org/ref/epsg/4326/ogcwkt/
200
OK
Thanks from all of us at index.home.raft for using a what3words API
```
## Reverse geocoding
Reverse geocodes coordinates, expressed as latitude and longitude to a 3 word address.
`GET https://api.what3words.com/v2/reverse`
### Parameters
| Parameter | Required | Description | Example |
| --- | --- | --- | --- |
| `coords` | required | Coordinates as a comma separated string of latitude and longitude | `coords=51.432393,-0.348023` |
| `key` | required | A valid API key; if not supplied as a parameter, a key must be supplied as a request header | `key=YOUR_API_KEY` |
| `lang` | optional | A supported 3 word address language as an ISO 639-1 2 letter code. Defaults to `en` | `lang=fr` |
| `display` | optional | Return display type; can be one of `full` (the default), `terse` (less output) or `minimal` (the bare minimum) | `display=full` |
| `format` | optional | Return data format type; can be one of `json` (the default), `geojson`or `xml` | `format=geojson` |
| `callback` | optional | Specifies that the response should be JSONP wrapped as a function; supplying a `callback` parameter is only supported for JSON and GeoJSON format responses. See JSONP Responses for more information. | `callback=jsonp` |
### Example request
**cURL**
```shellscript
curl --request GET --url 'https://api.what3words.com/v2/reverse?coords=51.521251%2C-0.203586&key=YOUR_API_KEY&lang=en&format=json&display=full'
```
**URL**
```
https://api.what3words.com/v2/reverse?coords=51.521251,-0.203586&display=full&format=json&key=YOUR_API_KEY
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"crs": {
"type": "link",
"properties": {
"href": "http://spatialreference.org/ref/epsg/4326/ogcwkt/",
"type": "ogcwkt"
}
},
"words": "index.home.raft",
"bounds": {
"southwest": {
"lng": -0.203607,
"lat": 51.521238
},
"northeast": {
"lng": -0.203564,
"lat": 51.521265
}
},
"geometry": {
"lng": -0.203586,
"lat": 51.521251
},
"language": "en",
"map": "http://w3w.co/index.home.raft",
"status": {
"code": 200,
"message": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
```
**GeoJSON**
```json
{
"crs": {
"type": "link",
"properties": {
"href": "http://spatialreference.org/ref/epsg/4326/ogcwkt/",
"type": "ogcwkt"
}
},
"bbox": [
-0.203607,
51.521238,
-0.203564,
51.521265
],
"geometry": {
"coordinates": [
-0.203586,
51.521251
],
"type": "Point"
},
"type": "Feature",
"properties": {
"words": "index.home.raft",
"language": "en",
"map": "http://w3w.co/index.home.raft",
"status": {
"code": 200,
"message": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
}
```
**XML**
```xml
index.home.raft
51.521251
-0.203586
51.521265
-0.203564
51.521238
-0.203607
en
http://spatialreference.org/ref/epsg/4326/ogcwkt/
200
OK
Thanks from all of us at index.home.raft for using a what3words API
```
## AutoSuggest
Returns a list of 3 word addresses based on user input and other parameters.
`GET https://api.what3words.com/v2/autosuggest`
This resource provides corrections for the following types of input error:
- typing errors
- spelling errors
- misremembered words (e.g. singular vs. plural)
- words in the wrong order
AutoSuggest determines possible corrections to the supplied 3 word address string based on the probability of the input errors listed above and returns a ranked list of suggestions. AutoSuggest can also take into consideration the geographic proximity of possible corrections to a given location to further improve the suggestions returned.
### Input 3 word address
All AutoSuggest variants accept either a full or partial 3 word address. If a partial 3 word address is specified, you will only receive results back if the partial 3 word address you submit contains the first two words and at least the first character of the third word; otherwise an error will be returned.
### Clipping and focus
We provide various `clip` policies to allow you to specify a geographic area that is used to exclude results that are not likely to be relevant to your users. We recommend that you use the `clip` parameter to give a more targeted, shorter set of results to your user. If you know your user’s current location, we also strongly recommend that you use the `focus` to return results which are likely to be more relevant (results near the user are considered to be more relevant).
In summary, the `clip` policy is used to optionally restrict the list of candidate AutoSuggest results, after which, if `focus` has been supplied, this will be used to weight the results in order of relevancy to the `focus`.
Multiple clipping policies can be specified, though only one of each type. For example you can clip to country and clip to circle in the same autosuggest call, and it will clip to the intersection of the two (results must be in the circle AND in the country). However, you can't specify two `clip-to-circle` policies in the same call.
### Language
AutoSuggest will search in all languages. However, you can additionally specify a fallback language, to help the API in situations where the input is particularly messy. The `lang` parameter is optional, and AutoSuggest will work well even without a `lang` parameter.
### Results
A maximum of 100 AutoSuggest results may be returned, but you may choose to display fewer results to your user e.g. the first 3 or 5 (depending on your user interface). By default, 3 results will be returned. It is possible we may increase the number of results returned in the future, so if you choose to limit the list of results returned, we recommend that you choose to include e.g. the top 3/5/7 results rather than choose to exclude the bottom e.g. 18/19/20 results.
### Parameters
| Parameter | Required | Description | Example |
| --- | --- | --- | --- |
| `addr` | required | The full or partial 3 word address to obtain suggestions for. At minimum this must be the first two complete words plus at least one character from the third word | `addr=plan.clips.a` |
| `key` | required | A valid API key; if not supplied as a parameter, a key must be supplied as a request header | `key=YOUR_API_KEY` |
| `lang` | optional | Specifies a fallback language, which will help guide AutoSuggest if the input is particularly messy. If specified, this parameter must be a supported 3 word address language as an ISO 639-1 2 letter code | `lang=fr` |
| `focus` | optional | A location, specified as a latitude,longitude used to refine the results. If specified, the results will be weighted to give preference to those near the specified location in addition to considering similarity to the `addr` string. If omitted the default behaviour is to weight results for similarity to the `addr` string only. | `focus=51.521251,-0.203586` |
| `clip` | optional | Restricts results to those within a geographical area. If omitted defaults to `clip=none`. See the section on clipping policies below for full details on the differing clip policies available. | `clip=radius(51.521251,-0.203586,10)` |
| `count` | optional | The number of AutoSuggest results to return. A maximum of 100 results can be specified, if a number greater than this is requested, this will be truncated to the maximum. The default is `3` | `count=5` |
| `display` | optional | Return display type; can be one of `full` (the default) or `terse` | `display=full` |
| `format` | optional | Return data format type; can be one of `json` (the default), `geojson` or `xml` | `format=json` |
| `callback` | optional | Specifies that the response should be JSONP wrapped as a function; supplying a `callback` parameter is only supported for JSON and GeoJSON format responses. See JSONP Responses for more information. | `callback=jsonp` |
### Clipping policies
| Policy | Default | Description | Example |
| --- | --- | --- | --- |
| `None` | default | No clipping takes place; this is the default. | `clip=none` |
| `Radius` | | `clip=radius(lat,lng,km)`. Clips to a radius of `km` kilometers from the point specified as `lat,lng`. | `clip=radius(51.521251,-0.203586,10)` |
| `Focus` | | `clip=focus(km)`. Clips to a radius of `km` kilometers from the point specified by the `focus` parameter. | `clip=focus(10)` |
| `Bounding Box` | | `clip=bbox(nelat,nelng,swlat,swlng)`. Clips to 3 word addresses that are fully contained inside a bounding box, specified by the northeast and southwest corner coordinates. | `clip=bbox(51.521215,-0.2036011,51.520982,-0.2041395)` |
### Example requests
#### AutoSuggest
This example returns AutoSuggest results for the partial 3 word address `plan.clips.a`; the results are not clipped and not ranked for proximity to a given location.
**URL**
```
https://api.what3words.com/v2/autosuggest?addr=plan.clips.a&lang=en&key=YOUR_API_KEY
```
#### AutoSuggest with focus and without clip policy
This example returns AutoSuggest results for the partial 3 word address `plan.clips.a`; the results are ranked for proximity relevance to the `focus` point of 51.4243877,-0.3474524.
**URL**
```
https://api.what3words.com/v2/autosuggest?addr=plan.clips.a&lang=en&focus=51.4243877,-0.3474524&key=YOUR_API_KEY
```
#### AutoSuggest with radius clip policy
This example returns AutoSuggest results for the partial 3 word address `plan.clips.a`; the results are constrained to those that are within 10 km of the point 51.4243877,-0.3474524.
**URL**
```
https://api.what3words.com/v2/autosuggest?addr=plan.clips.a&clip=radius(51.4243877,-0.3474524,10)&lang=en&key=YOUR_API_KEY
```
#### AutoSuggest with focus clip policy
This example returns AutoSuggest results for the partial 3 word address `plan.clips.a`; the results are constrained to those that are within 10 km of the `focus` point of 51.4243877,-0.3474524.
**URL**
```
https://api.what3words.com/v2/autosuggest?addr=plan.clips.a&focus=51.4243877,-0.3474524&clip=focus(10)&lang=en&key=YOUR_API_KEY
```
#### AutoSuggest with bounding box clip policy
This example returns AutoSuggest results for the partial 3 word address `plan.clips.a`; the results are constrained to those that are within the bounding box described by a NE corner of 54,2 and a SW corner of 50,-4; the results are then ranked for proximity relevance to the `focus` point of 51.4243877,-0.3474524.
**URL**
```
https://api.what3words.com/v2/autosuggest?addr=plan.clips.a&focus=51.4243877,-0.3474524&clip=bbox(54,2,50,-4)&lang=en&key=YOUR_API_KEY
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"suggestions": [
{
"country": "gb",
"distance": 14,
"words": "plan.clips.area",
"rank": 1,
"geometry": {
"lng": -0.140382,
"lat": 51.429293
},
"place": "Brixton Hill, London"
},
{
"country": "gb",
"distance": 7,
"words": "plan.flips.dawn",
"rank": 2,
"geometry": {
"lng": -0.443947,
"lat": 51.425332
},
"place": "Sunbury-on-Thames, Surrey"
},
{
"country": "gb",
"distance": 27,
"words": "plan.clips.arts",
"rank": 3,
"geometry": {
"lng": -0.249153,
"lat": 51.659134
},
"place": "Borehamwood, Herts."
}
],
"status": {
"status": 200,
"reason": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
```
**GeoJSON**
```json
{
{
"features": [
{
"geometry": {
"coordinates": [
-0.140382,
51.429293
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "gb",
"distance": 14,
"words": "plan.clips.area",
"rank": 1,
"place": "Brixton Hill, London"
}
},
{
"geometry": {
"coordinates": [
-0.443947,
51.425332
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "gb",
"distance": 7,
"words": "plan.flips.dawn",
"rank": 2,
"place": "Sunbury-on-Thames, Surrey"
}
},
{
"geometry": {
"coordinates": [
-0.249153,
51.659134
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "gb",
"distance": 27,
"words": "plan.clips.arts",
"rank": 3,
"place": "Borehamwood, Herts."
}
}
],
"type": "FeatureCollection",
"properties": {
"status": {
"status": 200,
"reason": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
}
```
**XML**
```xml
1
plan.clips.area
gb
Brixton Hill, London
51.429293
-0.140382
14
2
plan.flips.dawn
gb
Sunbury-on-Thames, Surrey
51.425332
-0.443947
7
3
plan.clips.arts
gb
Borehamwood, Herts.
51.659134
-0.249153
27
200
OK
Thanks from all of us at index.home.raft for using a what3words API
```
## Voice AutoSuggest
Returns a list of 3 word addresses based on an input string from one of two Cerence speech recognition systems: VoCon Hybrid and NDEV. The default of these is the Cerence Vocon Hybrid, which accepts URL-encoded JSON. The Cerence NDEV plain text output can also be passed to this endpoint, although the results generally have lower accuracy when dealing with a 3 word address input. Please note that this resource does not provide speech recognition capabilities and that a separate licensing agreement is required with Cerence to use the VoCon Hybrid and/or NDEV technologies.
`GET https://api.what3words.com/v2/voice-autosuggest`
This resource provides corrections for the following types of input error:
- words which sound similar
- misremembered words (e.g. singular vs. plural)
- words in the wrong order
The `voice-autosuggest` resource determines possible corrections to the supplied 3 word addresses based on the probability of the input errors listed above and returns a ranked list of suggestions. This resource can also take into consideration the geographic proximity of possible corrections to a given location to further improve the suggestions returned.
### Clipping and focus
We provide various `clip` policies to allow you to specify a geographic area that is used to exclude results that are not likely to be relevant to your users. We recommend that you use the `clip` parameter to give a more targeted, shorter set of results to your user. If you know your user’s current location, we also strongly recommend that you use the `focus` to return results which are likely to be more relevant (results near the user are considered to be more relevant).
In summary, the `clip` policy is used to optionally restrict the list of candidate Voice AutoSuggest results, after which, if `focus` has been supplied, this will be used to weight the results in order of relevancy to the `focus`.
### Language
The `lang` parameter is mandatory for `voice-autosuggest`; we recommend that you set this according to the language of your user interface, or the browser/device language of your user. If your software or app displays 3 word addresses to users (in addition to accepting 3 words as a search/input) then we recommend you set the language parameter for this resource to the same language that 3 word addresses are displayed to your users. Currently, English is the only supported language for voice but more languages will be available soon.
### JSON or text input
The `json` parameter is mandatory when using the Cerence VoCon Hybrid speech recognition system, which is the default. To use the Cerence NDEV text input, you should specify `voice-type=ndev`, at which point the `text` parameter is mandatory. Both strings will typically contain non-URL complaint characters, and should be URL-encoded.
### Results
A maximum of 20 Voice AutoSuggest results may be returned, but you may choose to display fewer results to your user e.g. the first 3 or 5 (depending on your user interface). By default, 3 results will be returned. It is possible we may increase the number of results returned in the future, so if you choose to limit the list of results returned, we recommend that you choose to include e.g. the top 3/5/7 results rather than choose to exclude the bottom e.g. 18/19/20 results.
### Parameters
| Parameter | Required | Description | Example |
| --- | --- | --- | --- |
| `json` | required (see `voice-type`) | Cerence VoCon Hybrid JSON, which must be URL encoded. | `json=[URL encoded JSON string]` |
| `text` | required (see `voice-type`) | Cerence NDEV output, which must be URL encoded. | `text=[URL encoded text with spaces and newlines]` |
| `key` | required | A valid API key; if not supplied as a parameter, a key must be supplied as a request header | `key=YOUR_API_KEY` |
| `lang` | required | A supported 3 word address language as an ISO 639-1 2 letter code | `lang=fr` |
| `focus` | optional | A location, specified as a latitude,longitude used to refine the results. If specified, the results will be weighted to give preference to those near the specified location in addition to considering similarity to the voice input. If omitted the default behaviour is to weight results for similarity to the voice input only. | `focus=51.521251,-0.203586` |
| `clip` | optional | Restricts results to those within a geographical area. If omitted defaults to `clip=none`. See the section on clipping policies below for full details on the differing clip policies available. | `clip=radius(51.521251,-0.203586,10)` |
| `count` | optional | The number of Voice AutoSuggest results to return. A maximum of 20 results can be specified, if a number greater than 20 is requested, this will be truncated to the maximum. The default is `3` | `count=5` |
| `voice-type` | optional | Which Cerence speech recognition system is being used, and therefore which parameter of `json=` and `text=` is required. Can be one of `vocon` (the default) or `ndev` | `voice-type=vocon` |
| `display` | optional | Return display type; can be one of `full` (the default) or `terse` | `display=full` |
| `format` | optional | Return data format type; can be one of `json` (the default), `geojson` or `xml` | `format=json` |
| `callback` | optional | Specifies that the response should be JSONP wrapped as a function; supplying a `callback` parameter is only supported for JSON and GeoJSON format responses. See JSONP Responses for more information. | `callback=jsonp` |
### Clipping policies
| Policy | Default | Description | Example |
| --- | --- | --- | --- |
| `None` | default | No clipping takes place; this is the default. | `clip=none` |
| `Radius` | | `clip=radius(lat,lng,km)`. Clips to a radius of `km` kilometers from the point specified as `lat,lng`. | `clip=radius(51.521251,-0.203586,10)` |
| `Focus` | | `clip=focus(km)`. Clips to a radius of `km` kilometers from the point specified by the `focus` parameter. | `clip=focus(10)` |
| `Bounding Box` | | `clip=bbox(nelat,nelng,swlat,swlng)`. Clips to 3 word addresses that are fully contained inside a bounding box, specified by the northeast and southwest corner coordinates. | `clip=bbox(51.521215,-0.2036011,51.520982,-0.2041395)` |
### Example requests
#### Voice AutoSuggest with focus and without clip policy
This example returns Voice AutoSuggest results for the supplied Cerence VoCon Hybrid JSON; the results are ranked for proximity relevance to the `focus` point of 51.4243877,-0.3474524.
**URL**
```
https://api.what3words.dev/v2/voice-autosuggest?json=%7B%22_isInGrammar%22%3A%22yes%22%2C%22_isSpeech%22%3A%22yes%22%2C%22_hypotheses%22%3A%5B%7B%22_score%22%3A342516%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6546%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34225%2C%22_orthography%22%3A%22tend%22%2C%22_conf%22%3A6964%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A43800%2C%22_orthography%22%3A%22poached%22%2C%22_conf%22%3A6181%2C%22_endTimeMs%22%3A4060%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342631%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6498%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34340%2C%22_orthography%22%3A%22tent%22%2C%22_conf%22%3A6772%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A43800%2C%22_orthography%22%3A%22poached%22%2C%22_conf%22%3A6181%2C%22_endTimeMs%22%3A4060%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342668%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6474%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34225%2C%22_orthography%22%3A%22tend%22%2C%22_conf%22%3A6964%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A41696%2C%22_orthography%22%3A%22perch%22%2C%22_conf%22%3A5950%2C%22_endTimeMs%22%3A4020%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342670%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6474%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34379%2C%22_orthography%22%3A%22tinge%22%2C%22_conf%22%3A6705%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A43800%2C%22_orthography%22%3A%22poached%22%2C%22_conf%22%3A6181%2C%22_endTimeMs%22%3A4060%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342783%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6426%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34340%2C%22_orthography%22%3A%22tent%22%2C%22_conf%22%3A6772%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A41696%2C%22_orthography%22%3A%22perch%22%2C%22_conf%22%3A5950%2C%22_endTimeMs%22%3A4020%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342822%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6402%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34379%2C%22_orthography%22%3A%22tinge%22%2C%22_conf%22%3A6705%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A41696%2C%22_orthography%22%3A%22perch%22%2C%22_conf%22%3A5950%2C%22_endTimeMs%22%3A4020%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%5D%2C%22_resultType%22%3A%22NBest%22%7D&lang=en&focus=51.4243877,-0.3474524&format=json&key=YOUR_API_KEY
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"suggestions": [
{
"country": "ie",
"distance": 598,
"words": "tinges.artichokes.perch",
"rank": 1,
"geometry": {
"lng": -8.621144,
"lat": 53.283595
},
"place": "Athenry, Connaught"
},
{
"country": "ch",
"distance": 924,
"words": "tent.artichoke.perch",
"rank": 2,
"geometry": {
"lng": 9.739427,
"lat": 46.400132
},
"place": "Silvaplana, Grisons"
},
{
"country": "se",
"distance": 1183,
"words": "tending.artichokes.perch",
"rank": 3,
"geometry": {
"lng": 15.379507,
"lat": 56.805695
},
"place": "Lessebo, Kronoberg"
}
],
"status": {
"status": 200,
"reason": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
```
**GeoJSON**
```json
{
"features": [
{
"geometry": {
"coordinates": [
-8.621144,
53.283595
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "ie",
"distance": 598,
"words": "tinges.artichokes.perch",
"rank": 1,
"place": "Athenry, Connaught"
}
},
{
"geometry": {
"coordinates": [
9.739427,
46.400132
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "ch",
"distance": 924,
"words": "tent.artichoke.perch",
"rank": 2,
"place": "Silvaplana, Grisons"
}
},
{
"geometry": {
"coordinates": [
15.379507,
56.805695
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "se",
"distance": 1183,
"words": "tending.artichokes.perch",
"rank": 3,
"place": "Lessebo, Kronoberg"
}
}
],
"type": "FeatureCollection",
"properties": {
"status": {
"status": 200,
"reason": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
}
```
**XML**
```xml
1
tinges.artichokes.perch
ie
Athenry, Connaught
53.283595
-8.621144
598
2
tent.artichoke.perch
ch
Silvaplana, Grisons
46.400132
9.739427
924
3
tending.artichokes.perch
se
Lessebo, Kronoberg
56.805695
15.379507
1183
200
OK
Thanks from all of us at index.home.raft for using a what3words API
```
## StandardBlend
Returns a blend of the three most relevant 3 word address candidates for a given location, based on a full or partial 3 word address.
`GET https://api.what3words.com/v2/standardblend`
The specified 3 word address may either be a full 3 word address or a partial 3 word address containing the first 2 words in full and at least 1 character of the 3rd word. StandardBlend provides the search logic that powers the search box on map.what3words.com and in the what3words mobile apps.
### Language
StandardBlend will search in all languages. However, you can additionally specify a fallback language, to help the API in situations where the input is particularly messy. The `lang` parameter is optional, and StandardBlend will work well even without a `lang` parameter.
### Results
A maximum of 100 AutoSuggest results may be returned, but you may choose to display fewer results to your user e.g. the first 3 or 5 (depending on your user interface). By default, 3 results will be returned. It is possible we may increase the number of results returned in the future, so if you choose to limit the list of results returned, we recommend that you choose to include e.g. the top 3/5/7 results rather than choose to exclude the bottom e.g. 18/19/20 results.
### Parameters
| Parameter | Required | Description | Example |
| --- | --- | --- | --- |
| `addr` | required | The full or partial 3 word address to obtain blended candidates for. At minimum this must be the first two complete words plus at least one character from the third word | `addr=plan.clips.a` |
| `key` | required | A valid API key; if not supplied as a parameter, a key must be supplied as a request header | `key=YOUR_API_KEY` |
| `lang` | optional | Specifies a fallback language, which will help guide StandardBlend if the input is particularly messy. If specified, this parameter must be a supported 3 word address language as an ISO 639-1 2 letter code | `lang=fr` |
| `focus` | optional | A location, specified as a latitude,longitude used to refine the results. If specified, the results will be weighted to give preference to those near the specified location. | `focus=51.521251,-0.203586` |
| `format` | optional | Return data format type; can be one of `json` (the default), `geojson` or `xml` | `format=json` |
| `callback` | optional | Specifies that the response should be JSONP wrapped as a function; supplying a `callback` parameter is only supported for JSON and GeoJSON format responses. See JSONP Responses for more information. | `callback=jsonp` |
### Visualising StandardBlend
The what3words map site uses the `standardblend` method to display candidate 3 word addresses. If the contents of the search box matches a partial 3 word address, detected by a regular expression, then `standardblend` will be invoked and any resulting candidate 3 word addresses displayed. The map site also displays a relevant flag, keyed on the ISO 3166-1 alpha-2 country code that is returned by the API. For the map site, we are using a flag set licensed from IconDrawer with the addition of two additional flags for tn and xk.
### Example requests
#### StandardBlend
This example returns StandardBlend results for the partial 3 word address `plan.clips.a`; the results are ranked for proximity relevance to the `focus` point 51.4243877,-0.3474524.
**URL**
```
https://api.what3words.com/v2/standardblend?addr=plan.clips.above&lang=en&focus=51.4243877,-0.3474524&format=json&key=YOUR_API_KEY
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"blends": [
{
"distance": 1,
"rank": 1,
"words": "plan.clips.above",
"language": "en",
"place": "Teddington, London",
"geometry": {
"lng": -0.348023,
"lat": 51.432393
},
"country": "gb"
},
{
"distance": 6405,
"rank": 2,
"words": "plans.clips.above",
"language": "en",
"place": "Warren Park, Indiana",
"geometry": {
"lng": -86.101238,
"lat": 39.785077
},
"country": "us"
},
{
"distance": 8822,
"rank": 3,
"words": "plan.clip.above",
"language": "en",
"place": "Coronado, California",
"geometry": {
"lng": -117.272099,
"lat": 32.716944
},
"country": "us"
}
],
"status": {
"status": 200,
"reason": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
```
**GeoJSON**
```json
{
"features": [
{
"properties": {
"distance": 1,
"rank": 1,
"words": "plan.clips.above",
"language": "en",
"place": "Teddington, London",
"country": "gb"
},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-0.348023,
51.432393
]
}
},
{
"properties": {
"distance": 6405,
"rank": 2,
"words": "plans.clips.above",
"language": "en",
"place": "Warren Park, Indiana",
"country": "us"
},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-86.101238,
39.785077
]
}
},
{
"properties": {
"distance": 8822,
"rank": 3,
"words": "plan.clip.above",
"language": "en",
"place": "Coronado, California",
"country": "us"
},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-117.272099,
32.716944
]
}
}
],
"type": "FeatureCollection",
"properties": {
"status": {
"status": 200,
"reason": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
}
```
**XML**
```xml
1
plan.clips.above
en
Teddington, London
1
51.432393
-0.348023
2
plans.clips.above
en
Warren Park, Indiana
6405
39.785077
-86.101238
3
plan.clip.above
en
Coronado, California
8822
32.716944
-117.272099
200
OK
Thanks from all of us at index.home.raft for using a what3words API
```
## Voice StandardBlend
Returns a blend of the three most relevant 3 word address candidates for a given location, based on an input string of URL encoded Cerence Vocon Hybrid JSON. Please note that this resource does not provide speech recognition capabilities and that a separate licensing agreement is required with Cerence to use the VoCon Hybrid SDK.
`GET https://api.what3words.com/v2/voice-standardblend`
### Parameters
| Parameter | Required | Description | Example |
| --- | --- | --- | --- |
| `json` | required | Cerence VoCon Hybrid JSON, which must be URL encoded. | `json=[URL encoded JSON string]` |
| `key` | required | A valid API key; if not supplied as a parameter, a key must be supplied as a request header | `key=YOUR_API_KEY` |
| `lang` | required | A supported 3 word address language as an ISO 639-1 2 letter code | `lang=fr` |
| `focus` | optional | A location, specified as a latitude,longitude used to refine the results. If specified, the results will be weighted to give preference to those near the specified location in addition to considering similarity to the voice input. If omitted the default behaviour is to weight results for similarity to the voice input only. | `focus=51.521251,-0.203586` |
| `format` | optional | Return data format type; can be one of `json` (the default), `geojson` or `xml` | `format=json` |
| `callback` | optional | Specifies that the response should be JSONP wrapped as a function; supplying a `callback` parameter is only supported for JSON and GeoJSON format responses. See JSONP Responses for more information. | `callback=jsonp` |
### Example requests
#### Single language StandardBlend
This example returns StandardBlend results for the supplied Cerence VoCon Hybrid JSON; the results are ranked for proximity relevance to the `focus` point 51.4243877,-0.3474524 not clipped.
**URL**
```
https://api.what3words.com/v2/voice-standardblend?json=%7B%22_isInGrammar%22%3A%22yes%22%2C%22_isSpeech%22%3A%22yes%22%2C%22_hypotheses%22%3A%5B%7B%22_score%22%3A342516%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6546%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34225%2C%22_orthography%22%3A%22tend%22%2C%22_conf%22%3A6964%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A43800%2C%22_orthography%22%3A%22poached%22%2C%22_conf%22%3A6181%2C%22_endTimeMs%22%3A4060%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342631%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6498%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34340%2C%22_orthography%22%3A%22tent%22%2C%22_conf%22%3A6772%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A43800%2C%22_orthography%22%3A%22poached%22%2C%22_conf%22%3A6181%2C%22_endTimeMs%22%3A4060%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342668%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6474%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34225%2C%22_orthography%22%3A%22tend%22%2C%22_conf%22%3A6964%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A41696%2C%22_orthography%22%3A%22perch%22%2C%22_conf%22%3A5950%2C%22_endTimeMs%22%3A4020%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342670%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6474%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34379%2C%22_orthography%22%3A%22tinge%22%2C%22_conf%22%3A6705%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A43800%2C%22_orthography%22%3A%22poached%22%2C%22_conf%22%3A6181%2C%22_endTimeMs%22%3A4060%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342783%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6426%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34340%2C%22_orthography%22%3A%22tent%22%2C%22_conf%22%3A6772%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A41696%2C%22_orthography%22%3A%22perch%22%2C%22_conf%22%3A5950%2C%22_endTimeMs%22%3A4020%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%2C%7B%22_score%22%3A342822%2C%22_startRule%22%3A%22whatthreewordsgrammar%23_main_%22%2C%22_conf%22%3A6402%2C%22_endTimeMs%22%3A6360%2C%22_beginTimeMs%22%3A1570%2C%22_lmScore%22%3A300%2C%22_items%22%3A%5B%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A34379%2C%22_orthography%22%3A%22tinge%22%2C%22_conf%22%3A6705%2C%22_endTimeMs%22%3A2250%2C%22_beginTimeMs%22%3A1580%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A47670%2C%22_orthography%22%3A%22artichokes%22%2C%22_conf%22%3A7176%2C%22_endTimeMs%22%3A3180%2C%22_beginTimeMs%22%3A2260%7D%2C%7B%22_type%22%3A%22terminal%22%2C%22_score%22%3A41696%2C%22_orthography%22%3A%22perch%22%2C%22_conf%22%3A5950%2C%22_endTimeMs%22%3A4020%2C%22_beginTimeMs%22%3A3220%7D%5D%7D%5D%2C%22_resultType%22%3A%22NBest%22%7D&lang=en&focus=51.4243877,-0.3474524&format=json&key=YOUR_API_KEY
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"blends": [{
"country": "ie",
"distance": 598,
"words": "tinges.artichokes.perch",
"rank": 1,
"language": "en",
"geometry": {
"lng": -8.621144,
"lat": 53.283595
},
"place": "Athenry, Connaught"
},
{
"country": "ca",
"distance": 5378,
"words": "tend.artichokes.perch",
"rank": 2,
"language": "en",
"geometry": {
"lng": -78.736977,
"lat": 47.928107
},
"place": "Rouyn-Noranda, Quebec"
},
{
"country": "ca",
"distance": 6142,
"words": "tent.artichokes.perch",
"rank": 3,
"language": "en",
"geometry": {
"lng": -124.344359,
"lat": 65.803269
},
"place": "Norman Wells, Northwest Territories"
}
],
"status": {
"status": 200,
"reason": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
```
**GeoJSON**
```json
{
"features": [{
"geometry": {
"coordinates": [-8.621144,
53.283595
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "ie",
"distance": 598,
"words": "tinges.artichokes.perch",
"rank": 1,
"language": "en",
"place": "Athenry, Connaught"
}
},
{
"geometry": {
"coordinates": [-78.736977,
47.928107
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "ca",
"distance": 5378,
"words": "tend.artichokes.perch",
"rank": 2,
"language": "en",
"place": "Rouyn-Noranda, Quebec"
}
},
{
"geometry": {
"coordinates": [-124.344359,
65.803269
],
"type": "Point"
},
"type": "Feature",
"properties": {
"country": "ca",
"distance": 6142,
"words": "tent.artichokes.perch",
"rank": 3,
"language": "en",
"place": "Norman Wells, Northwest Territories"
}
}
],
"type": "FeatureCollection",
"properties": {
"status": {
"status": 200,
"reason": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
}
```
**XML**
```xml
1
tinges.artichokes.perch
ie
en
Athenry, Connaught
598
53.283595
-8.621144
2
tend.artichokes.perch
ca
en
Rouyn-Noranda, Quebec
5378
47.928107
-78.736977
3
tent.artichokes.perch
ca
en
Norman Wells, Northwest Territories
6142
65.803269
-124.344359
200
OK
Thanks from all of us at index.home.raft for using a what3words API
```
## Grid section
Returns a section of the 3m x 3m what3words grid for a given area.
`GET https://api.what3words.com/v2/grid`
### Parameters
| Parameter | Required | Description | Example |
| --- | --- | --- | --- |
| `key` | required | A valid API key; if not supplied as a parameter, a key must be supplied as a request header | `key=YOUR_API_KEY` |
| `bbox` | required | Bounding box, specified by the northeast and southwest corner coordinates, for which the grid should be returned. | `bbox=52.207988,0.116126,52.208867,0.117540` |
| `format` | optional | Return data format type; can be either `json` (the default) or `geojson` | `format=geojson` |
| `callback` | optional | Specifies that the response should be JSONP wrapped as a function; supplying a `callback` parameter is only supported for JSON and GeoJSON format responses. See JSONP Responses for more information. | `callback=jsonp` |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v2/grid?bbox=52.208867%2C0.117540%2C52.207988%2C0.116126&key=YOUR_API_KEY&format=json'
```
**URL**
```
https://api.what3words.com/v2/grid?bbox=52.208867,0.117540,52.207988,0.116126&format=json&key=YOUR_API_KEY
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"lines": [
{
"start": {
"lng": 0.11612600000001,
"lat": 52.208009918068
},
"end": {
"lng": 0.11753999999999,
"lat": 52.208009918068
}
},
{
"start": {
"lng": 0.11612600000001,
"lat": 52.20803686934
},
"end": {
"lng": 0.11753999999999,
"lat": 52.20803686934
}
}
],
"status": {
"status": 200,
"reason": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
```
**GeoJSON**
```json
{
"type": "MultiLineString",
"coordinates": [
[
[
0.11612600000001,
52.208009918068
],
[
0.11753999999999,
52.208009918068
]
],
[
[
0.11612600000001,
52.20803686934
],
[
0.11753999999999,
52.20803686934
]
]
],
"properties": {
"status": {
"status": 200,
"reason": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
}
```
**XML**
```xml
52.208009918068136
0.11612600000000839
52.208009918068136
0.1175399999999911
52.20803686934023
0.11612600000000839
52.20803686934023
0.1175399999999911
200
OK
Thanks from all of us at index.home.raft for using a what3words API
```
## Get languages
Retrieves a list of the currently loaded and available 3 word address languages.
`GET https://api.what3words.com/v2/languages`
### Parameters
| Parameter | Required | Description | Example |
| --- | --- | --- | --- |
| `key` | required | A valid API key; if not supplied as a parameter, a key must be supplied as a request header | `key=YOUR_API_KEY` |
| `callback` | optional | Specifies that the response should be JSONP wrapped as a function; supplying a `callback` parameter is only supported for JSON and GeoJSON format responses. See JSONP Responses for more information. | `callback=jsonp` |
### Example request
**cURL**
```shellscript
curl --request GET \
--url 'https://api.what3words.com/v2/languages?key=YOUR_API_KEY'
```
**URL**
```
https://api.what3words.com/v2/languages?format=json&key=YOUR_API_KEY
```
### Example result
Status: `200 OK`
**JSON**
```json
{
"languages": [
{
"code": "de",
"name": "German",
"native_name": "Deutsch"
},
{
"code": "mn",
"name": "Mongolian",
"native_name": "Mонгол"
},
{
"code": "fi",
"name": "Finnish",
"native_name": "Suomi"
},
{
"code": "ru",
"name": "Russian",
"native_name": "Русский"
},
{
"code": "sv",
"name": "Swedish",
"native_name": "Svenska"
},
{
"code": "pt",
"name": "Portuguese",
"native_name": "Português"
},
{
"code": "sw",
"name": "Swahili",
"native_name": "Kiswahili"
},
{
"code": "en",
"name": "English",
"native_name": "English"
},
{
"code": "it",
"name": "Italian",
"native_name": "Italiano"
},
{
"code": "fr",
"name": "French",
"native_name": "Français"
},
{
"code": "es",
"name": "Spanish",
"native_name": "Español"
},
{
"code": "ar",
"name": "Arabic",
"native_name": "العربية"
},
{
"code": "pl",
"name": "Polish",
"native_name": "Polski"
},
{
"code": "tr",
"name": "Turkish",
"native_name": "Türkçe"
}
],
"status": {
"status": 200,
"reason": "OK"
},
"thanks": "Thanks from all of us at index.home.raft for using a what3words API"
}
```
**XML**
```xml
de
German
Deutsch
mn
Mongolian
Mонгол
fi
Finnish
Suomi
ru
Russian
Русский
sv
Swedish
Svenska
pt
Portuguese
Português
sw
Swahili
Kiswahili
en
English
English
it
Italian
Italiano
fr
French
Français
es
Spanish
Español
ar
Arabic
العربية
pl
Polish
Polski
tr
Turkish
Türkçe
200
OK
Thanks from all of us at index.home.raft for using a what3words API
```