Skip to content

Conversation

@avg-nikki
Copy link

@avg-nikki avg-nikki commented Jan 16, 2025

Specifically, add support for:

  • CDEK
  • Russian Post
  • 5post
  • Cainiao (AliExpress Shipping, done by someone else. Thanks!)

We'll see how that goes.
Wish me luck, I'm drunk as fuck

@avg-nikki
Copy link
Author

Going to start with Cainiao, I guess (there's 7 active parcels coming my way through Cainiao, sooo)

First thing to note is that Cainiao forces a captcha if the server the user using the app happens to be on is overloaded.
image

That is an obstacle, and the only ways to solve it are:

  1. Wait for the server load to drop
  2. Ask the user to complete a captcha

2nd is the best option for me, however that'd mean implementing some sort of a pop-up window. It'd be best to have a method with a URL as an argument in the DeliveryService class to show a pop-up window. However, this would create an issue where if that happens when the app is fetching data in the background, we would be unable to show that pop-up to the user due to restrictions from NotificationWorker (duh).

A possible solution is to send a notification, requesting the user to complete a captcha in-app, even though this is not the best either. I'll see if it's actually worth implementing later when testing, however that function might help out later on with other postal services.

@avg-nikki
Copy link
Author

A GET request sent to https://global.cainiao.com/global/detail.json with one query parameter mailNos set to the shipment ID returns a big chunk of data.

image

Most important of it is $.module[0].detailList: it is an array, which houses the details of each shipment status change.

Values to note:

  • time: A Unix timestamp, in milliseconds, when the status was changed;
  • standardDesc: A human-readable description of the current status, (sometimes) including the current location of the parcel within China;
  • $.group.nodeDesc: Shows the current shipment status (In transit, etc.)

@itsvic-dev
Copy link
Owner

itsvic-dev commented Jan 16, 2025

$.group is not always available!! and we shouldn't use it anyways because it will differ between locales and Parcel uses its own status enum to denote parcel status

@avg-nikki
Copy link
Author

$.group is not always available!! and we shouldn't use it anyways because it will differ between locales and Parcel uses its own status enum to denote parcel status

Fair point! I'll see more into it later then.

@avg-nikki
Copy link
Author

  • standardDesc: A human-readable description... (jump)

image
Sorry, meant to say standErd 😂

@avg-nikki
Copy link
Author

Cainiao support is in! There's more to be done, however it's everything I could do right now. Going to play the waiting game until I see more stuff happen with my own parcels.
image

@avg-nikki
Copy link
Author

More about the API:
Each status change event has an actionCode property. Here's everything I know about it so far:

  • PU_PICKUP_SUCCESS: Received by Cainiao, waiting to be shipped;
  • SC_INBOUND_SUCCESS: Arrived at a sorting center, sorting;
  • SC_OUTBOUND_SUCCESS: Left the sorting center it was at, in transit again;
  • CW_INBOUND: The parcel arrived at a warehouse, or it was received by a warehouse. It's weird, because it can get triggered twice, so keep that in mind;
  • LH_HO_IN_SUCCESS: Arrived at a departure transport hub, I guess the parcel is now waiting to be shipped to its destination country.

@avg-nikki
Copy link
Author

^^ Resolved a merge conflict due to Belpost being added

@avg-nikki
Copy link
Author

So, 5post. The website does use a fairly simple API, however it requires ReCAPTCHA (urgh fml).
image

This isn't going to work for us, so I'm going to dig into their mobile app, maybe that uses a different API, which wouldn't require a ReCAPTCHA response.

@avg-nikki
Copy link
Author

...so I'm going to dig into their mobile app, maybe that uses a different API, which wouldn't require a ReCAPTCHA response.

...And I was right!
Base URL: https://api-omni.x5.ru/five-post-mobile-api/v3/mobile/

  • GET order-tracking/{trackId}/orders: Returns an array, supposedly with parcel data (I don't have any active 5post parcels atm, so we'll see exactly what it returns in a few days);
  • GET order-statuses?view=ALL: Returns an array of JSON objects, each consists of two properties: status and statusLocalized. As you may guess, status is the status code for an event, and statusLocalized is that status code, but in a human-readable format (in Russian).

This is a really nice find, and it'll help out A LOT.

@avg-nikki avg-nikki changed the title WIP: Add support for multiple delivery services (Russia, Asia) WIP: Add support for multiple delivery services (Russia) Sep 29, 2025
@avg-nikki
Copy link
Author

been a while huh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants