Parse Shipping Info from Text
ShipEngine uses machine learning and natural language processing (NLP) to parse shipping data from unstructured text.
Data often enters your system as unstructured text (for example: emails, SMS messages, support tickets, or other documents). ShipEngine's shipment recognition API saves you from parsing this text and trying to extract the useful data within it. Instead, you can simply send us the unstructured text, and we'll return any shipping data it contains — such as addresses, names, package weight and dimensions, insurance options, and more
Our machine learning models learn and improve over time, so they become more accurate and better at understanding different writing patterns.
Example
Let's say you receive an order via email. You can send the text of the email to ShipEngine and it will automatically detect the shipment information, such as the customer's address, delivery confirmation preferences, and insurance needs. Here's an example:
I need to ship a 17lb package that’s 36x12x24in. It’s going to Amanda Miller’s house at 525 Winchester Blvd in San Jose California. The zip code is 95128. It's really valuable, so insure it for $400 and require an adult signature please.
You could send this text to ShipEngine via the PUT /v1/shipments/recognize
endpoint, and it will recognize the following pieces of information:
Entity Type |
Value |
weight |
17 lbs |
dimensions |
36 inch x 12 inch x 24 inch |
address |
Amanda Miller 525 Winchester Blvd San Jose, CA 95128 |
person |
Amanda Miller |
delivery_confirmation |
Adult Signature |
insured_value |
400 USD |
Supported Countries
ShipEngine NLP currently supports English text, and can recognize addresses for the following countries:
- Australia
- Canada
- Ireland
- New Zealand
- United Kingdom
- United States
API Sample
In the API sample below, the response has an overall score of 0.96044... which indicates a 96% confidence that it parsed the text correctly. The score value can help your application programmatically decide if any additional input or verification from your user is needed.
The entities array breaks down the recognized data further into their own individual objects and provides additional scoring on the confidence for each field.
Example Request
POST /v1/shipments/recognize HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
{
"text": "I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please."
}
curl -iX POST https://api.shipengine.com/v1/shipments/recognize \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Content-Type: application/json' \
-d '{
"text": "I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please."
}'
$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 `"text`": `"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.`"`n}"
$response = Invoke-RestMethod 'https://api.shipengine.com/v1/shipments/recognize' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
var 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({"text":"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please."});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v1/shipments/recognize", 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/shipments/recognize',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
},
body: JSON.stringify({"text":"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please."})
};
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/shipments/recognize",
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 \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\"\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/shipments/recognize"
payload = "{\n \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\"\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/shipments/recognize")
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 \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\"\n}"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v1/shipments/recognize");
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 \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\"\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 \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\"\n}");
Request request = new Request.Builder()
.url("https://api.shipengine.com/v1/shipments/recognize")
.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/shipments/recognize"
method := "POST"
payload := strings.NewReader("{\n \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\"\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/shipments/recognize"]
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 \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\"\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 \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\"\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v1/shipments/recognize")!,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()
Example Response
{
"score": 0.9604458751176728,
"shipment": {
"confirmation": "adult_signature",
"ship_to": {
"name": "Amanda Miller",
"company_name": "Adult Signature",
"address_line1": "525 Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"address_residential_indicator": "yes"
},
"packages": [
{
"weight": {
"value": 17,
"unit": "pound"
},
"dimensions": {
"length": 36,
"width": 12,
"height": 24,
"unit": "inch"
},
"insured_value": {
"amount": 400,
"currency": "USD"
}
}
]
},
"entities": [
{
"type": "weight",
"score": 0.9805313966503588,
"text": "17lb",
"start_index": 17,
"end_index": 20,
"result": {
"value": 17,
"unit": "pound"
}
},
{
"type": "dimensions",
"score": 1,
"text": "36x12x24in",
"start_index": 37,
"end_index": 46,
"result": {
"length": 36,
"width": 12,
"height": 24,
"unit": "inch"
}
},
{
"type": "dimension",
"score": 0.9805313966503588,
"text": "24in",
"start_index": 43,
"end_index": 46,
"result": {
"unit": "inch",
"value": 24
}
},
{
"type": "address",
"score": 0.9686815805970408,
"text": "to Amanda Miller’s house at 525 Winchester Blvd in San Jose California. The zip code is 95128. It's really valuable, so insure it for $400 and require an adult signature",
"start_index": 60,
"end_index": 228,
"result": {
"direction": "to",
"name": "Amanda Miller",
"company_name": "Adult Signature",
"address_line1": "525 Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"address_residential_indicator": "yes"
}
},
{
"type": "person",
"score": 0.9519646137063122,
"text": "Amanda Miller",
"start_index": 63,
"end_index": 75,
"result": {
"value": "Amanda Miller"
}
},
{
"type": "residential_indicator",
"score": 0.9519646137063122,
"text": "house",
"start_index": 79,
"end_index": 83,
"result": {
"value": "yes"
}
},
{
"type": "address_line",
"score": 0.9805313966503588,
"text": "525 Winchester Blvd",
"start_index": 88,
"end_index": 106,
"result": {
"line": 1,
"value": "525 Winchester Blvd"
}
},
{
"type": "number",
"score": 0.9805313966503588,
"text": "525",
"start_index": 88,
"end_index": 90,
"result": {
"type": "cardinal",
"value": 525
}
},
{
"type": "city_locality",
"score": 0.9805313966503588,
"text": "San Jose",
"start_index": 111,
"end_index": 118,
"result": {
"value": "San Jose"
}
},
{
"type": "state_province",
"score": 0.9805313966503588,
"text": "California",
"start_index": 120,
"end_index": 129,
"result": {
"name": "California",
"value": "CA"
}
},
{
"type": "postal_code",
"score": 0.9519646137063122,
"text": "95128",
"start_index": 148,
"end_index": 152,
"result": {
"value": "95128"
}
},
{
"type": "insurance",
"score": 0.8530163983409642,
"text": "insure it for $400",
"start_index": 180,
"end_index": 197,
"result": {
"value": 400,
"unit": "USD"
}
},
{
"type": "insured_value",
"score": 1,
"text": "$400",
"start_index": 194,
"end_index": 197,
"result": {
"unit": "USD",
"value": 400
}
},
{
"type": "company",
"score": 0.9519646137063122,
"text": "adult signature",
"start_index": 214,
"end_index": 228,
"result": {
"value": "Adult Signature"
}
},
{
"type": "delivery_confirmation",
"score": 0.8530163983409642,
"text": "adult signature",
"start_index": 214,
"end_index": 228,
"result": {
"name": "Adult Signature",
"value": "adult_signature"
}
}
]
}
{
"score": 0.9604458751176728,
"shipment": {
"confirmation": "adult_signature",
"ship_to": {
"name": "Amanda Miller",
"company_name": "Adult Signature",
"address_line1": "525 Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"address_residential_indicator": "yes"
},
"packages": [
{
"weight": {
"value": 17,
"unit": "pound"
},
"dimensions": {
"length": 36,
"width": 12,
"height": 24,
"unit": "inch"
},
"insured_value": {
"amount": 400,
"currency": "USD"
}
}
]
},
"entities": [
{
"type": "weight",
"score": 0.9805313966503588,
"text": "17lb",
"start_index": 17,
"end_index": 20,
"result": {
"value": 17,
"unit": "pound"
}
},
{
"type": "dimensions",
"score": 1,
"text": "36x12x24in",
"start_index": 37,
"end_index": 46,
"result": {
"length": 36,
"width": 12,
"height": 24,
"unit": "inch"
}
},
{
"type": "dimension",
"score": 0.9805313966503588,
"text": "24in",
"start_index": 43,
"end_index": 46,
"result": {
"unit": "inch",
"value": 24
}
},
{
"type": "address",
"score": 0.9686815805970408,
"text": "to Amanda Miller’s house at 525 Winchester Blvd in San Jose California. The zip code is 95128. It's really valuable, so insure it for $400 and require an adult signature",
"start_index": 60,
"end_index": 228,
"result": {
"direction": "to",
"name": "Amanda Miller",
"company_name": "Adult Signature",
"address_line1": "525 Winchester Blvd",
"city_locality": "San Jose",
"state_province": "CA",
"postal_code": "95128",
"address_residential_indicator": "yes"
}
},
{
"type": "person",
"score": 0.9519646137063122,
"text": "Amanda Miller",
"start_index": 63,
"end_index": 75,
"result": {
"value": "Amanda Miller"
}
},
{
"type": "residential_indicator",
"score": 0.9519646137063122,
"text": "house",
"start_index": 79,
"end_index": 83,
"result": {
"value": "yes"
}
},
{
"type": "address_line",
"score": 0.9805313966503588,
"text": "525 Winchester Blvd",
"start_index": 88,
"end_index": 106,
"result": {
"line": 1,
"value": "525 Winchester Blvd"
}
},
{
"type": "number",
"score": 0.9805313966503588,
"text": "525",
"start_index": 88,
"end_index": 90,
"result": {
"type": "cardinal",
"value": 525
}
},
{
"type": "city_locality",
"score": 0.9805313966503588,
"text": "San Jose",
"start_index": 111,
"end_index": 118,
"result": {
"value": "San Jose"
}
},
{
"type": "state_province",
"score": 0.9805313966503588,
"text": "California",
"start_index": 120,
"end_index": 129,
"result": {
"name": "California",
"value": "CA"
}
},
{
"type": "postal_code",
"score": 0.9519646137063122,
"text": "95128",
"start_index": 148,
"end_index": 152,
"result": {
"value": "95128"
}
},
{
"type": "insurance",
"score": 0.8530163983409642,
"text": "insure it for $400",
"start_index": 180,
"end_index": 197,
"result": {
"value": 400,
"unit": "USD"
}
},
{
"type": "insured_value",
"score": 1,
"text": "$400",
"start_index": 194,
"end_index": 197,
"result": {
"unit": "USD",
"value": 400
}
},
{
"type": "company",
"score": 0.9519646137063122,
"text": "adult signature",
"start_index": 214,
"end_index": 228,
"result": {
"value": "Adult Signature"
}
},
{
"type": "delivery_confirmation",
"score": 0.8530163983409642,
"text": "adult signature",
"start_index": 214,
"end_index": 228,
"result": {
"name": "Adult Signature",
"value": "adult_signature"
}
}
]
}
Already-known fields
You can specify any already-known fields for your shipment in the request. This can help you automatically define your known variable such as...
- ship_from
- carrier_id
- confirmation
- package dimensions
- verify_address
PUT /v1/shipments/recognize HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
Content-Type: application/json
{
"text": "I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.",
"shipment": {
"ship_from": {
"company_name": "Example Corp.",
"name": "John Doe",
"phone": "111-111-1111",
"address_line1": "4009 Marathon Blvd",
"address_line2": "Suite 300",
"city_locality": "Austin",
"state_province": "TX",
"postal_code": "78756",
"country_code": "US",
"address_residential_indicator": "no"
}
}
}
curl -iX PUT https://api.shipengine.com/v1/shipments/recognize \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
-H 'Content-Type: application/json' \
-d '{
"text": "I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.",
"shipment": {
"ship_from": {
"company_name": "Example Corp.",
"name": "John Doe",
"phone": "111-111-1111",
"address_line1": "4009 Marathon Blvd",
"address_line2": "Suite 300",
"city_locality": "Austin",
"state_province": "TX",
"postal_code": "78756",
"country_code": "US",
"address_residential_indicator": "no"
}
}
}'
$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 `"text`": `"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.`",`n `"shipment`": {`n `"ship_from`": {`n `"company_name`": `"Example Corp.`",`n `"name`": `"John Doe`",`n `"phone`": `"111-111-1111`",`n `"address_line1`": `"4009 Marathon Blvd`",`n `"address_line2`": `"Suite 300`",`n `"city_locality`": `"Austin`",`n `"state_province`": `"TX`",`n `"postal_code`": `"78756`",`n `"country_code`": `"US`",`n `"address_residential_indicator`": `"no`"`n }`n }`n}"
$response = Invoke-RestMethod 'https://api.shipengine.com/v1/shipments/recognize' -Method 'PUT' -Headers $headers -Body $body
$response | ConvertTo-Json
var 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({"text":"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.","shipment":{"ship_from":{"company_name":"Example Corp.","name":"John Doe","phone":"111-111-1111","address_line1":"4009 Marathon Blvd","address_line2":"Suite 300","city_locality":"Austin","state_province":"TX","postal_code":"78756","country_code":"US","address_residential_indicator":"no"}}});
var requestOptions = {
method: 'PUT',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v1/shipments/recognize", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
var request = require('request');
var options = {
'method': 'PUT',
'url': 'https://api.shipengine.com/v1/shipments/recognize',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
},
body: JSON.stringify({"text":"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.","shipment":{"ship_from":{"company_name":"Example Corp.","name":"John Doe","phone":"111-111-1111","address_line1":"4009 Marathon Blvd","address_line2":"Suite 300","city_locality":"Austin","state_province":"TX","postal_code":"78756","country_code":"US","address_residential_indicator":"no"}}})
};
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/shipments/recognize",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS =>"{\n \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\",\n \"shipment\": {\n \"ship_from\": {\n \"company_name\": \"Example Corp.\",\n \"name\": \"John Doe\",\n \"phone\": \"111-111-1111\",\n \"address_line1\": \"4009 Marathon Blvd\",\n \"address_line2\": \"Suite 300\",\n \"city_locality\": \"Austin\",\n \"state_province\": \"TX\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"no\"\n }\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/shipments/recognize"
payload = "{\n \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\",\n \"shipment\": {\n \"ship_from\": {\n \"company_name\": \"Example Corp.\",\n \"name\": \"John Doe\",\n \"phone\": \"111-111-1111\",\n \"address_line1\": \"4009 Marathon Blvd\",\n \"address_line2\": \"Suite 300\",\n \"city_locality\": \"Austin\",\n \"state_province\": \"TX\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"no\"\n }\n }\n}"
headers = {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__',
'Content-Type': 'application/json'
}
response = requests.request("PUT", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://api.shipengine.com/v1/shipments/recognize")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Host"] = "api.shipengine.com"
request["API-Key"] = "__YOUR_API_KEY_HERE__"
request["Content-Type"] = "application/json"
request.body = "{\n \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\",\n \"shipment\": {\n \"ship_from\": {\n \"company_name\": \"Example Corp.\",\n \"name\": \"John Doe\",\n \"phone\": \"111-111-1111\",\n \"address_line1\": \"4009 Marathon Blvd\",\n \"address_line2\": \"Suite 300\",\n \"city_locality\": \"Austin\",\n \"state_province\": \"TX\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"no\"\n }\n }\n}"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v1/shipments/recognize");
client.Timeout = -1;
var request = new RestRequest(Method.PUT);
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 \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\",\n \"shipment\": {\n \"ship_from\": {\n \"company_name\": \"Example Corp.\",\n \"name\": \"John Doe\",\n \"phone\": \"111-111-1111\",\n \"address_line1\": \"4009 Marathon Blvd\",\n \"address_line2\": \"Suite 300\",\n \"city_locality\": \"Austin\",\n \"state_province\": \"TX\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"no\"\n }\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 \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\",\n \"shipment\": {\n \"ship_from\": {\n \"company_name\": \"Example Corp.\",\n \"name\": \"John Doe\",\n \"phone\": \"111-111-1111\",\n \"address_line1\": \"4009 Marathon Blvd\",\n \"address_line2\": \"Suite 300\",\n \"city_locality\": \"Austin\",\n \"state_province\": \"TX\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"no\"\n }\n }\n}");
Request request = new Request.Builder()
.url("https://api.shipengine.com/v1/shipments/recognize")
.method("PUT", 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/shipments/recognize"
method := "PUT"
payload := strings.NewReader("{\n \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\",\n \"shipment\": {\n \"ship_from\": {\n \"company_name\": \"Example Corp.\",\n \"name\": \"John Doe\",\n \"phone\": \"111-111-1111\",\n \"address_line1\": \"4009 Marathon Blvd\",\n \"address_line2\": \"Suite 300\",\n \"city_locality\": \"Austin\",\n \"state_province\": \"TX\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"no\"\n }\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/shipments/recognize"]
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 \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\",\n \"shipment\": {\n \"ship_from\": {\n \"company_name\": \"Example Corp.\",\n \"name\": \"John Doe\",\n \"phone\": \"111-111-1111\",\n \"address_line1\": \"4009 Marathon Blvd\",\n \"address_line2\": \"Suite 300\",\n \"city_locality\": \"Austin\",\n \"state_province\": \"TX\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"no\"\n }\n }\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"PUT"];
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 \"text\": \"I need to ship a 17lb package thats 36x12x24in. Its going to Amanda Millers house at 525 Winchester Blvd in San Jose California. The zip code is 95128. Its really valuable, so insure it for $400 and require an adult signature please.\",\n \"shipment\": {\n \"ship_from\": {\n \"company_name\": \"Example Corp.\",\n \"name\": \"John Doe\",\n \"phone\": \"111-111-1111\",\n \"address_line1\": \"4009 Marathon Blvd\",\n \"address_line2\": \"Suite 300\",\n \"city_locality\": \"Austin\",\n \"state_province\": \"TX\",\n \"postal_code\": \"78756\",\n \"country_code\": \"US\",\n \"address_residential_indicator\": \"no\"\n }\n }\n}"
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v1/shipments/recognize")!,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 = "PUT"
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()
Entity Types
The shipment recognition API is currently designed to recognize the following types of entities:
Entity Type |
Recognized Attributes |
address |
direction: enumerated string ("from" or "to") name: string company_name: string phone: string address_line1: string address_line2: string address_line3: string city_locality: string state_province: string postal_code: string country_code: string address_residential_indicator: enumerated string ("yes", "no", or "unknown") |
address_line |
line: number(usually 1, 2 or 3) value: string (ex: "525 Winchester Blvd") |
carrier |
name: string (ex: "FedEx", "UPS", "Stamps.com") value: string (ex: "fedex", "ups", "stamps_com") |
city_locality |
value: string |
company |
value: string |
delivery_confirmation |
name: string (ex: "Adult Signature") value: string (ex: "adult_signature") |
country |
name: string value: string |
dimension |
value: number unit: enumerated string ("inch" or "centimeter") dimension: enumerated string ("length", "width", or "height") |
dimensions |
length: number width: number height: number unit: enumerated string ("inch", or "centimeter") |
insurance |
value: number unit: enumerated string ("USD", "CAD", "AUD", "GBP", or "EUR") provider: enumerated string ("shipsurance", "carrier", or "external") |
insurance_provider |
name: string (ex: "Shipsurance", "Carrier Insurance") value: enumerated string ("shipsurance", "carrier", or "external") |
insured_value |
value: number unit: enumerated string ("USD", "CAD", "AUD", "GBP", or "EUR") |
monetary_value |
value: number unit: enumerated string ("USD", "CAD", "AUD", "GBP", or "EUR") |
number |
type: enumerated string ("cardial", "ordinal", "or "percentage") value: number |
person |
value: string |
phone_number |
value: string |
postal_code |
value: string |
residential_indicator |
value: enumerated string ("yes", "no", or "unknown") |
service |
name: string (ex: "USPS First Class Mail Intl") value: string (ex: "usps_first_vlass_mail_international") |
state_province |
name: string (ex: "Texas", "Quebec", "New South Wales") value: string (ex: "TX", "QC", "NSW") country: string (ex: "US", "CA", "AU") |
timeframe |
type: enumerated string ("date" or "range") If the type is "date" value: string (ex: "2018-11-07T08:30:00.000Z") if the type is "range" start: string (ex: "2018-11-07T08:30:00.000Z") end: string (ex: "2018-11-07T08:30:00.000Z") NOTE: Timezones are not currently supported. All dates and times are returned in UTC |
weight |
value: number unit: enumerated string ("pound", "ounce", "gram", or "kilogram") |