goofish-api 0.0.3__tar.gz → 0.0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. goofish_api-0.0.5/PKG-INFO +411 -0
  2. goofish_api-0.0.5/README.md +400 -0
  3. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/__init__.py +2 -2
  4. goofish_api-0.0.5/goofish_api/__version__.py +1 -0
  5. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/api/good.py +8 -6
  6. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/api/order.py +4 -3
  7. goofish_api-0.0.5/goofish_api.egg-info/PKG-INFO +411 -0
  8. goofish_api-0.0.3/PKG-INFO +0 -31
  9. goofish_api-0.0.3/README.md +0 -20
  10. goofish_api-0.0.3/goofish_api/__version__.py +0 -1
  11. goofish_api-0.0.3/goofish_api.egg-info/PKG-INFO +0 -31
  12. {goofish_api-0.0.3 → goofish_api-0.0.5}/LICENSE +0 -0
  13. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/api/__init__.py +0 -0
  14. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/api/base.py +0 -0
  15. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/api/other.py +0 -0
  16. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/api/user.py +0 -0
  17. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/utils/__init__.py +0 -0
  18. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/utils/api_response.py +0 -0
  19. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/utils/base_client.py +0 -0
  20. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/utils/constants.py +0 -0
  21. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api/utils/helpers.py +0 -0
  22. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api.egg-info/SOURCES.txt +0 -0
  23. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api.egg-info/dependency_links.txt +0 -0
  24. {goofish_api-0.0.3 → goofish_api-0.0.5}/goofish_api.egg-info/top_level.txt +0 -0
  25. {goofish_api-0.0.3 → goofish_api-0.0.5}/setup.cfg +0 -0
  26. {goofish_api-0.0.3 → goofish_api-0.0.5}/setup.py +0 -0
