A Python library for Thailand Post track API
Project description
Thailand Post Track
A Python library for Thailand Post Track API
Table of Contents
Installation
pip install thailandpost-track
Usage
from thailandpost_track import ThailandpostTrack
Initial Thailand Post Track Object
Parameter:
token_key
string token to access API Get here
Function:
TOKEN_KEY = 'X5RcT/DOF@ESK_RxMICNP8PTW=Dm...'
thp = ThailandpostTrack(token_key=TOKEN_KEY)
Viewing Track
Check status of tracking
Parameter:
barcode
string list tracking number of Thailand Poststatus
string filter by statusdefault
StatusCode.ALL morelanguage
string language of responsedefault
Language.EN more
Function:
from thailandpost_track import Language
from thailandpost_track import StatusCode
barcode = ['EF582568151TH']
thp.track(barcode=barcode, status=StatusCode.FINAL_DELIVERY, language=Language.EN)
Response:
{
'response': {
'items': {
'EF582568151TH': [
{
'barcode': 'EF582568151TH',
'status': '501',
'status_description': 'Final delivery',
'status_date': '26/10/2019 10:00:44+07:00',
'location': 'RONG KWANG',
'postcode': '54140',
'delivery_status': 'S',
'delivery_description': 'Successful',
'delivery_datetime': '26/10/2019 10:00:44+07:00',
'receiver_name': 'ยุพิน/ภรรยา',
'signature': 'https://trackimage.thailandpost.co.th/f/signature/QDY4MTUxYjVzMGx1VDMz/QGI1c0VGMGx1VDMx/QGI1czBsVEh1VDM0/QGI1czBsdTU4MjVUMzI='
}
]
},
'track_count': {
'track_date': '24/03/2020',
'count_number': 6,
'track_count_limit': 1000
}
},
'message': 'successful',
'status': True
}
Viewing Token Expire
Check token expire
Function:
thp.expire()
Response:
2020-04-24 17:30:48+07:00
Fetch New Token
Fetch new token, if your token will expire
Function:
thp.fetch_token()
References
Status Code
Status of items. Click link to show more detail.
List:
Variables | Code | Description |
---|---|---|
ALL | all | All |
PRELOAD | 101 | Preload |
ACCEPTED_BY_AGENT | 102 | Accepted by Agent |
COLLECTION | 103 | Posting/Collection |
IN_TRANSIT | 201 | In transit |
PERFORM_CUSTOMS_CLEARANCE | 202 | Perform customs clearance |
RETURN_TO_SENDER | 203 | Return to Sender |
ARRIVAL_AT_OUTWARD_OFFICE | 204 | Arrival at outward office of exchange |
ARRIVAL_AT_INWARD_OFFICE | 205 | Arrival at inward office of exchange |
ARRIVAL_AT_POST_OFFICE | 206 | Arrival at post office |
PREPARE_TRANSIT | 207 | Prepare transit |
ITEM_OUT_FOR_PHYSICAL_DELIVERY | 301 | Item out for physical delivery |
ITEM_ARRIVAL_AT_COLLECTION_POINT | 302 | Item arrival at collection point for pick-up (by recipient) |
UNSUCCESSFUL | 401 | Unsuccessful (physical) delivery |
FINAL_DELIVERY | 501 | Final delivery |
How to use:
from thailandpost_track import StatusCode
StatusCode.ALL
Language
Language of response.
List:
Variables | Description |
---|---|
TH | Thai Language |
EN | English Language |
CN | Chinese Language |
How to use:
from thailandpost_track import Language
Language.EN
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file thailandpost-track-1.0.0.tar.gz
.
File metadata
- Download URL: thailandpost-track-1.0.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86a72548ba02ca1b8cd7d5e564217deb239e3cae2e1d445c5fb0aaff69740bf2 |
|
MD5 | a56123fc617204d3fc3e99f647b14d66 |
|
BLAKE2b-256 | 0c1252caadb644fba2c97af06fc589947546ec6b8caa8875b783d47aab71e193 |