1
https://shopee.ph/api/v4/search/search_items

主要是想按分类获取Top Sales的商品,看路径好像是和搜索同一个接口。其他参数没去研究,只是简单获取了每个二级分类下的Top 300。爬了266个二级分类,需要配合代理使用。

至于这个接口的其他请求参数和详细返回值字段意思,后续再详细更新。

1
https://shopee.ph/api/v4/search/search_items?by=sales&limit=60&match_id=11021766&newest=0&order=desc&page_type=search&scenario=PAGE_CATEGORY&version=2&view_session_id=c2bb389c-e55a-4d84-9fa9-26bb8c92e8cb

请求参数
match_id:分类id,上个文档有写如何获取分类
limit:最大100,返回条数
newest:相当于offset,页数*页码,从0开始的
view_session_id:可选,加不加无所谓

请求头:
去掉x-sap-access- 相关的,不然无法翻页
af-ac-enc-dat这个一定要的,至于生成方式还没研究,不知道多久会过期。

下面的示例是没带cookie的,需要设置cookie后才能正常返回。每一次请求会返回set-cookie,python的requests库可以自动管理cookie。页面需要登录,直接请求可以绕过登录。

Request

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
curl --location 'https://shopee.ph/api/v4/search/search_items?view_session_id=4bf76288-3a28-4f5d-a5dd-133265350c3f&page_type=search&scenario=PAGE_CATEGORY&by=sales&match_id=11021590&limit=1&newest=0&version=2&order=desc' \
--header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36 Edg/111.0.1661.41' \
--header 'authority: shopee.ph' \
--header 'accept: application/json' \
--header 'accept-language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6' \
--header 'af-ac-enc-dat: AAcyLjcuMS0yAAABhvR9F3sAABCJAyAAAAAAAAAAAhqvdklVrDkVX42dWW8WjwNMVVr2eVtks1BST6eLSS4Vm6Mzx0gD9O1aYGgjmjuYbekv+r87DkrJuhmCcm6qDZoK0tmaBkxL0vQE3VOkX7VY+xipgczoUhKAg6vJXYPkXE5ho+pc0XG8frvsLhQK78fs7www8WJ6JV771K7M3S4Ty2Ncm8vFui5C+Cokhc47s9IEFIsGDUtpEpNSSI0oOt3tagOTHkenEhnNI10zaevKlBjvvsvFui5C+Cokhc47s9IEFIsGDUtpEpNSSI0oOt3tagOTUWJy02xIVh23BkGRTuyWQfap+xOCy0qf6FceYCNc1JRGrbfJWuRYlFp+J0tcUk6vRQg7nCQX6c8aLMHSU1udIlj4f3pW05can3G4luWGcOFGrbfJWuRYlFp+J0tcUk6vgCDxiBpIlUwbzBjpEgESiJf/NhMnw8f21UXD2mkb2Ju/gXBj+hWyduwA/3u9+Lkc0CNfz1xrNOs4FGq3WJKpGeKetqs4i6BswY8fzozHGMYkJJPoyQ1NJpMgU3J9L51CYdTPQJEQ3E4ANa/rBkXkv+1Xae7Hx1gGQX2lWGDGVB3G15ETMomEh+2u21Fve4GTgRPf/it4Xc5dhyDOXdqNBf3DcN8SSRWnzd7ZOPdn3b3vQgEEDSd5FCY58Y0sQjhViqQUxOKs76V60NOqzEpRitz0tffrXWaioR2prDgEM8I7IRDhFgDONH3R79SEr4atabCKtlJXRsuqWnI106fiTR83WRZ1A8uf4ybgV3d2wMzR7aKLnePRlxZXK8uZtotMIKBQIEAkh/C4TWt2KcX/qGOv5glx+5XQdAlsQHUe//7omC9sx4VlzjDZiiU4fFYBT14xBhlstwzFVbpGSg7PtmWfK9jsILoVCesMqoV6xfz45SkSwbH+gUlyZ/VZp+Iv5OXgKafkcpX3A4wQI7TtzsoYfBW0jox0yIRvdIbGmHMhSvsYMlPrYirRCvm7NH4vm8wHeC5EX8z18AePpRWeJ4lFKpq0WQyCGMxSw/gwr2SX/zYTJ8PH9tVFw9ppG9ibA8XMmx7lA1zWkEGMEnBiGw==' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--header 'pragma: no-cache' \
--header 'referer: https://shopee.ph/Tops-cat.11021587.11021590?page=0&sortBy=sales' \
--header 'sec-ch-ua: "Microsoft Edge";v="111", "Not(A:Brand";v="8", "Chromium";v="111"' \
--header 'sec-ch-ua-mobile: ?0' \
--header 'sec-ch-ua-platform: "Windows"' \
--header 'sec-fetch-dest: empty' \
--header 'sec-fetch-mode: cors' \
--header 'sec-fetch-site: same-origin' \
--header 'x-api-source: pc' \
--header 'x-requested-with: XMLHttpRequest' \
--header 'x-shopee-language: en' \
--header 'Host: shopee.ph'

