Shopee may not have a great deal of recognition in the West, but they’re one of the biggest online retailers in Southeast Asia. By connecting sellers and buyers directly, it’s offering more direct avenues for transactions, and that’s earned Shopee attention in Latin America as well.
And while Shopee doesn’t have its own proprietary API, Data Scraper’s alternative comes with all the fundamental functionality you’d hope for from a retail-based API. This API offers a diverse selection of endpoints, and it can be easily implemented into an existing platform with PHP, Python, Ruby, or JavaScript.
Connect to the Shopee API Free
What is the Shopee API?
Shopee is a digital platform that allows individual retailers to each establish their own digital storefronts. Each of these storefronts is assigned a domain based on their regional market along with a trailing code that’s unique to their storefront. This organizational system serves as the basis for all of the search and filtering that Shopee has built into their platform.
This API takes advantage of that core organizational structure in a way that lets you search for results with far more precision. The most basic queries from this API simply require a regional domain, but other endpoints allow you to filter very particular information based on a shop’s unique ID.
How Does the Shopee API Work?
This API takes advantage of the existing infrastructure of the Shopee site to create a formal system for users to place requests. Since the structure of the site is formal, the results are a programmatic way to request information directly from that source server.
Since this is a third-party API built to work in conjunction with Shopee, you can read data and manipulate it locally, but you won’t be making changes to the source data. This process is typically known as data scraping, and it’s often used to help provide analysis for readily available resources that don’t have proprietary API pipelines for the average user.
Who is This API For?
The breadth of endpoints utilized by the Shopee API lends is an equally diverse variety of use cases.
Shop Owners: This API provides a method shop owners can use to evaluate the competition. It can be used to check out the pricing and inventory of competitors offering similar products or for more sophisticated analysis like which keywords are trending in the region or what promotions a specific retailer is employing.
Consumers: Many of the endpoints in this API simulate the same filter and search options you’ll find on the Shopee site, but the endpoints can be used to track pricing on specific products so you can get the best deal. Savvy shoppers can even use it to narrow down results when shopping for the right model.
Product Reviewers: The product- and genre-specific endpoints utilized by this API can offer a strong leg-up for reviewers researching products. The information it scrapes can provide insight both into consumer reviews and into the practical specs listed for a product.
How to Connect to the Shopee API – (Step by Step
Step One: Register or Log In at RapidAPI
A basic account with RapidAPI is free, and you can sign up using your existing email, GitHub, Facebook, or Google account.
Step Two: Subscribe to the API
Navigate to the Shopee API’s entry at RapidAPI and then click on the pricing tab. Fortunately, there’s a free option available for this API. Choosing this will allow you to get up to 100 free API calls per month.
Step Three: Test the API Endpoints
Go to the Endpoints tab underneath the Shopee API page, and pick the endpoint that you’re looking to test. Each endpoint will provide you with a sample request and response, but you can enter your own by adding your own parameter entries and clicking on the Test Endpoint button.
The following lists the top 40 category filters that apply to a keyword search for “Samsung”. Note that it display a status error of “200”. That indicates that the API request you made was fully successful. In all of the cases, you’ll want to replace the x-rapidapi-key
placeholder in the code with your existing RapidAPI API key.
Step Four: Integrate it With Your Platform
Requests can be handled directly through the RapidAPI interface, but you’ll want to integrate them into a functional code base if you want to really make the most of the API. The endpoint tab translates code snippets for most major programming languages, and you can simply copy and paste them into your existing app.
We’ll cover how to work with some of the most popular languages below. We’ll use the same endpoint, request, and response we used in step three for the sake of consistency.
How to Use the Shopee API with Python
Installing Python and creating a Python app is outside the purview of this article, but once you have everything up and running, you’ll have a couple of options for integrating this API. Fortunately, all three use slightly different protocols to produce familiar results. You can choose the one that works for you, but keep in mind that you’ll want to install the Request dependency if you’re using that.
with an HttpClient/Unirest:
With Request:
How to Use the Shopee API with PHP
The most effective way to incorporate this API into a PHP app is to use a combination of cUrl and Request. Make sure that you have PHP on your computer and install both dependencies.
How to Use the API with Ruby
If you’re looking to create a more complicated API app, you’ll probably want to install Ruby on Rails. The rails generator helps you develop the structure of your API with little experience. But regardless of which version of Ruby you use, code can be integrated easily with Unirest protocol.
How to Use the API with JavaScript
JavaScript offers what’s arguably the most straightforward method for making an API request through its fetch method which uses very simple requests to produce results.
If you’d prefer, RapidAPI also offers code that uses the jQuery model.
Shopee API Endpoints
This API comes with 19 endpoints. Since it’s a third-party app that gets all of its info from data scraping, you’ll only find endpoints that use the GET request. We can split these endpoints up into a few different categories depending on the information you need to make a request.
Root Endpoints
Root endpoints simply require you to know the domain name for your region. Naturally, the requests and responses tend to be generically related to Shopee’s operations rather than those of a specific storefront.
shipping-locations
returns both the states and cities within a Shopee domain’s country of origin. City names are stored as arrays linked to state names.get-filters
provides more technical metadata, specifically listing out the brand, category, location, and shipping filters used to further organize shipping for a regional Shopee domain.keyword-suggestions
will return the keyword suggestions for a search request.search returns
all of the relevant metadata for products that match your keyword search request.
Category Endpoints
Category endpoints require a domain and may or may not require the ID for a category you want to explore. Categories are unique to each domain.
list-main-categories
returns all of a domain’s primary categories.list-all-categories
returns all minor and major categories in a domain.list-official-shops
takes a category ID and returns all of the sanctioned shops listed in that category.list-items
returns all items tied to particular category ID.get-filters
works as above but can be applied to a specific category ID.
Shop Endpoints
Shop endpoints take a specific domain and shop ID to return information on a specific retailer.
list-categories
produces all of the categories the retailer uses in their shop.list-items
will return all of the items available through a storefront.
Item Endpoints
Item endpoints offer queries on specific items, and they require shop and product IDs in addition to a domain.
ratings
gets you all of the user review information for a specific retailer’s productshippings
produces all of the shipping and delivery options for a productvouchers
returns any discount information available for a productdetail
is the endpoint to use if you want all the relevant information for a product
Flash Sale Endpoints
Flash sale endpoints only require a domain, as they offer relevant information on domain-specific sales that are part of the Shopee model.
current-sessions
produces generally information on currently ongoing flash sales.list-items
returns information on all of the items in a given flash sale, but it requires the promotion_id from the sale in question.Miscellaneous Endpoints
There are a couple of loose endpoints that don’t fit comfortably in any other caty.
user-info
requires a username (not a user ID) and provides all the relevant information on a customer or shop owner.
trending-keywords
only requires a domain entry. It will list the most common keywords from that domain in order of popularity.
What are the Benefits of the Shopee API?
While this API isn’t officially produced by Shopee, the thoroughness of the data scraping it offers means that there’s a request for practically any available information you could need. Setting up the API is easy, and the requests themselves are very straightforward.
But the biggest advantage of this API is its breadth. Shopee has domains in eight different regions, and the API offers insight into all of them. And the universality of their site structure across these domains means the basic principles should continue to apply as Shopee expands to new markets.
Summary
Shopee’s API is as thorough a resource as you’ll find for getting information on Shopee’s operations, and it’s fortunately very flexible to work with. No matter what coding language you’re most comfortable with, you should be able to easily integrate this API into your existing app infrastructure.
Leave a Reply