> This page is for Analytics API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://documentation.babelstreet.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://documentation.babelstreet.com/_mcp/server.

# Match addresses from input

POST https://analytics.babelstreet.com/rest/v1/address-similarity
Content-Type: application/json

Returns the confidence score of matching 2 addresses. You can specify the fields of the addresses to be matched or provide the address as a string.

Reference: https://documentation.babelstreet.com/analytics/match-names/address-similarity/match-addresses-from-input

## Authentication

- `X-BabelStreetAPI-Key` header (required) — API Key authentication via header
- `X-RosetteAPI-Key` header (required) — API Key authentication via header

## Servers

- `https://analytics.babelstreet.com/rest/v1` (https://analytics.babelstreet.com/rest/v1/, default)
- `https://api.rosette.com/rest/v1` (https://api.rosette.com/rest/v1/)

## Request

### Body (application/json)

This endpoint expects an AddressSimilarityRequest.

- `address1` (Address, optional)
- `address2` (Address, optional)

## Response

### 200

OK

- `score` (double, optional) — Similarity score of two addresses

## Types

### Address

- AddressFielded: AddressFielded
- AddressString: string

### AddressFielded

- `city` (string, optional) — the city, town, village, etc.
- `cityDistrict` (string, optional) — a borough or district within a city,
- `country` (string, optional) — a sovereign nation or its dependent territory,
- `countryRegion` (string, optional) — informal subdivision of a country,
- `entrance` (string, optional) — numbered/lettered entrance,
- `house` (string, optional) — venue or building name,
- `houseNumber` (string, optional) — external building number,
- `island` (string, optional) — a named island,
- `level` (string, optional) — expression indicating a floor number,
- `poBox` (string, optional) — post office box,
- `postCode` (string, optional) — postal code,
- `road` (string, optional) — street name,
- `staircase` (string, optional) — numbered/lettered staircase,
- `state` (string, optional) — a first-level administrative division,
- `stateDistrict` (string, optional) — a second-level administrative division or county,
- `suburb` (string, optional) — unofficial neighborhood name,
- `unit` (string, optional) — a secondary unit designator,
- `worldRegion` (string, optional) — West Indies, if appropriate,

## Examples

**Request**

```json
{
  "address1": {
    "city": "Washington",
    "houseNumber": "1600",
    "postCode": "20500",
    "road": "Pennsylvania Ave. NW",
    "state": "D.C."
  },
  "address2": "160 Pennsilvana Avenue, Washington, D.C., 20500"
}
```

**Response**

```json
{
  "score": 1.1
}
```

**SDK Code**

```python JSON String
import requests

url = "https://analytics.babelstreet.com/rest/v1/address-similarity"

payload = {
    "address1": {
        "city": "Washington",
        "houseNumber": "1600",
        "postCode": "20500",
        "road": "Pennsylvania Ave. NW",
        "state": "D.C."
    },
    "address2": "160 Pennsilvana Avenue, Washington, D.C., 20500"
}
headers = {
    "X-BabelStreetAPI-Key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript JSON String
const url = 'https://analytics.babelstreet.com/rest/v1/address-similarity';
const options = {
  method: 'POST',
  headers: {'X-BabelStreetAPI-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"address1":{"city":"Washington","houseNumber":"1600","postCode":"20500","road":"Pennsylvania Ave. NW","state":"D.C."},"address2":"160 Pennsilvana Avenue, Washington, D.C., 20500"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go JSON String
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://analytics.babelstreet.com/rest/v1/address-similarity"

	payload := strings.NewReader("{\n  \"address1\": {\n    \"city\": \"Washington\",\n    \"houseNumber\": \"1600\",\n    \"postCode\": \"20500\",\n    \"road\": \"Pennsylvania Ave. NW\",\n    \"state\": \"D.C.\"\n  },\n  \"address2\": \"160 Pennsilvana Avenue, Washington, D.C., 20500\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-BabelStreetAPI-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby JSON String
require 'uri'
require 'net/http'

url = URI("https://analytics.babelstreet.com/rest/v1/address-similarity")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-BabelStreetAPI-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"address1\": {\n    \"city\": \"Washington\",\n    \"houseNumber\": \"1600\",\n    \"postCode\": \"20500\",\n    \"road\": \"Pennsylvania Ave. NW\",\n    \"state\": \"D.C.\"\n  },\n  \"address2\": \"160 Pennsilvana Avenue, Washington, D.C., 20500\"\n}"

response = http.request(request)
puts response.read_body
```

```java JSON String
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://analytics.babelstreet.com/rest/v1/address-similarity")
  .header("X-BabelStreetAPI-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"address1\": {\n    \"city\": \"Washington\",\n    \"houseNumber\": \"1600\",\n    \"postCode\": \"20500\",\n    \"road\": \"Pennsylvania Ave. NW\",\n    \"state\": \"D.C.\"\n  },\n  \"address2\": \"160 Pennsilvana Avenue, Washington, D.C., 20500\"\n}")
  .asString();
```

```php JSON String
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://analytics.babelstreet.com/rest/v1/address-similarity', [
  'body' => '{
  "address1": {
    "city": "Washington",
    "houseNumber": "1600",
    "postCode": "20500",
    "road": "Pennsylvania Ave. NW",
    "state": "D.C."
  },
  "address2": "160 Pennsilvana Avenue, Washington, D.C., 20500"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-BabelStreetAPI-Key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp JSON String
using RestSharp;

var client = new RestClient("https://analytics.babelstreet.com/rest/v1/address-similarity");
var request = new RestRequest(Method.POST);
request.AddHeader("X-BabelStreetAPI-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"address1\": {\n    \"city\": \"Washington\",\n    \"houseNumber\": \"1600\",\n    \"postCode\": \"20500\",\n    \"road\": \"Pennsylvania Ave. NW\",\n    \"state\": \"D.C.\"\n  },\n  \"address2\": \"160 Pennsilvana Avenue, Washington, D.C., 20500\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift JSON String
import Foundation

let headers = [
  "X-BabelStreetAPI-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "address1": [
    "city": "Washington",
    "houseNumber": "1600",
    "postCode": "20500",
    "road": "Pennsylvania Ave. NW",
    "state": "D.C."
  ],
  "address2": "160 Pennsilvana Avenue, Washington, D.C., 20500"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://analytics.babelstreet.com/rest/v1/address-similarity")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```