Expand response
In some Shippo API responses, instead of returning parameters, the endpoint will return the object ID of the object that contains the parameters. This is available for a number of Shippo objects.
For example, in the transaction response, the rate
is returned as an object ID. The Shippo API is designed in this way to manage the size of the response.
Get a transactionresponse sample
curl --location 'https://api.goshippo.com/transactions/3e294ad43f7e417889c3c3766df2589b' \
--header 'Authorization: ShippoToken <API_TOKEN>' \
--header 'Content-Type: application/json'
{
"object_state": "VALID",
"status": "SUCCESS",
"object_created": "2024-04-23T16:03:01.881Z",
"object_updated": "2024-04-23T16:03:04.906Z",
"object_id": "3e294ad43f7e417889c3c3766df2589b",
"object_owner": "mrhippo@goshippo.com",
"test": true,
"rate": "819282d7ec8d4b1db3d03bbf8f0e1a7d",
"tracking_number": "EB000098472US",
"tracking_status": "UNKNOWN",
}
You can choose to expand an object using the query parameter expand
. When you expand an object, the returned response includes the parameters in that object.
Get a transaction including expand requestGet a transaction including expand response
curl --location 'https://api.goshippo.com/transactions/3e294ad43f7e417889c3c3766df2589b?expand="rate"' \
--header 'Authorization: ShippoToken <API_TOKEN>' \
--header 'Content-Type: application/json'
{
"object_state": "VALID",
"status": "SUCCESS",
"object_created": "2024-04-23T16:03:01.881Z",
"object_updated": "2024-04-23T16:03:04.906Z",
"object_id": "3e294ad43f7e417889c3c3766df2589b",
"object_owner": "mrhippo@goshippo.com",
"test": true,
"rate": {
"object_id": "819282d7ec8d4b1db3d03bbf8f0e1a7d",
"amount": "76.66",
"currency": "USD",
"amount_local": "71.95",
"currency_local": "EUR",
"provider": "USPS",
"servicelevel_name": "Priority Mail Express International",
"servicelevel_token": "usps_priority_mail_express_international",
"carrier_account": "b19e750708384303ac19ca693fe037ce"
},
"tracking_number": "EB000098472US",
"tracking_status": "UNKNOWN",
}
You can choose to expand multiple objects together at once using an array.
curl --location 'https://api.goshippo.com/transactions/3e294ad43f7e417889c3c3766df2589b?expand=["rate","parcel"]' \
--header 'Authorization: ShippoToken <API_TOKEN>' \
--header 'Content-Type: application/json'
This method does not support recursion.