Shopee OpenAPI Handsup ๐Ÿ‘‹

Wendee ๐Ÿ’œ๐Ÿ•
2 min readJun 5, 2022

--

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

Image from OpenAPI

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.

Auth Flow

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/&timestamp=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

--

--

Responses (3)