If your application ships with more than one carrier, tracking can become a collection of separate integrations. Each carrier may return different event names, fields, timing, and error responses. A tracking API can provide one request pattern and a normalized response, while your application remains responsible for storing shipments, deciding when to check them, and presenting useful information to customers.
This guide walks through those application responsibilities. The examples use C2W’s documented endpoint, distributed through RapidAPI, as a concrete reference. Verify that your required carrier services and fields work with representative tracking numbers before designing a production workflow around them.
1. Define the tracking workflow
Before writing code, decide when a shipment enters tracking, which screens need its status, and what should happen after delivery or an exception. A typical flow looks like this:
- Your system creates a shipment record when it receives a tracking number.
- A background worker schedules a tracking request.
- Your server calls the tracking API and checks the HTTP response.
- Your application stores the latest result and relevant events.
- Your customer-facing page reads your stored shipment state.
- A scheduler checks again when the shipment is still active.
Keep the tracking API call on your server. That lets you protect credentials, apply request limits, and avoid exposing provider details in a browser or mobile app.
2. Store a shipment record you can update
At minimum, keep your own shipment ID, tracking number as a string, carrier if known, current status, last-check time, and next-check time. Store the provider’s original status text and the event history you need for your product. Tracking numbers should stay strings so leading zeroes and long identifiers are preserved.
It is useful to separate your internal state from carrier wording. For example, your interface might use broad stages such as pre_transit, in_transit, out_for_delivery, delivered, and exception, while retaining the source status and event text for detail and troubleshooting. Map only values you have observed and tested; unknown values should remain visible as source data rather than being guessed.
3. Make a server-side tracking request
The public C2W reference documents a GET request with one trackingNumber query parameter. Authentication uses your RapidAPI credentials. Keep the API key in a server-side environment variable or secrets manager.
const trackingNumber = '9200190312809701574398';
const url = new URL('https://trackingpackage.p.rapidapi.com/TrackingPackage');
url.searchParams.set('trackingNumber', trackingNumber);
const response = await fetch(url, {
headers: {
'X-RapidAPI-Key': process.env.RAPIDAPI_KEY,
'X-RapidAPI-Host': 'trackingpackage.p.rapidapi.com'
},
signal: AbortSignal.timeout(10_000)
});
if (!response.ok) {
throw new Error(`Tracking request failed: ${response.status}`);
}
const tracking = await response.json();
console.log(tracking.Status, tracking.TrackingDetails);
The timeout above is an application example, not a provider service guarantee. Use the exact endpoint, headers, and credential requirements shown for your subscription. Do not put a private RapidAPI key in frontend JavaScript, a public repository, or client-visible configuration.
4. Handle failures separately from shipment status
An unsuccessful HTTP request is not a shipment status. Check the HTTP status before treating the body as a successful tracking object. Authentication failures, quota responses, temporary gateway errors, and unavailable tracking data can have different payloads.
- For authentication errors, verify the subscription and server-side credentials.
- For rate or quota responses, slow down and respect any retry guidance returned by the gateway.
- For timeouts and temporary server errors, use a bounded retry policy with exponential backoff and jitter.
- For a valid response with missing fields, store what is available and avoid inventing a status.
Do not retry every failure at the same frequency. A bad credential will not be fixed by retrying, and aggressive retries can make quota pressure worse. Log enough context to diagnose an error, but avoid logging API keys or unnecessary customer data.
5. Schedule checks around shipment state
The documented C2W integration is request-based: webhooks are not supported, so your application manages polling. Start with conservative intervals and adjust them to your customer experience, carrier mix, API limits, and cost. Treat any schedule as a starting point to validate, not a carrier promise.
| Internal stage | Scheduling idea | Application behavior |
|---|---|---|
| Label created or waiting for handoff | Check infrequently | Allow time for the first carrier scan; avoid rapid repeated requests. |
| In transit | Use a regular, bounded cadence | Spread work over time and reschedule based on the latest result. |
| Out for delivery | Consider more frequent checks during the delivery window | Increase frequency only when fresher status is valuable and within plan limits. |
| Delivered or otherwise complete | Stop routine polling | Keep the final result and reopen tracking only when your workflow requires it. |
Use a durable job queue or scheduled worker for production polling rather than relying on a user keeping a page open. Add jitter to scheduled checks so many shipments do not hit the API at exactly the same time. Compare new events with saved events before sending notifications, because repeated requests can return the same event again.
6. Estimate request usage before launch
Count requests, not only shipments. If 1,000 active shipments are each checked four times per day, that is about 4,000 requests a day before retries or manual refreshes. If a shipment is checked every hour for a full day, that is 24 requests for that shipment. Caching results in your own application can prevent duplicate checks when several users view the same shipment.
Review both the daily allowance and per-second rate limit on your plan. Allow room for retries, new shipment spikes, and support-driven refreshes. The API’s response may be cached, and a successful request does not mean a new carrier scan occurred since your previous check.
7. Test carrier behavior with real use cases
Before launch, evaluate representative tracking numbers from each carrier service your customers use. Include shipments that are newly created, moving, delivered, and experiencing an exception if you can. Confirm how your app handles missing destination fields, unfamiliar event text, unchanged results, and gateway errors.
The current public reference covers one tracking number per request and does not document a batch endpoint. If your workload needs batch submission, confirm the endpoint, maximum batch size, and quota accounting with C2W before building around it. Carrier coverage and field availability can vary by service and route.
Production-readiness checklist
- Keep provider credentials on your server.
- Store tracking numbers as strings and retain each shipment’s last successful result.
- Check HTTP status before parsing a success response.
- Use bounded timeouts, retries, and backoff.
- Schedule polling within both daily quotas and rate limits.
- Stop routine checks after a terminal shipment state.
- Deduplicate events before sending customer notifications.
- Test the specific carrier services, routes, and response fields your product needs.
A good multi-carrier integration keeps provider calls behind your application boundary and gives your product one consistent way to store and display shipment progress. Start with a narrow set of workflows, measure request usage and missing-data cases, and expand after you have validated actual shipments.