📦 Get shipping rates for orders by Shippo
Asynchronous microservice that returns shipping rates from Shippo for given from
and to
addresses and parcel
info. Built with Micro 🤩
Both a moltin and Shippo account are needed for this to function.
Create a .env
at the project root with the following credentials.
MOLTIN_SECRET_KEY=
SHIPPO_PRIVATE_KEY=
npm install
npm run dev
Once you have the function deployed, take a note of the immutable now.sh
url.
You can use this URL to make requests, providing you send along X-MOLTIN-SECRET-KEY
in the request header that is the same you defined in .env
. You may wish to invoke this function server side so you don't expose your MOLTIN_SECRET_KEY
but you could remove this feature entirely.
Send a request to http://localhost:3000
that includes the following payload
{
"from": {
"name": "...",
"company": "...",
"street1": "...",
"city": "...",
"state": "...",
"zip": "...",
"country": "...",
"phone": "...",
"email": "..."
},
"to": {
"name": "...",
"company": "...",
"street1": "...",
"city": "...",
"state": "...",
"zip": "...",
"country": "...",
"phone": "...",
"email": "..."
},
"parcels": [
{
"length": "5",
"width": "5",
"height": "5",
"distance_unit": "in",
"weight": "2",
"mass_unit": "lb"
}
]
}
You can easily deploy this function to now.