When building a custom checkout experience or integrating your own shipping solution with Shopify, you often need real-time shipping rates.
That’s where the Shopify API comes in — allowing you to get shipping rates programmatically for any order or cart.
In this guide, we’ll cover how to use the Shopify API to get shipping rates, including REST and GraphQL examples, authentication setup, and best practices for working with carrier services.

Shopify APIs Used for Shipping Rates
There are two main ways to retrieve shipping rates using Shopify’s APIs:
| API | Description | Use Case |
|---|---|---|
| CarrierService API | Custom apps can return live shipping rates from external carriers. | For third-party shipping rate providers |
| Admin API (REST or GraphQL) | Retrieve rates for draft orders, checkout sessions, or fulfillment services. | For custom checkout or backend calculations |
Let’s explore both in detail.
Method 1: Using the CarrierService API
The CarrierService API allows your custom app to provide real-time rates directly to Shopify’s checkout page.
This is useful if you operate your own logistics system or want to connect a non-standard carrier.
Step 1: Register a Carrier Service
You can register your app as a shipping rate provider via the Admin REST API:
Example Request:
-
callback_url: the endpoint Shopify will call to request rates. -
service_discovery:trueallows Shopify to automatically fetch all available services.
Example Response:
Step 2: Handle the Rate Request
When a customer checks out, Shopify sends a POST request to your callback URL with order details.
Example Callback Payload:
Your system must respond with a list of rates:
Example Response:
Shopify will display these rates at checkout for the customer to choose from.
✅ Pro Tip: You can calculate your rates dynamically using external APIs (like FedEx or UPS) before returning them to Shopify.
Method 2: Using the Shopify Admin API (REST or GraphQL)
If you’re working with custom checkouts, draft orders, or internal tools, you can get shipping rates directly from Shopify’s Admin API.
Option A: REST API Example
Endpoint:
Example Request:
Example Response (Rates Section):
Option B: GraphQL Example
Using GraphQL, you can query for shipping rates within a checkout session:
This returns all available shipping options for that checkout.
Authentication Setup
All Shopify API requests require authentication.
For private apps or custom apps, use the Admin API access token.
Make sure your app has permissions:
-
read_shipping -
write_shipping -
read_checkouts(if using checkout endpoints)
If you’re building a public app, use OAuth 2.0 for authorization.
Testing Shopify Shipping Rate API Locally
You can use tools like Postman or Insomnia to test requests.
Steps:
-
Generate a Shopify Admin API token.
-
Create a test order or checkout.
-
Use API endpoints to fetch rates.
-
Inspect JSON responses and verify expected behavior.
You can also test your callback endpoint (CarrierService) using mock data from Shopify’s test environment.
Common Issues and Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| No rates returned | Incorrect zone setup or carrier not available | Check “Shipping and Delivery” settings |
| 400 Bad Request | Invalid request format | Validate JSON structure |
| 401 Unauthorized | Missing or invalid API token | Regenerate access token |
| Delayed response | Callback timeout | Ensure your server responds within 10 seconds |
| Incorrect currency | Shopify store and response currency mismatch | Use store’s default currency or specify via API |
The Shopify API for getting shipping rates gives developers complete flexibility to customize delivery options for customers.
Whether you:
-
Build your own Carrier Service integration,
-
Fetch rates for custom checkouts, or
-
Automate fulfillment with multi-carrier shipping apps —
…the Shopify API makes it possible to provide accurate, dynamic shipping costs in real time.
By following this guide and best practices, you’ll have full control over your Shopify store’s shipping logic — improving both customer experience and operational efficiency.
