Calculate rates
Name | Type | Description |
---|---|---|
shipment * | shipment | An instance of shipping freight or cargo |
async | boolean | enable async mode or not (set to false if not provided) |
is_document | boolean | If the shipment is document type. (set to false if not provided) |
shipper_accounts | array of reference | accounts for shipment Object reference |
ship_date | string | Ship Date in YYYY-MM-DD, if not provided, will be today of the shipper account timezone |
{
"shipper_accounts": [
{
"id": "c9244cf0-297a-43d6-b2a6-fc31637499e6"
}
],
"shipment": {
"parcels": [
{
"box_type": "custom",
"weight": {
"value": 1.2,
"unit": "kg"
},
"dimension": {
"height": 30,
"width": 20,
"depth": 40,
"unit": "cm"
},
"items": [
{
"description": "Food Bar",
"origin_country": "AUS",
"quantity": 2,
"price": {
"amount": 50,
"currency": "AUD"
},
"weight": {
"value": 0.6,
"unit": "kg"
},
"sku": "Epic_Food_Bar"
}
]
}
],
"ship_from": {
"contact_name": "contact australia post",
"company_name": "A Company",
"email": "panda@panda.com",
"street1": "Sydney street",
"city": "Craigieburn",
"postal_code": "3064",
"state": "VIC",
"country": "AUS",
"type": "business",
"phone": "1234567890"
},
"ship_to": {
"contact_name": "Buckinghamshire Livingstone West",
"company_name": "SICAB PTY LTD",
"email": "panda@panda.com",
"street1": "Level 2, Suite 4, 55 Norton St.",
"city": "St Kilda",
"postal_code": "3182",
"state": "VIC",
"country": "AUS",
"type": "residential"
}
},
"async": false
}
curl --request POST \
--url https://sandbox-api.postmen.com/v3/rates \
--header 'content-type: application/json' \
--header 'postmen-api-key: 8fc7966b-679b-4a57-911d-c5a663229c9e' \
--data '{"shipper_accounts":[{"id":"c9244cf0-297a-43d6-b2a6-fc31637499e6"}],"shipment":{"parcels":[{"box_type":"custom","weight":{"value":1.2,"unit":"kg"},"dimension":{"height":30,"width":20,"depth":40,"unit":"cm"},"items":[{"description":"Food Bar","origin_country":"AUS","quantity":2,"price":{"amount":50,"currency":"AUD"},"weight":{"value":0.6,"unit":"kg"},"sku":"Epic_Food_Bar"}]}],"ship_from":{"contact_name":"contact australia post","company_name":"A Company","email":"panda@panda.com","street1":"Sydney street","city":"Craigieburn","postal_code":"3064","state":"VIC","country":"AUS","type":"business","phone":"1234567890"},"ship_to":{"contact_name":"Buckinghamshire Livingstone West","company_name":"SICAB PTY LTD","email":"panda@panda.com","street1":"Level 2, Suite 4, 55 Norton St.","city":"St Kilda","postal_code":"3182","state":"VIC","country":"AUS","type":"residential"}},"async":false}'
using System;
using System.Net;
using System.IO;
class ExamplePostmen
{
static void Main(string[] args)
{
WebRequest httpWebRequest = WebRequest.Create("https://sandbox-api.postmen.com/v3/rates");
string json = "{\"shipper_accounts\":[{\"id\":\"c9244cf0-297a-43d6-b2a6-fc31637499e6\"}],\"shipment\":{\"parcels\":[{\"box_type\":\"custom\",\"weight\":{\"value\":1.2,\"unit\":\"kg\"},\"dimension\":{\"height\":30,\"width\":20,\"depth\":40,\"unit\":\"cm\"},\"items\":[{\"description\":\"Food Bar\",\"origin_country\":\"AUS\",\"quantity\":2,\"price\":{\"amount\":50,\"currency\":\"AUD\"},\"weight\":{\"value\":0.6,\"unit\":\"kg\"},\"sku\":\"Epic_Food_Bar\"}]}],\"ship_from\":{\"contact_name\":\"contact australia post\",\"company_name\":\"A Company\",\"email\":\"panda@panda.com\",\"street1\":\"Sydney street\",\"city\":\"Craigieburn\",\"postal_code\":\"3064\",\"state\":\"VIC\",\"country\":\"AUS\",\"type\":\"business\",\"phone\":\"1234567890\"},\"ship_to\":{\"contact_name\":\"Buckinghamshire Livingstone West\",\"company_name\":\"SICAB PTY LTD\",\"email\":\"panda@panda.com\",\"street1\":\"Level 2, Suite 4, 55 Norton St.\",\"city\":\"St Kilda\",\"postal_code\":\"3182\",\"state\":\"VIC\",\"country\":\"AUS\",\"type\":\"residential\"}},\"async\":false}";
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
httpWebRequest.Headers["postmen-api-key"] = "8fc7966b-679b-4a57-911d-c5a663229c9e";
using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
string result = streamReader.ReadToEnd();
Console.WriteLine(result);
}
}
}
import com.squareup.okhttp.*;
public class test {
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"shipper_accounts\":[{\"id\":\"c9244cf0-297a-43d6-b2a6-fc31637499e6\"}],\"shipment\":{\"parcels\":[{\"box_type\":\"custom\",\"weight\":{\"value\":1.2,\"unit\":\"kg\"},\"dimension\":{\"height\":30,\"width\":20,\"depth\":40,\"unit\":\"cm\"},\"items\":[{\"description\":\"Food Bar\",\"origin_country\":\"AUS\",\"quantity\":2,\"price\":{\"amount\":50,\"currency\":\"AUD\"},\"weight\":{\"value\":0.6,\"unit\":\"kg\"},\"sku\":\"Epic_Food_Bar\"}]}],\"ship_from\":{\"contact_name\":\"contact australia post\",\"company_name\":\"A Company\",\"email\":\"panda@panda.com\",\"street1\":\"Sydney street\",\"city\":\"Craigieburn\",\"postal_code\":\"3064\",\"state\":\"VIC\",\"country\":\"AUS\",\"type\":\"business\",\"phone\":\"1234567890\"},\"ship_to\":{\"contact_name\":\"Buckinghamshire Livingstone West\",\"company_name\":\"SICAB PTY LTD\",\"email\":\"panda@panda.com\",\"street1\":\"Level 2, Suite 4, 55 Norton St.\",\"city\":\"St Kilda\",\"postal_code\":\"3182\",\"state\":\"VIC\",\"country\":\"AUS\",\"type\":\"residential\"}},\"async\":false}");
Request request = new Request.Builder()
.url("https://sandbox-api.postmen.com/v3/rates")
.post(body)
.addHeader("postmen-api-key", "8fc7966b-679b-4a57-911d-c5a663229c9e")
.addHeader("content-type", "application/json")
.build();
try {
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
} catch (Exception e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}
}
var request = require("request");
var options = {
method: 'POST',
url: 'https://sandbox-api.postmen.com/v3/rates',
headers: {
'content-type': 'application/json',
'postmen-api-key': '8fc7966b-679b-4a57-911d-c5a663229c9e'
},
body: '{"shipper_accounts":[{"id":"c9244cf0-297a-43d6-b2a6-fc31637499e6"}],"shipment":{"parcels":[{"box_type":"custom","weight":{"value":1.2,"unit":"kg"},"dimension":{"height":30,"width":20,"depth":40,"unit":"cm"},"items":[{"description":"Food Bar","origin_country":"AUS","quantity":2,"price":{"amount":50,"currency":"AUD"},"weight":{"value":0.6,"unit":"kg"},"sku":"Epic_Food_Bar"}]}],"ship_from":{"contact_name":"contact australia post","company_name":"A Company","email":"panda@panda.com","street1":"Sydney street","city":"Craigieburn","postal_code":"3064","state":"VIC","country":"AUS","type":"business","phone":"1234567890"},"ship_to":{"contact_name":"Buckinghamshire Livingstone West","company_name":"SICAB PTY LTD","email":"panda@panda.com","street1":"Level 2, Suite 4, 55 Norton St.","city":"St Kilda","postal_code":"3182","state":"VIC","country":"AUS","type":"residential"}},"async":false}'
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$url = 'https://sandbox-api.postmen.com/v3/rates';
$method = 'POST';
$headers = array(
"content-type: application/json",
"postmen-api-key: 8fc7966b-679b-4a57-911d-c5a663229c9e"
);
$body = '{"shipper_accounts":[{"id":"c9244cf0-297a-43d6-b2a6-fc31637499e6"}],"shipment":{"parcels":[{"box_type":"custom","weight":{"value":1.2,"unit":"kg"},"dimension":{"height":30,"width":20,"depth":40,"unit":"cm"},"items":[{"description":"Food Bar","origin_country":"AUS","quantity":2,"price":{"amount":50,"currency":"AUD"},"weight":{"value":0.6,"unit":"kg"},"sku":"Epic_Food_Bar"}]}],"ship_from":{"contact_name":"contact australia post","company_name":"A Company","email":"panda@panda.com","street1":"Sydney street","city":"Craigieburn","postal_code":"3064","state":"VIC","country":"AUS","type":"business","phone":"1234567890"},"ship_to":{"contact_name":"Buckinghamshire Livingstone West","company_name":"SICAB PTY LTD","email":"panda@panda.com","street1":"Level 2, Suite 4, 55 Norton St.","city":"St Kilda","postal_code":"3182","state":"VIC","country":"AUS","type":"residential"}},"async":false}';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $body
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
# Make sure to install requests: pip install requests
import requests
url = 'https://sandbox-api.postmen.com/v3/rates'
payload = '''
{
"shipper_accounts": [
{
"id": "c9244cf0-297a-43d6-b2a6-fc31637499e6"
}
],
"shipment": {
"parcels": [
{
"box_type": "custom",
"weight": {
"value": 1.2,
"unit": "kg"
},
"dimension": {
"height": 30,
"width": 20,
"depth": 40,
"unit": "cm"
},
"items": [
{
"description": "Food Bar",
"origin_country": "AUS",
"quantity": 2,
"price": {
"amount": 50,
"currency": "AUD"
},
"weight": {
"value": 0.6,
"unit": "kg"
},
"sku": "Epic_Food_Bar"
}
]
}
],
"ship_from": {
"contact_name": "contact australia post",
"company_name": "A Company",
"email": "panda@panda.com",
"street1": "Sydney street",
"city": "Craigieburn",
"postal_code": "3064",
"state": "VIC",
"country": "AUS",
"type": "business",
"phone": "1234567890"
},
"ship_to": {
"contact_name": "Buckinghamshire Livingstone West",
"company_name": "SICAB PTY LTD",
"email": "panda@panda.com",
"street1": "Level 2, Suite 4, 55 Norton St.",
"city": "St Kilda",
"postal_code": "3182",
"state": "VIC",
"country": "AUS",
"type": "residential"
}
},
"async": false
}
'''
headers = {
'postmen-api-key': '8fc7966b-679b-4a57-911d-c5a663229c9e',
'content-type': 'application/json'
}
response = requests.request('POST', url, data=payload, headers=headers)
print(response.text)
require 'uri'
require 'net/http'
url = URI('https://sandbox-api.postmen.com/v3/rates')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request['postmen-api-key'] = '8fc7966b-679b-4a57-911d-c5a663229c9e'
request['content-type'] = 'application/json'
request.body = '{"shipper_accounts":[{"id":"c9244cf0-297a-43d6-b2a6-fc31637499e6"}],"shipment":{"parcels":[{"box_type":"custom","weight":{"value":1.2,"unit":"kg"},"dimension":{"height":30,"width":20,"depth":40,"unit":"cm"},"items":[{"description":"Food Bar","origin_country":"AUS","quantity":2,"price":{"amount":50,"currency":"AUD"},"weight":{"value":0.6,"unit":"kg"},"sku":"Epic_Food_Bar"}]}],"ship_from":{"contact_name":"contact australia post","company_name":"A Company","email":"panda@panda.com","street1":"Sydney street","city":"Craigieburn","postal_code":"3064","state":"VIC","country":"AUS","type":"business","phone":"1234567890"},"ship_to":{"contact_name":"Buckinghamshire Livingstone West","company_name":"SICAB PTY LTD","email":"panda@panda.com","street1":"Level 2, Suite 4, 55 Norton St.","city":"St Kilda","postal_code":"3182","state":"VIC","country":"AUS","type":"residential"}},"async":false}'
response = http.request(request)
puts response.read_body
Name | Type | Description |
---|---|---|
id | string | Calculate Rate ID |
status | string | Accepts: calculating ,calculated ,failed . |
rates | array of rate type | The amount of a charge or payment with reference to some basis of calculation. |
created_at | string | A formatted date. |
updated_at | string | A formatted date. |
Response example
{
"meta": {
"code": 200,
"message": "OK",
"details": []
},
"data": {
"created_at": "2020-05-22T09:36:06+00:00",
"id": "a468d916-9716-40d5-a526-6d1249dcd44a",
"updated_at": "2020-05-22T09:36:15+00:00",
"status": "calculated",
"rates": [
{
"shipper_account": {
"id": "c9244cf0-297a-43d6-b2a6-fc31637499e6",
"slug": "star-track",
"description": "star-track"
},
"service_type": "star-track_express",
"service_name": "Express",
"pickup_deadline": null,
"booking_cut_off": null,
"delivery_date": null,
"transit_time": null,
"error_message": null,
"info_message": null,
"charge_weight": null,
"total_charge": {
"amount": 15.76,
"currency": "AUD"
},
"detailed_charges": [
{
"type": "freight charge",
"charge": {
"amount": 12.48,
"currency": "AUD"
}
},
{
"type": "total gst",
"charge": {
"amount": 1.43,
"currency": "AUD"
}
},
{
"type": "fuel surcharge",
"charge": {
"amount": 1.85,
"currency": "AUD"
}
}
]
},
{
"shipper_account": {
"id": "c9244cf0-297a-43d6-b2a6-fc31637499e6",
"slug": "star-track",
"description": "star-track"
},
"service_type": "star-track_fixed_price_premium",
"service_name": "1,3 & 5KG Fixed Price Premium",
"pickup_deadline": null,
"booking_cut_off": null,
"delivery_date": null,
"transit_time": null,
"error_message": null,
"info_message": null,
"charge_weight": null,
"total_charge": {
"amount": 20.44,
"currency": "AUD"
},
"detailed_charges": [
{
"type": "freight charge",
"charge": {
"amount": 15.65,
"currency": "AUD"
}
},
{
"type": "total gst",
"charge": {
"amount": 1.86,
"currency": "AUD"
}
},
{
"type": "security surcharge",
"charge": {
"amount": 0.61,
"currency": "AUD"
}
},
{
"type": "fuel surcharge",
"charge": {
"amount": 2.32,
"currency": "AUD"
}
}
]
}
]
}
}
List all rates
Optional parameters
Name | Type | Description |
---|---|---|
status | string | Rate status Accepts: calculating ,calculated ,failed . |
limit | string | Number of records per page |
created_at_min | string | Start date and time of the record created (format YYYY-MM-DDTHH:MM:SSZ or YYYY-MM-DDTHH:MM:SS+00:00, default: 24hrs ago) |
created_at_max | string | End date and time of the record created (format YYYY-MM-DDTHH:MM:SSZ or YYYY-MM-DDTHH:MM:SS+00:00, default: NOW()) |
next_token | string | Next token |
{}
curl --request GET \
--url https://sandbox-api.postmen.com/v3/rates \
--header 'content-type: application/json' \
--header 'postmen-api-key: 8fc7966b-679b-4a57-911d-c5a663229c9e' \
using System;
using System.Net;
using System.IO;
class ExamplePostmen
{
static void Main(string[] args)
{
WebRequest httpWebRequest = WebRequest.Create("https://sandbox-api.postmen.com/v3/rates");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "GET";
httpWebRequest.Headers["postmen-api-key"] = "8fc7966b-679b-4a57-911d-c5a663229c9e";
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
string result = streamReader.ReadToEnd();
Console.WriteLine(result);
}
}
}
import com.squareup.okhttp.*;
public class test {
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
Request request = new Request.Builder()
.url("https://sandbox-api.postmen.com/v3/rates")
.get()
.addHeader("postmen-api-key", "8fc7966b-679b-4a57-911d-c5a663229c9e")
.addHeader("content-type", "application/json")
.build();
try {
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
} catch (Exception e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}
}
var request = require("request");
var options = {
method: 'GET',
url: 'https://sandbox-api.postmen.com/v3/rates',
headers: {
'content-type': 'application/json',
'postmen-api-key': '8fc7966b-679b-4a57-911d-c5a663229c9e'
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$url = 'https://sandbox-api.postmen.com/v3/rates';
$method = 'GET';
$headers = array(
"content-type: application/json",
"postmen-api-key: 8fc7966b-679b-4a57-911d-c5a663229c9e"
);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
# Make sure to install requests: pip install requests
import requests
url = 'https://sandbox-api.postmen.com/v3/rates'
headers = {
'postmen-api-key': '8fc7966b-679b-4a57-911d-c5a663229c9e',
'content-type': 'application/json'
}
response = requests.request('GET', url, headers=headers)
print(response.text)
require 'uri'
require 'net/http'
url = URI('https://sandbox-api.postmen.com/v3/rates')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request['postmen-api-key'] = '8fc7966b-679b-4a57-911d-c5a663229c9e'
request['content-type'] = 'application/json'
response = http.request(request)
puts response.read_body
Name | Type | Description |
---|---|---|
next_token | string or null | Any of string or null |
limit | number | Number of records per page |
rates | array of a rate record object | A rate record object |
Response example
No example available
Retrieve rates
{
"shipper_accounts": [
{
"id": "00000000-0000-0000-0000-000000000000"
}
],
"shipment": {
"parcels": [
{
"box_type": "custom",
"weight": {
"value": 1.2,
"unit": "kg"
},
"dimension": {
"height": 30,
"width": 20,
"depth": 40,
"unit": "cm"
},
"items": [
{
"description": "Food Bar",
"origin_country": "AUS",
"quantity": 2,
"price": {
"amount": 50,
"currency": "AUD"
},
"weight": {
"value": 0.6,
"unit": "kg"
},
"sku": "Epic_Food_Bar"
}
]
}
],
"ship_from": {
"contact_name": "contact australia post",
"company_name": "A Company",
"email": "panda@panda.com",
"street1": "Sydney street",
"city": "MOUNTAIN GATE",
"postal_code": "3156",
"state": "VIC",
"country": "AUS",
"type": "business",
"phone": "1234567890"
},
"ship_to": {
"contact_name": "Buckinghamshire Livingstone West",
"company_name": "SICAB PTY LTD",
"email": "panda@panda.com",
"street1": "Level 2, Suite 4, 55 Norton St.",
"city": "MOUNTAIN GATE",
"postal_code": "2000",
"state": "NSW",
"country": "AUS",
"type": "residential"
}
},
"async": false
}
curl --request GET \
--url https://sandbox-api.postmen.com/v3/rates/ \
--header 'content-type: application/json' \
--header 'postmen-api-key: 8fc7966b-679b-4a57-911d-c5a663229c9e' \
--data '{"shipper_accounts":[{"id":"00000000-0000-0000-0000-000000000000"}],"shipment":{"parcels":[{"box_type":"custom","weight":{"value":1.2,"unit":"kg"},"dimension":{"height":30,"width":20,"depth":40,"unit":"cm"},"items":[{"description":"Food Bar","origin_country":"AUS","quantity":2,"price":{"amount":50,"currency":"AUD"},"weight":{"value":0.6,"unit":"kg"},"sku":"Epic_Food_Bar"}]}],"ship_from":{"contact_name":"contact australia post","company_name":"A Company","email":"panda@panda.com","street1":"Sydney street","city":"MOUNTAIN GATE","postal_code":"3156","state":"VIC","country":"AUS","type":"business","phone":"1234567890"},"ship_to":{"contact_name":"Buckinghamshire Livingstone West","company_name":"SICAB PTY LTD","email":"panda@panda.com","street1":"Level 2, Suite 4, 55 Norton St.","city":"MOUNTAIN GATE","postal_code":"2000","state":"NSW","country":"AUS","type":"residential"}},"async":false}'
using System;
using System.Net;
using System.IO;
class ExamplePostmen
{
static void Main(string[] args)
{
WebRequest httpWebRequest = WebRequest.Create("https://sandbox-api.postmen.com/v3/rates/");
string json = "{\"shipper_accounts\":[{\"id\":\"00000000-0000-0000-0000-000000000000\"}],\"shipment\":{\"parcels\":[{\"box_type\":\"custom\",\"weight\":{\"value\":1.2,\"unit\":\"kg\"},\"dimension\":{\"height\":30,\"width\":20,\"depth\":40,\"unit\":\"cm\"},\"items\":[{\"description\":\"Food Bar\",\"origin_country\":\"AUS\",\"quantity\":2,\"price\":{\"amount\":50,\"currency\":\"AUD\"},\"weight\":{\"value\":0.6,\"unit\":\"kg\"},\"sku\":\"Epic_Food_Bar\"}]}],\"ship_from\":{\"contact_name\":\"contact australia post\",\"company_name\":\"A Company\",\"email\":\"panda@panda.com\",\"street1\":\"Sydney street\",\"city\":\"MOUNTAIN GATE\",\"postal_code\":\"3156\",\"state\":\"VIC\",\"country\":\"AUS\",\"type\":\"business\",\"phone\":\"1234567890\"},\"ship_to\":{\"contact_name\":\"Buckinghamshire Livingstone West\",\"company_name\":\"SICAB PTY LTD\",\"email\":\"panda@panda.com\",\"street1\":\"Level 2, Suite 4, 55 Norton St.\",\"city\":\"MOUNTAIN GATE\",\"postal_code\":\"2000\",\"state\":\"NSW\",\"country\":\"AUS\",\"type\":\"residential\"}},\"async\":false}";
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "GET";
httpWebRequest.Headers["postmen-api-key"] = "8fc7966b-679b-4a57-911d-c5a663229c9e";
using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
string result = streamReader.ReadToEnd();
Console.WriteLine(result);
}
}
}
import com.squareup.okhttp.*;
public class test {
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"shipper_accounts\":[{\"id\":\"00000000-0000-0000-0000-000000000000\"}],\"shipment\":{\"parcels\":[{\"box_type\":\"custom\",\"weight\":{\"value\":1.2,\"unit\":\"kg\"},\"dimension\":{\"height\":30,\"width\":20,\"depth\":40,\"unit\":\"cm\"},\"items\":[{\"description\":\"Food Bar\",\"origin_country\":\"AUS\",\"quantity\":2,\"price\":{\"amount\":50,\"currency\":\"AUD\"},\"weight\":{\"value\":0.6,\"unit\":\"kg\"},\"sku\":\"Epic_Food_Bar\"}]}],\"ship_from\":{\"contact_name\":\"contact australia post\",\"company_name\":\"A Company\",\"email\":\"panda@panda.com\",\"street1\":\"Sydney street\",\"city\":\"MOUNTAIN GATE\",\"postal_code\":\"3156\",\"state\":\"VIC\",\"country\":\"AUS\",\"type\":\"business\",\"phone\":\"1234567890\"},\"ship_to\":{\"contact_name\":\"Buckinghamshire Livingstone West\",\"company_name\":\"SICAB PTY LTD\",\"email\":\"panda@panda.com\",\"street1\":\"Level 2, Suite 4, 55 Norton St.\",\"city\":\"MOUNTAIN GATE\",\"postal_code\":\"2000\",\"state\":\"NSW\",\"country\":\"AUS\",\"type\":\"residential\"}},\"async\":false}");
Request request = new Request.Builder()
.url("https://sandbox-api.postmen.com/v3/rates/")
.get(body)
.addHeader("postmen-api-key", "8fc7966b-679b-4a57-911d-c5a663229c9e")
.addHeader("content-type", "application/json")
.build();
try {
Response response = client.newCall(request).execute();
System.out.println(response.body().string());
} catch (Exception e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}
}
var request = require("request");
var options = {
method: 'GET',
url: 'https://sandbox-api.postmen.com/v3/rates/',
headers: {
'content-type': 'application/json',
'postmen-api-key': '8fc7966b-679b-4a57-911d-c5a663229c9e'
},
body: '{"shipper_accounts":[{"id":"00000000-0000-0000-0000-000000000000"}],"shipment":{"parcels":[{"box_type":"custom","weight":{"value":1.2,"unit":"kg"},"dimension":{"height":30,"width":20,"depth":40,"unit":"cm"},"items":[{"description":"Food Bar","origin_country":"AUS","quantity":2,"price":{"amount":50,"currency":"AUD"},"weight":{"value":0.6,"unit":"kg"},"sku":"Epic_Food_Bar"}]}],"ship_from":{"contact_name":"contact australia post","company_name":"A Company","email":"panda@panda.com","street1":"Sydney street","city":"MOUNTAIN GATE","postal_code":"3156","state":"VIC","country":"AUS","type":"business","phone":"1234567890"},"ship_to":{"contact_name":"Buckinghamshire Livingstone West","company_name":"SICAB PTY LTD","email":"panda@panda.com","street1":"Level 2, Suite 4, 55 Norton St.","city":"MOUNTAIN GATE","postal_code":"2000","state":"NSW","country":"AUS","type":"residential"}},"async":false}'
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
<?php
$url = 'https://sandbox-api.postmen.com/v3/rates/';
$method = 'GET';
$headers = array(
"content-type: application/json",
"postmen-api-key: 8fc7966b-679b-4a57-911d-c5a663229c9e"
);
$body = '{"shipper_accounts":[{"id":"00000000-0000-0000-0000-000000000000"}],"shipment":{"parcels":[{"box_type":"custom","weight":{"value":1.2,"unit":"kg"},"dimension":{"height":30,"width":20,"depth":40,"unit":"cm"},"items":[{"description":"Food Bar","origin_country":"AUS","quantity":2,"price":{"amount":50,"currency":"AUD"},"weight":{"value":0.6,"unit":"kg"},"sku":"Epic_Food_Bar"}]}],"ship_from":{"contact_name":"contact australia post","company_name":"A Company","email":"panda@panda.com","street1":"Sydney street","city":"MOUNTAIN GATE","postal_code":"3156","state":"VIC","country":"AUS","type":"business","phone":"1234567890"},"ship_to":{"contact_name":"Buckinghamshire Livingstone West","company_name":"SICAB PTY LTD","email":"panda@panda.com","street1":"Level 2, Suite 4, 55 Norton St.","city":"MOUNTAIN GATE","postal_code":"2000","state":"NSW","country":"AUS","type":"residential"}},"async":false}';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $body
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
# Make sure to install requests: pip install requests
import requests
url = 'https://sandbox-api.postmen.com/v3/rates/'
payload = '''
{
"shipper_accounts": [
{
"id": "00000000-0000-0000-0000-000000000000"
}
],
"shipment": {
"parcels": [
{
"box_type": "custom",
"weight": {
"value": 1.2,
"unit": "kg"
},
"dimension": {
"height": 30,
"width": 20,
"depth": 40,
"unit": "cm"
},
"items": [
{
"description": "Food Bar",
"origin_country": "AUS",
"quantity": 2,
"price": {
"amount": 50,
"currency": "AUD"
},
"weight": {
"value": 0.6,
"unit": "kg"
},
"sku": "Epic_Food_Bar"
}
]
}
],
"ship_from": {
"contact_name": "contact australia post",
"company_name": "A Company",
"email": "panda@panda.com",
"street1": "Sydney street",
"city": "MOUNTAIN GATE",
"postal_code": "3156",
"state": "VIC",
"country": "AUS",
"type": "business",
"phone": "1234567890"
},
"ship_to": {
"contact_name": "Buckinghamshire Livingstone West",
"company_name": "SICAB PTY LTD",
"email": "panda@panda.com",
"street1": "Level 2, Suite 4, 55 Norton St.",
"city": "MOUNTAIN GATE",
"postal_code": "2000",
"state": "NSW",
"country": "AUS",
"type": "residential"
}
},
"async": false
}
'''
headers = {
'postmen-api-key': '8fc7966b-679b-4a57-911d-c5a663229c9e',
'content-type': 'application/json'
}
response = requests.request('GET', url, data=payload, headers=headers)
print(response.text)
require 'uri'
require 'net/http'
url = URI('https://sandbox-api.postmen.com/v3/rates/')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request['postmen-api-key'] = '8fc7966b-679b-4a57-911d-c5a663229c9e'
request['content-type'] = 'application/json'
request.body = '{"shipper_accounts":[{"id":"00000000-0000-0000-0000-000000000000"}],"shipment":{"parcels":[{"box_type":"custom","weight":{"value":1.2,"unit":"kg"},"dimension":{"height":30,"width":20,"depth":40,"unit":"cm"},"items":[{"description":"Food Bar","origin_country":"AUS","quantity":2,"price":{"amount":50,"currency":"AUD"},"weight":{"value":0.6,"unit":"kg"},"sku":"Epic_Food_Bar"}]}],"ship_from":{"contact_name":"contact australia post","company_name":"A Company","email":"panda@panda.com","street1":"Sydney street","city":"MOUNTAIN GATE","postal_code":"3156","state":"VIC","country":"AUS","type":"business","phone":"1234567890"},"ship_to":{"contact_name":"Buckinghamshire Livingstone West","company_name":"SICAB PTY LTD","email":"panda@panda.com","street1":"Level 2, Suite 4, 55 Norton St.","city":"MOUNTAIN GATE","postal_code":"2000","state":"NSW","country":"AUS","type":"residential"}},"async":false}'
response = http.request(request)
puts response.read_body
Name | Type | Description |
---|---|---|
id | string | Calculate Rate ID |
status | string | Accepts: calculating ,calculated ,failed . |
rates | array of rate type | The amount of a charge or payment with reference to some basis of calculation. |
created_at | string | A formatted date. |
updated_at | string | A formatted date. |
Response example
{
"meta": {
"code": 200,
"message": "OK",
"details": []
},
"data": {
"created_at": "2019-07-11T07:06:55+00:00",
"id": "f2edba61-6c9b-410d-8619-6bf0ca45825d",
"updated_at": "2019-07-11T07:07:10+00:00",
"status": "calculated",
"rates": [
{
"shipper_account": {
"id": "00000000-0000-0000-0000-000000000000",
"slug": "star-track",
"description": "star-track"
},
"service_type": null,
"service_name": null,
"pickup_deadline": null,
"booking_cut_off": null,
"delivery_date": null,
"transit_time": null,
"error_message": null,
"info_message": "No rate quotes returned from carrier.",
"charge_weight": null,
"total_charge": null,
"detailed_charges": []
}
]
}
}