import PackageRetriever from '@packageretriever/sdk';
const pr = new PackageRetriever('pr_test_YOUR_KEY_HERE');
// Validate an address
const address = await pr.addresses.validate({
name: 'Jane Smith',
street1: '417 Montgomery St',
city: 'San Francisco',
state: 'CA',
zip: '94104',
country: 'US'
});
// Get rates
const rates = await pr.rates.get({
from_address: address,
to_address: { name: 'Customer', street1: '123 Main St', city: 'Austin', state: 'TX', zip: '78701', country: 'US' },
parcel: { weight_oz: 16, length: 9, width: 6, height: 2 }
});
// Buy the cheapest label
const label = await pr.labels.create({ rate_id: rates.rates[0].id });
console.log(label.tracking_number); // 9400111899223408065744