Shopee OpenAPI Handsup ๐
Working as a data engineer at Shopee Express, I was assigned to retrieve a specific shopโs data via Shopee Open Platform (Challenge Accepted ๐)
The Shopee Open Platform is a technical services portal with API offerings, supporting developers in creating Partner Apps that grow sellersโ businesses.
Open Platform has a detailed document here. However, Iโve been struggle with its first-time authentication ๐คง Hence, this article will guide you through:
- Authenticate a shop
- Retrieve token
- Get order list
Letโs Gogogogo ๐๐๐
Authenticate a Shop
Here are steps required to use OpenAPI. By following this guide, we can get an App on Open Platform.
You have a shop, right? We will use the appโs partner id and key, plus the shopโs account and password later.
With the code above, we create an Auth link. Click the link and log in with the shopโs account and password ๐
https://partner.shopeemobile.com/api/v2/shop/auth_partner?partner_id=2xxxxx3&redirect=https://www.google.com/×tamp=1653985317&sign=979xxxx63aaa4
โ If you encounter error showing Invalid timestamp
, it may be caused from:
- We forget to turn timestamp to type
Int
- The link is only valid for 5 minutes. After 5 mins, we need to recreate an auth link with a new timestamp.
โ If you face error showing wrong sign
, please check whether:
- Environment for key, partner_id, and host match (uat, test, or live)
- Timestamp used to create the sign is identical to the one shown in the url.
If things go well, you will be redirect to the magic link (See the code and shop_id? Awesome, thatโs what we want ๐)
https://www.google.com/?code=4e424xxxxxx&shop_id=5xxxxxx9
Retrieve token
With the code, we can get token in this way:
access_token
will only be valid for 4 hours. We can get a new one using refresh_token
afterwards ๐
Get order list
Hooooray ๐ With our access_token
, we are able to retrieve and update the shopโs orders using OpenAPI.
Cool, isnโt it? You can explore other APIs in its document. Authentication might be the hardest part. As soon as you get the token, the rest is merely a piece of ๐ฐ Happy Coding :D