Validate an Address
Address validation ensures accurate addresses and can lead to reduced shipping costs by preventing address correction surcharges. ShipEngine cross references multiple databases to validate addresses and identify potential deliverability issues.
tip
Available Countries
ShipEngine supports address validation for virtually every country on Earth, including the United States, Canada, Great Britain, Australia, Germany, France, Norway, Spain, Sweden, Israel, Italy, and over 160 others.
Example
POST /v1/addresses/validate
This is a full request you can make to the address verification service. The JSON body can take up to 250 addresses to validate per request
POST /v1/addresses/validate HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
[
{
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "US"
}
]
curl -iX POST https://api.shipengine.com/v1/addresses/validate \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Content-Type: application/json' \
-d '[
{
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "US"
}
]'$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Host", "api.shipengine.com")
$headers.Add("API-Key", "__YOUR_API_KEY_HERE__")
$headers.Add("Content-Type", "application/json")
$body = "[`n {`n `"address_line1`": `"525 S Winchester Blvd`",`n `"city_locality`": `"San Jose`",`n `"state_province`": `"CA`",`n `"postal_code`": `"95128`",`n `"country_code`": `"US`"`n }`n]"
$response = Invoke-RestMethod 'https://api.shipengine.com/v1/addresses/validate' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Jsonvar myHeaders = new Headers();
myHeaders.append("Host", "api.shipengine.com");
myHeaders.append("API-Key", "__YOUR_API_KEY_HERE__");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify([{"address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"US"}]);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v1/addresses/validate", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.shipengine.com/v1/addresses/validate',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
},
body: JSON.stringify([{"address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"US"}])
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.shipengine.com/v1/addresses/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]",
CURLOPT_HTTPHEADER => array(
"Host: api.shipengine.com",
"API-Key: __YOUR_API_KEY_HERE__",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://api.shipengine.com/v1/addresses/validate"
payload = "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]"
headers = {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://api.shipengine.com/v1/addresses/validate")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Host"] = "api.shipengine.com"
request["API-Key"] = "__YOUR_API_KEY_HERE__"
request["Content-Type"] = "application/json"
request.body = "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v1/addresses/validate");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Host", "api.shipengine.com");
request.AddHeader("API-Key", "__YOUR_API_KEY_HERE__");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]");
Request request = new Request.Builder()
.url("https://api.shipengine.com/v1/addresses/validate")
.method("POST", body)
.addHeader("Host", "api.shipengine.com")
.addHeader("API-Key", "__YOUR_API_KEY_HERE__")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.shipengine.com/v1/addresses/validate"
method := "POST"
payload := strings.NewReader("[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]")
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
}
req.Header.Add("Host", "api.shipengine.com")
req.Header.Add("API-Key", "__YOUR_API_KEY_HERE__")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.shipengine.com/v1/addresses/validate"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Host": @"api.shipengine.com",
@"API-Key": @"__YOUR_API_KEY_HERE__",
@"Content-Type": @"application/json"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);import Foundation
var semaphore = DispatchSemaphore (value: 0)
let parameters = "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v1/addresses/validate")!,timeoutInterval: Double.infinity)
request.addValue("api.shipengine.com", forHTTPHeaderField: "Host")
request.addValue("__YOUR_API_KEY_HERE__", forHTTPHeaderField: "API-Key")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
The Address Validation Response is provided for every address sent to the Address Validator, in the order it was received.
[
{
"status": "verified",
"original_address": {
"name": null,
"phone": null,
"company_name": null,
"address_line1": "525 S Winchester Blvd",
"address_line2": null,
"address_line3": null,
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "US",
"address_residential_indicator": "unknown"
},
"matched_address": {
"name": null,
"phone": null,
"company_name": null,
"address_line1": "525 S WINCHESTER BLVD",
"address_line2": "",
"address_line3": null,
"city_locality": "SAN JOSE",
"state_province": "CA",
"postal_code": "95128-2537",
"country_code": "US",
"address_residential_indicator": "no"
},
"messages": []
}
]
Address Status Meanings
| status | description |
|---|---|
verified |
Address was successfully verified. |
unverified |
Address validation was not validated against the database because pre-validation failed. |
warning |
The address was validated, but the address should be double checked. |
error |
The address could not be validated with any degree of certainty against the database. |
Samples
Verified Status
POST /v1/addresses/validate HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
[
{
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "US"
}
]
curl -iX POST https://api.shipengine.com/v1/addresses/validate \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Content-Type: application/json' \
-d '[
{
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "US"
}
]'$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Host", "api.shipengine.com")
$headers.Add("API-Key", "__YOUR_API_KEY_HERE__")
$headers.Add("Content-Type", "application/json")
$body = "[`n {`n `"address_line1`": `"525 S Winchester Blvd`",`n `"city_locality`": `"San Jose`",`n `"state_province`": `"CA`",`n `"postal_code`": `"95128`",`n `"country_code`": `"US`"`n }`n]"
$response = Invoke-RestMethod 'https://api.shipengine.com/v1/addresses/validate' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Jsonvar myHeaders = new Headers();
myHeaders.append("Host", "api.shipengine.com");
myHeaders.append("API-Key", "__YOUR_API_KEY_HERE__");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify([{"address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"US"}]);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v1/addresses/validate", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.shipengine.com/v1/addresses/validate',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
},
body: JSON.stringify([{"address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"US"}])
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.shipengine.com/v1/addresses/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]",
CURLOPT_HTTPHEADER => array(
"Host: api.shipengine.com",
"API-Key: __YOUR_API_KEY_HERE__",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://api.shipengine.com/v1/addresses/validate"
payload = "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]"
headers = {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://api.shipengine.com/v1/addresses/validate")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Host"] = "api.shipengine.com"
request["API-Key"] = "__YOUR_API_KEY_HERE__"
request["Content-Type"] = "application/json"
request.body = "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v1/addresses/validate");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Host", "api.shipengine.com");
request.AddHeader("API-Key", "__YOUR_API_KEY_HERE__");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]");
Request request = new Request.Builder()
.url("https://api.shipengine.com/v1/addresses/validate")
.method("POST", body)
.addHeader("Host", "api.shipengine.com")
.addHeader("API-Key", "__YOUR_API_KEY_HERE__")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.shipengine.com/v1/addresses/validate"
method := "POST"
payload := strings.NewReader("[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]")
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
}
req.Header.Add("Host", "api.shipengine.com")
req.Header.Add("API-Key", "__YOUR_API_KEY_HERE__")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.shipengine.com/v1/addresses/validate"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Host": @"api.shipengine.com",
@"API-Key": @"__YOUR_API_KEY_HERE__",
@"Content-Type": @"application/json"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);import Foundation
var semaphore = DispatchSemaphore (value: 0)
let parameters = "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"US\"\n }\n]"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v1/addresses/validate")!,timeoutInterval: Double.infinity)
request.addValue("api.shipengine.com", forHTTPHeaderField: "Host")
request.addValue("__YOUR_API_KEY_HERE__", forHTTPHeaderField: "API-Key")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
Unverified Status
POST /v1/addresses/validate HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
[
{
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "USA"
}
]
curl -iX POST https://api.shipengine.com/v1/addresses/validate \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Content-Type: application/json' \
-d '[
{
"address_line1": "525 S Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"country_code": "USA"
}
]'$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Host", "api.shipengine.com")
$headers.Add("API-Key", "__YOUR_API_KEY_HERE__")
$headers.Add("Content-Type", "application/json")
$body = "[`n {`n `"address_line1`": `"525 S Winchester Blvd`",`n `"city_locality`": `"San Jose`",`n `"state_province`": `"CA`",`n `"postal_code`": `"95128`",`n `"country_code`": `"USA`"`n }`n]"
$response = Invoke-RestMethod 'https://api.shipengine.com/v1/addresses/validate' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Jsonvar myHeaders = new Headers();
myHeaders.append("Host", "api.shipengine.com");
myHeaders.append("API-Key", "__YOUR_API_KEY_HERE__");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify([{"address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"USA"}]);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v1/addresses/validate", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.shipengine.com/v1/addresses/validate',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
},
body: JSON.stringify([{"address_line1":"525 S Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"95128","country_code":"USA"}])
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.shipengine.com/v1/addresses/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"USA\"\n }\n]",
CURLOPT_HTTPHEADER => array(
"Host: api.shipengine.com",
"API-Key: __YOUR_API_KEY_HERE__",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://api.shipengine.com/v1/addresses/validate"
payload = "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"USA\"\n }\n]"
headers = {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://api.shipengine.com/v1/addresses/validate")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Host"] = "api.shipengine.com"
request["API-Key"] = "__YOUR_API_KEY_HERE__"
request["Content-Type"] = "application/json"
request.body = "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"USA\"\n }\n]"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v1/addresses/validate");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Host", "api.shipengine.com");
request.AddHeader("API-Key", "__YOUR_API_KEY_HERE__");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"USA\"\n }\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"USA\"\n }\n]");
Request request = new Request.Builder()
.url("https://api.shipengine.com/v1/addresses/validate")
.method("POST", body)
.addHeader("Host", "api.shipengine.com")
.addHeader("API-Key", "__YOUR_API_KEY_HERE__")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.shipengine.com/v1/addresses/validate"
method := "POST"
payload := strings.NewReader("[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"USA\"\n }\n]")
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
}
req.Header.Add("Host", "api.shipengine.com")
req.Header.Add("API-Key", "__YOUR_API_KEY_HERE__")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.shipengine.com/v1/addresses/validate"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Host": @"api.shipengine.com",
@"API-Key": @"__YOUR_API_KEY_HERE__",
@"Content-Type": @"application/json"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"USA\"\n }\n]" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);import Foundation
var semaphore = DispatchSemaphore (value: 0)
let parameters = "[\n {\n \"address_line1\": \"525 S Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"95128\",\n \"country_code\": \"USA\"\n }\n]"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v1/addresses/validate")!,timeoutInterval: Double.infinity)
request.addValue("api.shipengine.com", forHTTPHeaderField: "Host")
request.addValue("__YOUR_API_KEY_HERE__", forHTTPHeaderField: "API-Key")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
Warning Status
POST /v1/addresses/validate HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
[
{
"address_line1": "Studio Tour Drive, Leavesden WD25 7LR, UK",
"country_code": "GB"
}
]
curl -iX POST https://api.shipengine.com/v1/addresses/validate \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Content-Type: application/json' \
-d '[
{
"address_line1": "Studio Tour Drive, Leavesden WD25 7LR, UK",
"country_code": "GB"
}
]'$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Host", "api.shipengine.com")
$headers.Add("API-Key", "__YOUR_API_KEY_HERE__")
$headers.Add("Content-Type", "application/json")
$body = "[`n {`n `"address_line1`": `"Studio Tour Drive, Leavesden WD25 7LR, UK`",`n `"country_code`": `"GB`"`n }`n]"
$response = Invoke-RestMethod 'https://api.shipengine.com/v1/addresses/validate' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Jsonvar myHeaders = new Headers();
myHeaders.append("Host", "api.shipengine.com");
myHeaders.append("API-Key", "__YOUR_API_KEY_HERE__");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify([{"address_line1":"Studio Tour Drive, Leavesden WD25 7LR, UK","country_code":"GB"}]);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v1/addresses/validate", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.shipengine.com/v1/addresses/validate',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
},
body: JSON.stringify([{"address_line1":"Studio Tour Drive, Leavesden WD25 7LR, UK","country_code":"GB"}])
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.shipengine.com/v1/addresses/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"[\n {\n \"address_line1\": \"Studio Tour Drive, Leavesden WD25 7LR, UK\",\n \"country_code\": \"GB\"\n }\n]",
CURLOPT_HTTPHEADER => array(
"Host: api.shipengine.com",
"API-Key: __YOUR_API_KEY_HERE__",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://api.shipengine.com/v1/addresses/validate"
payload = "[\n {\n \"address_line1\": \"Studio Tour Drive, Leavesden WD25 7LR, UK\",\n \"country_code\": \"GB\"\n }\n]"
headers = {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://api.shipengine.com/v1/addresses/validate")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Host"] = "api.shipengine.com"
request["API-Key"] = "__YOUR_API_KEY_HERE__"
request["Content-Type"] = "application/json"
request.body = "[\n {\n \"address_line1\": \"Studio Tour Drive, Leavesden WD25 7LR, UK\",\n \"country_code\": \"GB\"\n }\n]"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v1/addresses/validate");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Host", "api.shipengine.com");
request.AddHeader("API-Key", "__YOUR_API_KEY_HERE__");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "[\n {\n \"address_line1\": \"Studio Tour Drive, Leavesden WD25 7LR, UK\",\n \"country_code\": \"GB\"\n }\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"address_line1\": \"Studio Tour Drive, Leavesden WD25 7LR, UK\",\n \"country_code\": \"GB\"\n }\n]");
Request request = new Request.Builder()
.url("https://api.shipengine.com/v1/addresses/validate")
.method("POST", body)
.addHeader("Host", "api.shipengine.com")
.addHeader("API-Key", "__YOUR_API_KEY_HERE__")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.shipengine.com/v1/addresses/validate"
method := "POST"
payload := strings.NewReader("[\n {\n \"address_line1\": \"Studio Tour Drive, Leavesden WD25 7LR, UK\",\n \"country_code\": \"GB\"\n }\n]")
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
}
req.Header.Add("Host", "api.shipengine.com")
req.Header.Add("API-Key", "__YOUR_API_KEY_HERE__")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.shipengine.com/v1/addresses/validate"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Host": @"api.shipengine.com",
@"API-Key": @"__YOUR_API_KEY_HERE__",
@"Content-Type": @"application/json"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"[\n {\n \"address_line1\": \"Studio Tour Drive, Leavesden WD25 7LR, UK\",\n \"country_code\": \"GB\"\n }\n]" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);import Foundation
var semaphore = DispatchSemaphore (value: 0)
let parameters = "[\n {\n \"address_line1\": \"Studio Tour Drive, Leavesden WD25 7LR, UK\",\n \"country_code\": \"GB\"\n }\n]"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v1/addresses/validate")!,timeoutInterval: Double.infinity)
request.addValue("api.shipengine.com", forHTTPHeaderField: "Host")
request.addValue("__YOUR_API_KEY_HERE__", forHTTPHeaderField: "API-Key")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()
Error Status
POST /v1/addresses/validate HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
[
{
"address_line1": "Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "78756",
"country_code": "US"
}
]
curl -iX POST https://api.shipengine.com/v1/addresses/validate \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Content-Type: application/json' \
-d '[
{
"address_line1": "Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "78756",
"country_code": "US"
}
]'$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Host", "api.shipengine.com")
$headers.Add("API-Key", "__YOUR_API_KEY_HERE__")
$headers.Add("Content-Type", "application/json")
$body = "[`n {`n `"address_line1`": `"Winchester Blvd`",`n `"city_locality`": `"San Jose`",`n `"state_province`": `"CA`",`n `"postal_code`": `"78756`",`n `"country_code`": `"US`"`n }`n]"
$response = Invoke-RestMethod 'https://api.shipengine.com/v1/addresses/validate' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Jsonvar myHeaders = new Headers();
myHeaders.append("Host", "api.shipengine.com");
myHeaders.append("API-Key", "__YOUR_API_KEY_HERE__");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify([{"address_line1":"Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"78756","country_code":"US"}]);
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v1/addresses/validate", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.shipengine.com/v1/addresses/validate',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
},
body: JSON.stringify([{"address_line1":"Winchester Blvd","city_locality":"San Jose","state_province":"CA","postal_code":"78756","country_code":"US"}])
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.shipengine.com/v1/addresses/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS =>"[\n {\n \"address_line1\": \"Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\"\n }\n]",
CURLOPT_HTTPHEADER => array(
"Host: api.shipengine.com",
"API-Key: __YOUR_API_KEY_HERE__",
"Content-Type: application/json"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://api.shipengine.com/v1/addresses/validate"
payload = "[\n {\n \"address_line1\": \"Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\"\n }\n]"
headers = {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://api.shipengine.com/v1/addresses/validate")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Host"] = "api.shipengine.com"
request["API-Key"] = "__YOUR_API_KEY_HERE__"
request["Content-Type"] = "application/json"
request.body = "[\n {\n \"address_line1\": \"Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\"\n }\n]"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v1/addresses/validate");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Host", "api.shipengine.com");
request.AddHeader("API-Key", "__YOUR_API_KEY_HERE__");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "[\n {\n \"address_line1\": \"Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\"\n }\n]", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "[\n {\n \"address_line1\": \"Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\"\n }\n]");
Request request = new Request.Builder()
.url("https://api.shipengine.com/v1/addresses/validate")
.method("POST", body)
.addHeader("Host", "api.shipengine.com")
.addHeader("API-Key", "__YOUR_API_KEY_HERE__")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.shipengine.com/v1/addresses/validate"
method := "POST"
payload := strings.NewReader("[\n {\n \"address_line1\": \"Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\"\n }\n]")
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
}
req.Header.Add("Host", "api.shipengine.com")
req.Header.Add("API-Key", "__YOUR_API_KEY_HERE__")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
fmt.Println(string(body))
}#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.shipengine.com/v1/addresses/validate"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Host": @"api.shipengine.com",
@"API-Key": @"__YOUR_API_KEY_HERE__",
@"Content-Type": @"application/json"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"[\n {\n \"address_line1\": \"Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\"\n }\n]" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);import Foundation
var semaphore = DispatchSemaphore (value: 0)
let parameters = "[\n {\n \"address_line1\": \"Winchester Blvd\",\n \"city_locality\": \"San Jose\",\n \"state_province\": \"CA\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\"\n }\n]"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v1/addresses/validate")!,timeoutInterval: Double.infinity)
request.addValue("api.shipengine.com", forHTTPHeaderField: "Host")
request.addValue("__YOUR_API_KEY_HERE__", forHTTPHeaderField: "API-Key")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
request.httpBody = postData
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
semaphore.signal()
}
task.resume()
semaphore.wait()