Since there's potential to have a large number of batches, we allow them to be queryable in of ShipEngine.
GET /v1/batches?status=open HTTP/1.1
Host: api.shipengine.com
API-Key: __YOUR_API_KEY_HERE__
curl -iX GET 'https://api.shipengine.com/v1/batches?status=open' \
-H 'API-Key: __YOUR_API_KEY_HERE__' \
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Host", "api.shipengine.com")
$headers.Add("API-Key", "__YOUR_API_KEY_HERE__")
$response = Invoke-RestMethod 'https://api.shipengine.com/v1/batches?status=open' -Method 'GET' -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__");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://api.shipengine.com/v1/batches?status=open", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://api.shipengine.com/v1/batches?status=open',
'headers': {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__'
}
};
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/batches?status=open",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Host: api.shipengine.com",
"API-Key: __YOUR_API_KEY_HERE__"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://api.shipengine.com/v1/batches?status=open"
payload = {}
headers = {
'Host': 'api.shipengine.com',
'API-Key': '__YOUR_API_KEY_HERE__'
}
response = requests.request("GET", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
require "uri"
require "net/http"
url = URI("https://api.shipengine.com/v1/batches?status=open")
https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Host"] = "api.shipengine.com"
request["API-Key"] = "__YOUR_API_KEY_HERE__"
response = https.request(request)
puts response.read_body
var client = new RestClient("https://api.shipengine.com/v1/batches?status=open");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Host", "api.shipengine.com");
request.AddHeader("API-Key", "__YOUR_API_KEY_HERE__");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.shipengine.com/v1/batches?status=open")
.method("GET", null)
.addHeader("Host", "api.shipengine.com")
.addHeader("API-Key", "__YOUR_API_KEY_HERE__")
.build();
Response response = client.newCall(request).execute();
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.shipengine.com/v1/batches?status=open"
method := "GET"
client := &http.Client {
}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
}
req.Header.Add("Host", "api.shipengine.com")
req.Header.Add("API-Key", "__YOUR_API_KEY_HERE__")
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/batches?status=open"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Host": @"api.shipengine.com",
@"API-Key": @"__YOUR_API_KEY_HERE__"
};
[request setAllHTTPHeaderFields:headers];
[request setHTTPMethod:@"GET"];
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)
var request = URLRequest(url: URL(string: "https://api.shipengine.com/v1/batches?status=open")!,timeoutInterval: Double.infinity)
request.addValue("api.shipengine.com", forHTTPHeaderField: "Host")
request.addValue("__YOUR_API_KEY_HERE__", forHTTPHeaderField: "API-Key")
request.httpMethod = "GET"
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()
{
"batches": [
{
"label_layout": null,
"label_format": null,
"batch_id": "se-1013790",
"external_batch_id": "1daa0c22-0519-46d0-8653-9f3dc62e7d2c",
"batch_notes": "2019-7-25 Morning Shipments",
"created_at": "2019-07-25T15:24:46.657Z",
"errors": 0,
"warnings": 0,
"completed": 0,
"forms": 0,
"count": 1,
"batch_shipments_url": {
"href": "https://api.shipengine.com/v1/shipments?batch_id=se-1013790"
},
"batch_labels_url": {
"href": "https://api.shipengine.com/v1/labels?batch_id=se-1013790"
},
"batch_errors_url": {
"href": "https://api.shipengine.com/v1/batches/se-1013790/errors"
},
"label_download": {
"href": "https://api.shipengine.com/v1/downloads/1/uths7PctKUqbM4OfmgzXLg/label-1013790.pdf"
},
"form_download": {
"href": "https://api.shipengine.com/v1/downloads/1/xKVZeKA650-bvQB_oriYkQ/form-1013790.pdf"
},
"status": "open"
}
],
"total": 1,
"page": 1,
"pages": 1,
"links": {
"first": {
"href": "https://api.shipengine.com/v1/batches?status=open&page=1&page_size=100"
},
"last": {
"href": "https://api.shipengine.com/v1/batches?status=open&page=1&page_size=100"
},
"prev": {},
"next": {}
}
}
{
"batches": [
{
"label_layout": null,
"label_format": null,
"batch_id": "se-1013790",
"external_batch_id": "1daa0c22-0519-46d0-8653-9f3dc62e7d2c",
"batch_notes": "2019-7-25 Morning Shipments",
"created_at": "2019-07-25T15:24:46.657Z",
"errors": 0,
"warnings": 0,
"completed": 0,
"forms": 0,
"count": 1,
"batch_shipments_url": {
"href": "https://api.shipengine.com/v1/shipments?batch_id=se-1013790"
},
"batch_labels_url": {
"href": "https://api.shipengine.com/v1/labels?batch_id=se-1013790"
},
"batch_errors_url": {
"href": "https://api.shipengine.com/v1/batches/se-1013790/errors"
},
"label_download": {
"href": "https://api.shipengine.com/v1/downloads/1/uths7PctKUqbM4OfmgzXLg/label-1013790.pdf"
},
"form_download": {
"href": "https://api.shipengine.com/v1/downloads/1/xKVZeKA650-bvQB_oriYkQ/form-1013790.pdf"
},
"status": "open"
}
],
"total": 1,
"page": 1,
"pages": 1,
"links": {
"first": {
"href": "https://api.shipengine.com/v1/batches?status=open&page=1&page_size=100"
},
"last": {
"href": "https://api.shipengine.com/v1/batches?status=open&page=1&page_size=100"
},
"prev": {},
"next": {}
}
}