Skip to main content
https://img.shields.io/pypi/v/trackr.svg https://img.shields.io/travis/rpedigoni/trackr.svg Documentation Status Updates

trackr is a lightweight Python lib to access carriers’ tracking information.

Installation

pip install trackr

Works with Python 2.7, 3.5 and 3.6.

Usage

from trackr import Trackr

package = Trackr.track('ect', 'PN871429404BR')

for t in package.tracking_info:
    print t.location, t.status

Or also using Trackr cli:

$ trackr --carrier=ect --object-id=PN871429404BR

Available carriers

  • ect (brazilian “Correios”)

  • fake (for testing purposes)

ECT

Data is retrieved from Correios using its SOAP webservice. For that you’ll need an username and password. Get in touch with your ECT representative to gain acess.

The easiest way to provide the credentials is exporting as env variable:

export TRACKR_ECT_USERNAME=**
export TRACKR_ECT_PASSWORD=**

You can also pass a function keyword args:

package = Trackr.track('ect', 'PN871429404BR', ect_username='**', ect_password='**')

Fake

Fake carrier is meant to be used when testing and developing integrations. It will always return as package found with 4 tracking info rows. Example

$ trackr --carrier=fake --object-id=123456789
Package found!
2017-04-23 15:12:23.521052 - City 1 - In transit 1
2017-04-23 15:12:23.521075 - City 2 - In transit 2
2017-04-23 15:12:23.521081 - City 3 - In transit 3
2017-04-23 15:12:23.521086 - City 4 - In transit 4

Integrating a new carrier

To add a new carrier, inherit carriers.base.BaseCarrier and fillout _track_single() and/or _track_bulk() methods, it must return one instance or a list of carriers.base.Package instance. See an example below:

from datetime import datetime
from .base import BaseCarrier


class MyOwnCarrier(BaseCarrier):
    id = 'mycarrier'
    name = 'My Carrier'

    def _track_single(self, object_id):

        # ... fetch data from carrier's data source

        package = self.create_package(
            object_id=object_id,
            service_name='Express service',
        )

        package.add_tracking_info(
            date=datetime(2017, 1, 1, 10, 00),
            location='Last Location',
            status='In transit to another location'
            description='Get ready!',
        )

        package.add_tracking_info(
            date=datetime.now(),
            location='Current Location',
            status='Delivered'
            description='Finally',
        )


        return package

Then update the carrier mapping on trackr/carriers/__init__.py (this should be improved with some autodiscover feature). Remember to write tests!

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Metadata

Release files for trackr 2.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for trackr 2.3.0
File Interpreter ABI Platform
trackr-2.3.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Release files / trackr-2.3.0-py2.py3-none-any.whl

Download URL trackr-2.3.0-py2.py3-none-any.whl
Size 8.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
57a4964b52290c552a2ce90e30771dfec423fe0d66bb8c118c46ae3ad4e1598d
BLAKE2b-256 checksum
How to use checksums
5bc1821d59d2ad2313a21ca7afd2430b6ac35cf8fde5cb20a6f400dd1ef3f55e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.13

Release history Release notifications | RSS feed

This release

2.3.0 This release

1 release file

2.2.0

1 release file

2.1.0

1 release file

2.0.0

1 release file

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page