@@ -0,0 +1,411 @@
1
+ Metadata-Version: 2.1
2
+ Name: goofish_api
3
+ Version: 0.0.5
4
+ Summary: Python wrapper for the goofish API
5
+ Home-page: https://github.com/xie7654/goofish_api
6
+ Author: XIE JUN
7
+ Author-email: xie765462425@gmail.com
8
+ License: MIT
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+
12
+ # Goofish API Python SDK
13
+
14
+ [![Python Version](https://img.shields.io/badge/python-3.7+-blue.svg)](https://python.org)
15
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
16
+
17
+ Goofish API Python SDK 是一个用于闲鱼开放平台的Python客户端库,提供了完整的API封装,支持商品管理、订单处理、用户授权等功能。
18
+
19
+ ## 功能特性
20
+
21
+ - 🚀 **完整的API覆盖** - 支持闲鱼开放平台的所有主要API
22
+ - 🔐 **自动签名验证** - 内置MD5签名算法,无需手动处理
23
+ - 📦 **模块化设计** - 按功能模块组织代码,易于使用和维护
24
+ - 🛡️ **类型安全** - 使用枚举类型确保参数正确性
25
+ - 📝 **详细文档** - 每个API都有详细的参数说明和示例
26
+
27
+ ## 支持的API模块
28
+
29
+ - **用户模块** - 店铺授权管理
30
+ - **商品模块** - 商品CRUD操作、类目管理、属性查询
31
+ - **订单模块** - 订单查询、发货处理、卡密管理
32
+ - **其他模块** - 快递公司查询等
33
+
34
+ ## 安装
35
+
36
+ ### 从PyPI安装
37
+
38
+ ```bash
39
+ pip install goofish-api
40
+ ```
41
+
42
+ ## 依赖要求
43
+
44
+ - Python 3.7+
45
+ - requests >= 2.26.0
46
+ - python-dotenv >= 0.20.0
47
+
48
+ ## 快速开始
49
+ ### 1. 基本使用
50
+
51
+ ```python
52
+ from goofish_api import GoofishClient
53
+
54
+ APP_KEY = ''
55
+ APP_SECRET = ''
56
+ # 初始化客户端
57
+ client = GoofishClient(
58
+ app_key=APP_KEY,
59
+ app_secret=APP_SECRET
60
+ )
61
+
62
+
63
+ # 查询授权店铺
64
+ response = client.user.get_authorize_list()
65
+ print(response)
66
+ ```
67
+
68
+ ## API 使用示例
69
+
70
+ ### 用户模块
71
+
72
+ #### 查询授权店铺
73
+
74
+ ```python
75
+ # 获取已授权的闲鱼店铺列表
76
+ response = client.user.get_authorize_list()
77
+ print(response)
78
+ ```
79
+
80
+ ### 商品模块
81
+
82
+ #### 查询商品类目
83
+
84
+ ```python
85
+ from goofish_api.utils.constants import ItemBizType, SpBizType
86
+
87
+ # 查询普通商品的手机类目
88
+ response = client.good.get_product_category_list(
89
+ item_biz_type=ItemBizType.COMMON,
90
+ sp_biz_type=SpBizType.MOBILE
91
+ )
92
+ print(response)
93
+ ```
94
+
95
+ #### 查询商品属性
96
+
97
+ ```python
98
+ # 查询指定类目的商品属性
99
+ response = client.good.get_product_pv_list(
100
+ item_biz_type=ItemBizType.COMMON,
101
+ sp_biz_type=SpBizType.MOBILE,
102
+ channel_cat_id="4d8b31d719602249ac899d2620c5df2b"
103
+ )
104
+ print(response)
105
+ ```
106
+
107
+ #### 查询商品列表
108
+
109
+ ```python
110
+ from goofish_api.utils.constants import ProductStatus, SaleStatus
111
+
112
+ # 查询销售中的商品
113
+ response = client.good.get_product_list(
114
+ product_status=ProductStatus.STATUS_21,
115
+ sale_status=SaleStatus.ON_SALE,
116
+ page_no=1,
117
+ page_size=20
118
+ )
119
+ print(response)
120
+ ```
121
+
122
+ #### 查询商品详情
123
+
124
+ ```python
125
+ # 根据商品ID查询详情
126
+ response = client.good.get_product_detail(product_id=1234567890)
127
+ print(response)
128
+ ```
129
+
130
+ #### 创建商品
131
+
132
+ ```python
133
+ # 创建单个商品
134
+ product_data = {
135
+ "item_biz_type": 2,
136
+ "sp_biz_type": 1,
137
+ "channel_cat_id": "e11455b218c06e7ae10cfa39bf43dc0f",
138
+ "channel_pv": [
139
+ {
140
+ "property_id": "b5e5462c028aba7f1921b9e373cead75",
141
+ "property_name": "交易形式",
142
+ "value_id": "8a3445658e0bc44687b43d68bdc44732",
143
+ "value_name": "代下单"
144
+ }
145
+ ],
146
+ "price": 550000, # 价格(分)
147
+ "original_price": 700000,
148
+ "express_fee": 10,
149
+ "stock": 10,
150
+ "outer_id": "2021110112345",
151
+ "stuff_status": 100,
152
+ "publish_shop": [
153
+ {
154
+ "images": ["https://example.com/image1.jpg"],
155
+ "user_name": "闲鱼会员名",
156
+ "province": 130000,
157
+ "city": 130100,
158
+ "district": 130101,
159
+ "title": "商品标题",
160
+ "content": "商品描述",
161
+ "service_support": "SDR"
162
+ }
163
+ ]
164
+ }
165
+
166
+ response = client.good.create_product(product_data=product_data)
167
+ print(response)
168
+ ```
169
+
170
+ #### 批量创建商品
171
+
172
+ ```python
173
+ # 批量创建商品
174
+ product_list = [product_data1, product_data2, product_data3]
175
+ response = client.good.product_batch_create(product_data=product_list)
176
+ print(response)
177
+ ```
178
+
179
+ #### 发布商品
180
+
181
+ ```python
182
+ # 发布商品到闲鱼
183
+ response = client.good.product_publish(
184
+ product_id=1234567890,
185
+ user_name=["闲鱼会员名1", "闲鱼会员名2"]
186
+ )
187
+ print(response)
188
+ ```
189
+
190
+ #### 下架商品
191
+
192
+ ```python
193
+ # 下架商品
194
+ response = client.good.product_down_shelf(product_id=1234567890)
195
+ print(response)
196
+ ```
197
+
198
+ #### 编辑商品
199
+
200
+ ```python
201
+ # 编辑商品信息
202
+ edit_data = {
203
+ "product_id": 1234567890,
204
+ "title": "新的商品标题",
205
+ "price": 600000,
206
+ "stock": 20
207
+ }
208
+ response = client.good.product_edit(product_data=edit_data)
209
+ print(response)
210
+ ```
211
+
212
+ #### 修改库存
213
+
214
+ ```python
215
+ # 修改商品库存和价格
216
+ response = client.good.product_edit_stock(
217
+ product_id=1234567890,
218
+ price=600000,
219
+ stock=15
220
+ )
221
+ print(response)
222
+ ```
223
+
224
+ #### 删除商品
225
+
226
+ ```python
227
+ # 删除商品
228
+ response = client.good.product_delete(product_id=1234567890)
229
+ print(response)
230
+ ```
231
+
232
+ ### 订单模块
233
+
234
+ #### 查询订单列表
235
+
236
+ ```python
237
+ from goofish_api.utils.constants import OrderStatus, RefundStatus
238
+
239
+ # 查询待发货订单
240
+ response = client.order.get_order_list(
241
+ order_status=OrderStatus.PENDING_SHIPMENT,
242
+ page_no=1,
243
+ page_size=20
244
+ )
245
+ print(response)
246
+ ```
247
+
248
+ #### 查询订单详情
249
+
250
+ ```python
251
+ # 根据订单号查询详情
252
+ response = client.order.get_order_detail(order_no="1339920336328048683")
253
+ print(response)
254
+ ```
255
+
256
+ #### 查询订单卡密
257
+
258
+ ```python
259
+ # 查询订单的卡密信息
260
+ response = client.order.kam_order_list(order_no="1339920336328048683")
261
+ print(response)
262
+ ```
263
+
264
+ #### 订单发货
265
+
266
+ ```python
267
+ # 订单物流发货
268
+ response = client.order.order_ship(
269
+ order_no="1339920336328048683",
270
+ ship_name="张三",
271
+ ship_mobile="13800138000",
272
+ ship_district_id=440305,
273
+ ship_prov_name="广东省",
274
+ ship_city_name="深圳市",
275
+ ship_area_name="南山区",
276
+ waybill_no="25051016899982",
277
+ express_name="其他",
278
+ express_code="qita"
279
+ )
280
+ print(response)
281
+ ```
282
+
283
+ ### 其他模块
284
+
285
+ #### 查询快递公司
286
+
287
+ ```python
288
+ # 获取支持的快递公司列表
289
+ response = client.other.get_express_companies()
290
+ print(response)
291
+ ```
292
+
293
+ ## 常量枚举
294
+
295
+ SDK提供了丰富的枚举类型,确保API调用的参数正确性:
296
+
297
+ ### 商品类型 (ItemBizType)
298
+
299
+ ```python
300
+ from goofish_api.utils.constants import ItemBizType
301
+
302
+ ItemBizType.COMMON # 普通商品
303
+ ItemBizType.INSPECTED # 已验货
304
+ ItemBizType.INSPECTION_BAO # 验货宝
305
+ ItemBizType.BRAND_AUTH # 品牌授权
306
+ ItemBizType.XIAN_YU_SELECTED # 闲鱼严选
307
+ ItemBizType.XIAN_YU_FLASH # 闲鱼特卖
308
+ ItemBizType.BRAND_PICK # 品牌捡漏
309
+ ```
310
+
311
+ ### 行业类型 (SpBizType)
312
+
313
+ ```python
314
+ from goofish_api.utils.constants import SpBizType
315
+
316
+ SpBizType.MOBILE # 手机
317
+ SpBizType.TREND # 潮品
318
+ SpBizType.HOME_APPLIANCE # 家电
319
+ SpBizType.DIGITAL # 3C数码
320
+ SpBizType.LUXURY # 奢品
321
+ SpBizType.MATERNAL # 母婴
322
+ SpBizType.BEAUTY # 美妆个护
323
+ # ... 更多类型
324
+ ```
325
+
326
+ ### 订单状态 (OrderStatus)
327
+
328
+ ```python
329
+ from goofish_api.utils.constants import OrderStatus
330
+
331
+ OrderStatus.PENDING_PAYMENT # 待付款
332
+ OrderStatus.PENDING_SHIPMENT # 待发货
333
+ OrderStatus.SHIPPED # 已发货
334
+ OrderStatus.TRANSACTION_SUCCESS # 交易成功
335
+ OrderStatus.REFUNDED # 已退款
336
+ OrderStatus.TRANSACTION_CLOSED # 交易关闭
337
+ ```
338
+
339
+ ### 退款状态 (RefundStatus)
340
+
341
+ ```python
342
+ from goofish_api.utils.constants import RefundStatus
343
+
344
+ RefundStatus.NOT_APPLIED # 未申请退款
345
+ RefundStatus.PENDING_SELLER_APPROVAL # 待商家处理
346
+ RefundStatus.PENDING_BUYER_RETURN # 待买家退货
347
+ RefundStatus.PENDING_SELLER_RECEIVE # 待商家收货
348
+ RefundStatus.REFUND_CLOSED # 退款关闭
349
+ RefundStatus.REFUND_SUCCESS # 退款成功
350
+ RefundStatus.REFUND_REJECTED # 已拒绝退款
351
+ RefundStatus.PENDING_RETURN_ADDRESS_CONFIRMATION # 待确认退货地址
352
+ ```
353
+
354
+ ## 错误处理
355
+
356
+ SDK会自动处理API响应,返回统一的响应格式:
357
+
358
+ ```python
359
+ response = client.user.get_authorize_list()
360
+
361
+ if response.success:
362
+ print("请求成功:", response.data)
363
+ else:
364
+ print("请求失败:", response.message)
365
+ print("错误代码:", response.code)
366
+ ```
367
+
368
+ ## 调试模式
369
+
370
+ 启用调试模式可以查看详细的请求和响应信息:
371
+
372
+ ```python
373
+ client = GoofishClient(
374
+ app_key="your_app_key",
375
+ app_secret="your_app_secret",
376
+ debug=True # 启用调试模式
377
+ )
378
+ ```
379
+
380
+ ## 测试示例
381
+
382
+ 项目包含完整的测试示例,位于 `test/` 目录:
383
+
384
+ ```bash
385
+ # 运行测试
386
+ cd test
387
+ python go.py
388
+ ```
389
+
390
+ ## 贡献
391
+
392
+ 欢迎提交Issue和Pull Request来改进这个项目。
393
+
394
+ ## 许可证
395
+
396
+ 本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。
397
+
398
+ ## 作者
399
+
400
+ - **XIE JUN** - [xie7654](https://github.com/xie7654)
401
+ - 邮箱: xie765462425@gmail.com
402
+
403
+ ## 相关链接
404
+
405
+ - [闲鱼开放平台文档](https://open.goofish.pro)
406
+ - [GitHub 仓库](https://github.com/xie7654/goofish_api)
407
+ - [PyPI 包](https://pypi.org/project/goofish-api/)
408
+
409
+ ---
410
+
411
+ 如有问题或建议,请通过GitHub Issues联系我们。或qq:765462425 wx:JUN765462425