Response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
{
"bff_meta": null,
"error": null,
"error_msg": null,
"reserved_keyword": null,
"suggestion_algorithm": null,
"algorithm": null,
"total_count": 3000,
"nomore": false,
"items": [
{
"item_basic": {
"itemid": 4918259435,
"shopid": 50099473,
"name": "simple active t shirt Men & Women American size Plain Dark color top men s apparel Crew neck Round",
"label_ids": [
29,
1003289,
1013151,
1012150,
1014043,
1400025126,
1004508,
13,
700025246,
1118588,
1400085335,
1143666,
1003284
],
"image": "c9b205ca3224853e84bfe863d68241f5",
"images": [
"c9b205ca3224853e84bfe863d68241f5",
"209d617bd983822eeeffb97b023319cb",
"0226d3c95c6403c8cccec7ab29cd213a",
"87c393d2916c02e312aaf8a76f9a7888",
"67e5e70c5c1b601fcd1910993b50100b",
"38d0f64ec4508878c19c94af7489e5f2",
"10997c0741a9f8f30fcffc315ef2620f",
"6a18d46f6badbbae94b1dae500b3a5b6",
"693c3a0f810781b81f5e4ca02dbbdd27"
],
"currency": "PHP",
"stock": 110636,
"status": 1,
"ctime": 1583058192,
"sold": 12706,
"historical_sold": 244374,
"liked": false,
"liked_count": 1735,
"view_count": null,
"catid": 100011,
"brand": "",
"cmt_count": 5282,
"flag": 0,
"cb_option": 0,
"item_status": "normal",
"price": 5900000,
"price_min": 5900000,
"price_max": 6900000,
"price_min_before_discount": 12800000,
"price_max_before_discount": 12800000,
"hidden_price_display": null,
"price_before_discount": 12800000,
"has_lowest_price_guarantee": true,
"show_discount": 54,
"raw_discount": 54,
"discount": "54%",
"is_category_failed": null,
"size_chart": "",
"video_info_list": [
{
"video_id": "99f5b5de3e455bf402cd0250bddcea87",
"thumb_url": "ff2ee92e11eb2414db6aec2a25d5be7c",
"duration": 20,
"version": 2,
"vid": "sg_1a91eca4-09f4-4a1a-abf4-9558108bee86_000027",
"formats": [],
"default_format": {
"format": 600001,
"defn": "ORI",
"profile": "MP4",
"path": "",
"url": "https://play-ws.vod.shopee.com/c3/98934353/107/YzQsMTM0LTQ0MDEwLDE0MjI4NjU3OTgyNjgwMTg2ODksMg.mp4",
"width": 592,
"height": 1280
}
}
],
"tier_variations": [
{
"name": "ACTIVE T SHIRT",
"options": [
"WHITE",
"BLACK",
"RED",
"YELLOW",
"ROYAL BLUE",
"LIGHT BLUE",
"NEON YELLOW",
"BLUE GRAY"
],
"images": [
"c9b205ca3224853e84bfe863d68241f5",
"67e5e70c5c1b601fcd1910993b50100b",
"38d0f64ec4508878c19c94af7489e5f2",
"10997c0741a9f8f30fcffc315ef2620f",
"6a18d46f6badbbae94b1dae500b3a5b6",
"fdcc96393e9f3682f18d7e1525cdb001",
"59acc5093766b95bba47535f78f1ff62",
"sg-11134201-23020-c1uy7wbre0mvb8"
],
"properties": [],
"type": 0
},
{
"name": "American SIZE",
"options": [
"XS",
"S",
"M",
"L",
"XL",
"XXL"
],
"images": null,
"properties": [],
"type": 0
}
],
"item_rating": {
"rating_star": 4.831018078020932,
"rating_count": [
5282,
79,
35,
115,
245,
4808
],
"rcount_with_context": 914,
"rcount_with_image": 537
},
"item_type": 0,
"reference_item_id": "",
"transparent_background_image": "d85b26c141a380f5c8d5a46ff7a64abe",
"is_adult": false,
"badge_icon_type": 0,
"shopee_verified": false,
"is_official_shop": false,
"show_official_shop_label": false,
"show_shopee_verified_label": false,
"show_official_shop_label_in_title": false,
"is_cc_installment_payment_eligible": false,
"is_non_cc_installment_payment_eligible": false,
"coin_earn_label": null,
"show_free_shipping": false,
"preview_info": null,
"coin_info": null,
"exclusive_price_info": null,
"bundle_deal_id": 0,
"can_use_bundle_deal": false,
"bundle_deal_info": null,
"is_group_buy_item": null,
"has_group_buy_stock": null,
"group_buy_info": null,
"welcome_package_type": 0,
"welcome_package_info": null,
"add_on_deal_info": null,
"can_use_wholesale": true,
"is_preferred_plus_seller": false,
"shop_location": "Valenzuela City, Metro Manila",
"has_model_with_available_shopee_stock": false,
"voucher_info": null,
"can_use_cod": false,
"is_on_flash_sale": false,
"spl_installment_tenure": null,
"is_live_streaming_price": null,
"is_mart": false,
"pack_size": null,
"deep_discount_skin": {
"skin_id": 0,
"start_time": 0,
"end_time": 0,
"skin_data": {
"promo_label": {
"promotion_price": "₱ 47",
"hidden_promotion_price": "₱ ?7",
"text": null,
"start_time": 1679846400,
"end_time": 1679932740
}
}
},
"is_service_by_shopee": false,
"spl_repayment_label_repayment": null,
"spl_repayment_label_text": null,
"highlight_video": null,
"free_shipping_info": null
},
"adsid": null,
"campaignid": null,
"distance": null,
"match_type": null,
"ads_keyword": null,
"deduction_info": null,
"collection_id": null,
"display_name": null,
"campaign_stock": null,
"json_data": "ogaWAQqTAWJmZi1zZWFyY2hfcGhfc2c5XzEwLjE2OC43My4xMzRfezFmOGExYjg0Zjc4OGYyODQ5MjQxNGEzNzVlMjgwZTAwOjAyMDAwMDIyMmY2YzE1OTc6MDEwMDAwYWQ1Nzk2ZGVmOH1fazhzLXdvcmtlci1zZzktbGl2ZS0xNzg4MDEwMzAuc2hvcGVlbW9iaWxlLmNvbQ==",
"tracking_info": {
"viral_spu_tracking": null,
"business_tracking": null,
"multi_search_tracking": null,
"groupid": 0,
"ruleid": [
0
]
},
"itemid": 4918259435,
"shopid": 50099473,
"algo_image": null,
"fe_flags": null,
"item_type": 1,
"foody_item": null,
"search_item_tracking": "{\"is_ads\":false,\"ruleids\":[0],\"groupid\":0,\"item_type\":1,\"biz_json\":\"\",\"merge_rank\":0,\"matched_keywords\":[\"\"]}",
"bff_item_tracking": "{\"label_ids\":[29,1003289,1013151,1012150,1014043,1400025126,1004508,13,700025246,1118588,1400085335,1143666,1003284],\"is_on_flash_sale\":false,\"is_liked\":false,\"with_video\":true,\"is_dp_mirror_sku\":false,\"image_position\":null,\"image_id\":\"c9b205ca3224853e84bfe863d68241f5\"}",
"personalized_labels": null,
"biz_json": null,
"creative_image_id": null,
"creative_id": null,
"creative_id_int": null
}
],
"price_adjust": null,
"adjust": {
"count": 3000
},
"total_ads_count": 0,
"hint_keywords": null,
"show_disclaimer": false,
"json_data": "",
"query_rewrite": {
"fe_query_write_status": 0,
"rewrite_keyword": null,
"hint_keywords": null,
"ori_keyword": "",
"ori_total_count": 3000,
"rewrite_type": null
},
"disclaimer_infos": [],
"need_next_search": true,
"low_result": null,
"autoplay_info": null,
"food_item_info": {
"total_count": 0
},
"search_tracking": "{\"algorithm\":\"\",\"ab_sign\":[30977,29835,29850,30433,29698,32497],\"low_result\":null,\"total_ads_count\":0,\"total_count\":3000,\"query_expansion_info\":null,\"request_id\":\"bff-search_ph_sg9_10.168.73.134_{1f8a1b84f788f28492414a375e280e00:020000222f6c1597:010000ad5796def8}_k8s-worker-sg9-live-178801030.shopeemobile.com\",\"user_type\":[99],\"version_tracking\":\"{\\\"search_server\\\":\\\"{\\\\\\\"Code\\\\\\\":\\\\\\\"origin/release_0321_1100\\\\\\\",\\\\\\\"Config\\\\\\\":\\\\\\\"others=default;\\\\\\\"}\\\",\\\"es_proxy\\\":\\\"{\\\\\\\"Code\\\\\\\":\\\\\\\"769fc76\\\\\\\",\\\\\\\"Config\\\\\\\":\\\\\\\"others=default;\\\\\\\"}\\\"}\",\"is_censor\":false}",
"search_sessionid": null,
"batch_size": 1,
"search_item_bff_tracking": "{\"ab_test_sign\":\"0.a.9457@HX0UW26\",\"version_tracking\":\"{\\\"Code\\\":\\\"f45dce0\\\",\\\"Config\\\":\\\"m_cnf=52;others=default;\\\"}\",\"cached_result\":null,\"response_time\":1679542439973}",
"user_info": {
"user_type": [
99
]
},
"request_id": "bff-search_ph_sg9_10.168.73.134_{1f8a1b84f788f28492414a375e280e00:020000222f6c1597:010000ad5796def8}_k8s-worker-sg9-live-178801030.shopeemobile.com",
"cached_result": null,
"experiments": [
{
"key": "sch.user_feedback_in_srp_bff",
"value": "0"
}
],
"item_extra_config": "{\"lowest_discount_price\":100000,\"discount_price_gap\":50000000000}"
}