pythonups

UPS tracking API activity status options


UPS Tracking API

I am trying to use a UPS tracking API in Python.

import requests

inquiry_number = "1ZXXXXXXXXXXXXXXXX"
url = "https://wwwcie.ups.com/api/track/v1/details/" + inquiry_number

query = {
    "locale": "en_US",
    "returnSignature": "true"
}

headers = {
    "Content-Type": "application/json",
    "transId": "1234",
    "transactionSrc": "testing",
    "Authorization": "Bearer "..."
}

response = requests.get(url, headers=headers, params=query)

data = response.json()
print(data)

This output some statuses:

{
    'trackResponse': {
        'shipment': [
            {
                'inquiryNumber': '1Z1442YY7229014688',
                'package': [
                    {
                        'trackingNumber': '1Z1442YY7229014688',
                        'deliveryDate': [
                            {
                                'type': 'DEL',
                                'date': '20220126'
                            }
                        ],
                        'deliveryTime': {
                            'type': 'DEL',
                            'endTime': '163000'
                        },
                        'activity': [
                            {
                                'location': {
                                    'address': {
                                        'city': 'PARAMUS',
                                        'stateProvince': 'NJ',
                                        'countryCode': 'US',
                                        'country': 'US'
                                    },
                                    'slic': '0761'
                                },
                                'status': {
                                    'type': 'D',
                                    'description': 'DELIVERED ',
                                    'code': 'F4',
                                    'statusCode': '011'
                                },
                                'date': '20220126',
                                'time': '163000'
                            },
                            {
                                'location': {
                                    'address': {
                                        'countryCode': 'US',
                                        'country': 'US'
                                    }
                                },
                                'status': {
                                    'type': 'M',
                                    'description': 'Shipper created a label, UPS has not received the package yet. ',
                                    'code': 'MP',
                                    'statusCode': '003'
                                },
                                'date': '20220126',
                                'time': '151641'
                            }
                        ],
                        'packageCount': 1
                    }
                ]
            }
        ]
    }
}

Now I can't find anywhere a table with possible status types... I can see that 'D' and 'M' exist but what else?

Also:

in this documentation here I can see that in response there should be a currentStatus but I can't see him.

P.S.

How do you test with this API different scenarios, because it is obvious to me, that this test API is not connected with database for real (witch is expected). How can I test different trackig possibilities... dolivered, not delivered,...


Solution

  • You may have been looking for these codes. In the developer sandbox, under the "Methods" title, there is a link to "API Codes" If you go to the link, you will see the Tracking API Codes table with the column "Processing Details Status Code", try to take the code from the response in the statusCode field and find the status in a table. I think this is what you need.

    If you have already found a solution, please share it with us.