avatarWendee 💜🍕

Summary

The website content outlines a data engineer's experience and guidance on using the Shopee OpenAPI, detailing the authentication process, token retrieval, and how to get an order list for a specific shop.

Abstract

The article is a technical guide written by a data engineer at Shopee Express, who shares their experience in accessing a shop's data through the Shopee Open Platform. The author describes the challenges faced during the first-time authentication process and provides a step-by-step walkthrough on how to authenticate a shop, retrieve the necessary token, and obtain an order list using the OpenAPI. The guide includes code snippets and troubleshooting tips for common errors such as invalid timestamps and incorrect signatures. The author emphasizes that while authentication can be tricky, once the token is obtained, the rest of the API interactions are straightforward, encouraging users to explore the full range of API offerings for further development.

Opinions

  • The author acknowledges the Shopee Open Platform as a comprehensive resource for developers to create apps that support sellers' businesses.
  • There is an admission of personal struggle with the initial authentication on the Open Platform, indicating that this might be a common issue among new users.
  • The guide is presented with enthusiasm, as seen in phrases like "Challenge Accepted" and "Let's Gogogogo," suggesting a proactive and positive approach to problem-solving.
  • The author provides practical advice, such as the need to ensure the timestamp is an integer and that the authentication link is used within 5 minutes.
  • There is a hint of frustration conveyed through the emoji use (e.g., 🤧) when discussing the authentication challenges, but overall, the tone is optimistic and supportive.
  • The author seems to take pride in overcoming the authentication hurdles, as indicated by the celebratory language used when the process is successful (e.g., "Hooooray 🎊").
  • The guide concludes with a reassuring and motivational message, suggesting that with perseverance, developers can master the OpenAPI and enjoy the process of building applications with it.

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

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

Shopee
Open Api Platform
Auth
Recommended from ReadMedium