CH Post Track is an React app made to track your parcels
- React (PrimeReact, Bootstrap, Axios)
- Php
- Login / Token login
- Register
- Add/Update/Remove parcels
- Show parcels status
You will need a server that supports php and authorize the file_get_contents function
git clone "https://github.com/YungBricoCoop/ch-post-track.git"
# Transfer the "backend" folder to your server
# Edit the file "frontend/src/config/api.js" to point the links to your server
cd ch-post-track/frontend
npm i
npm start
To get the event list of a parcel you have to make several requests to the Post API. Since it is not possible from the frontend because of cores we will do it from the backend. however we will need to save the cookies/x-csrf-token to use them in requests
Endpoint : https://service.post.ch/ekp-web/api/
sequenceDiagram
Php Backend->> Service.post.ch: GetUser (GET : /user)
Service.post.ch-->>Php Backend: body = [userIdentifier], headers = [cookie,x-csrf-token]
Note right of Php Backend: Here we get the userId <br>And capture the Cookie/X-CSRF-TOKEN (mandatory to send the next requests)
Php Backend->> Service.post.ch: GetHash(POST : /history?userId={userId}) <br> body = ["searchQuery" : trackingNumber], headers = [cookie,x-csrf-token])
Service.post.ch-->>Php Backend: body = [hash]
Php Backend->> Service.post.ch: getIdentity(GET : /history/not-included/{hash}?userId={userId}) <br> headers = [cookie,x-csrf-token])
Service.post.ch-->>Php Backend: body = [identity]
Php Backend->> Service.post.ch: getIdentity(GET : /shipment/id/{identity}/events/ <br> headers = [cookie,x-csrf-token])
Service.post.ch-->>Php Backend: body = [events]