能否通过Fedex API及SOAP API获取指定运单编号的运输历史?若可以该如何操作?
Hey there! Let's tackle your questions about FedEx APIs one by one:
问题1:是否可通过Fedex API获取特定追踪编号的运输历史记录?
Absolutely yes! Both the REST and SOAP versions of FedEx's Tracking API support retrieving full shipment history (i.e., all tracking events like pickup, transit, delivery, etc.) for a specific tracking number. You just need to use the right API operation and provide valid authentication details.
问题2:是否可通过Fedex SOAP API获取特定追踪编号的运输(追踪)历史记录?若可以,具体操作方式是什么?
Yes, you definitely can use the FedEx SOAP API to pull complete tracking history. Here's a step-by-step breakdown to make it work:
1. Grab your FedEx developer credentials first
Before making any requests, you'll need to register on the FedEx Developer Portal to get these mandatory authentication details:
- API Key
- API Password
- FedEx Account Number
- Meter Number
These are non-negotiable for validating your SOAP requests.
2. Use the FedEx Track Service SOAP API
You'll work with the TrackRequest operation under the Track Service—this is specifically built to fetch tracking details, including full shipment history.
3. Build your SOAP request XML
Here's the core structure you need to follow:
- Authentication section: Includes your API key/password (under
WebAuthenticationDetail) and account/meter numbers (underClientDetail). - Track parameters:
SelectionDetails: Specify your target tracking number usingPackageIdentifierwith typeTRACKING_NUMBER_OR_DOORTAG.ProcessingOptions: Set this toINCLUDE_DETAILED_SCANSto ensure you get the full timeline of all tracking events (not just the latest status).
Here's a sample request snippet (replace placeholders with your actual info):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v="http://fedex.com/ws/track/v19"> <soapenv:Header/> <soapenv:Body> <v:TrackRequest> <v:WebAuthenticationDetail> <v:UserCredential> <v:Key>YOUR_API_KEY</v:Key> <v:Password>YOUR_API_PASSWORD</v:Password> </v:UserCredential> </v:WebAuthenticationDetail> <v:ClientDetail> <v:AccountNumber>YOUR_ACCOUNT_NUMBER</v:AccountNumber> <v:MeterNumber>YOUR_METER_NUMBER</v:MeterNumber> </v:ClientDetail> <v:TransactionDetail> <v:CustomerTransactionId>Track_Request_001</v:CustomerTransactionId> </v:TransactionDetail> <v:Version> <v:ServiceId>trck</v:ServiceId> <v:Major>19</v:Major> <v:Intermediate>0</v:Intermediate> <v:Minor>0</v:Minor> </v:Version> <v:SelectionDetails> <v:PackageIdentifier> <v:Type>TRACKING_NUMBER_OR_DOORTAG</v:Type> <v:Value>YOUR_TARGET_TRACKING_NUMBER</v:Value> </v:PackageIdentifier> </v:SelectionDetails> <v:ProcessingOptions>INCLUDE_DETAILED_SCANS</v:ProcessingOptions> </v:TrackRequest> </soapenv:Body> </soapenv:Envelope>
4. Send the request to the correct endpoint
- Testing environment:
https://wsbeta.fedex.com:443/web-services - Production environment:
https://ws.fedex.com:443/web-services
Double-check you're using the right endpoint based on whether you're testing or going live.
5. Parse the response for tracking history
In the SOAP response, look for the TrackDetails node. Under it, the Events array will hold every entry in the shipment's history—each entry includes the event timestamp, location, status description, and relevant codes.
Quick tips
- Always use the latest API version (the example uses v19, but FedEx updates versions periodically—verify the current version in their docs).
- For bulk tracking, you can add multiple
SelectionDetailsnodes to a single request.
内容的提问来源于stack exchange,提问作者Sumit

