# ozon-uploader **Repository Path**: alenzhai/ozon-uploader ## Basic Information - **Project Name**: ozon-uploader - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-08 - **Last Updated**: 2026-03-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Ozon 商品上传工具 通过 Ozon API 上传商品到 Ozon 俄罗斯电商平台。 ## 快速开始 ### 1. 获取 API 凭证 登录 Ozon 卖家后台:https://seller.ozon.ru/ 1. 进入 **Settings** → **API keys** 2. 点击 **Create new key** 3. 选择权限(至少需要 Products 相关权限) 4. 记录 **Client ID** 和 **API Key** ### 2. 配置 **⚠️ 注意**:`config.json` 包含敏感信息,不会被提交到 Git 仓库。 复制配置文件并填入你的凭证: ```bash cd ozon-uploader cp config.example.json config.json ``` 编辑 `config.json`: ```json { "client_id": "你的 Client ID", "api_key": "你的 API Key", "sandbox": true } ``` > **建议**:先用沙箱模式(`sandbox: true`)测试,确认无误后再切换到正式环境。 ### 3. 安装依赖 ```bash pip install requests ``` ### 4. 运行 ```bash python ozon_uploader.py ``` ## 使用方法 ### 创建商品 ```python from ozon_uploader import OzonAPI, OzonProduct, ProductPrice, ProductStock, ProductImage, ProductDimension # 初始化 API api = OzonAPI( client_id="YOUR_CLIENT_ID", api_key="YOUR_API_KEY", sandbox=True ) # 创建商品 product = OzonProduct( name="商品名称", description="商品描述", price=ProductPrice( price="999.00", # 价格(卢布) old_price="1299.00" # 原价(可选) ), stock=ProductStock( type="own", # own=自有仓库,ozon=Ozon 仓库 value=100 # 库存数量 ), images=[ ProductImage(url="https://example.com/image1.jpg"), ProductImage(url="https://example.com/image2.jpg") ], dimension=ProductDimension( width=200, # 宽度 mm height=50, # 高度 mm depth=150, # 深度 mm weight=250 # 重量 g ), category_id=12345, # 类目 ID sku="PRODUCT-001", # SKU(必填) barcode="1234567890123", # 条形码(可选) brand="YourBrand" # 品牌(可选) ) # 上传商品 result = api.create_product(product) if result["success"]: print("上传成功!") print(result["data"]) else: print("上传失败:", result["error"]) ``` ### 获取类目列表 ```python # 获取根类目 result = api.get_categories(parent_id=0) # 获取子类目 result = api.get_categories(parent_id=12345) ``` ### 更新库存 ```python result = api.update_stock( sku="PRODUCT-001", stock_value=50, stock_type="own" ) ``` ### 更新价格 ```python result = api.update_price( sku="PRODUCT-001", price="899.00", old_price="1199.00" ) ``` ## 商品属性说明 | 字段 | 类型 | 必填 | 说明 | |------|------|------|------| | name | string | ✅ | 商品名称 | | description | string | ✅ | 商品描述 | | price | string | ✅ | 价格(卢布) | | old_price | string | ❌ | 原价(用于显示折扣) | | sku | string | ✅ | 商品 SKU(唯一标识) | | barcode | string | ❌ | 条形码(EAN-13 等) | | category_id | int | ✅ | 类目 ID | | brand | string | ❌ | 品牌名称 | | images | list | ✅ | 图片 URL 列表(至少 1 张) | | dimension | object | ✅ | 尺寸和重量 | | stock | object | ✅ | 库存信息 | ## 注意事项 1. **图片要求**: - 图片必须是可公开访问的 URL - 建议尺寸:1000x1000 像素以上 - 支持格式:JPG, PNG 2. **类目选择**: - 不同类目有不同的必填属性 - 使用 `get_category_attributes()` 查看类目要求 3. **沙箱测试**: - 沙箱环境的商品不会显示在真实店铺 - 测试通过后再切换到正式环境 4. **API 限制**: - 注意 API 调用频率限制 - 批量上传时建议添加延迟 ## 错误处理 常见错误及解决方案: | 错误 | 原因 | 解决 | |------|------|------| | Invalid client-id | Client ID 错误 | 检查配置文件 | | Invalid api-key | API Key 错误 | 重新生成 API Key | | Category not found | 类目 ID 不存在 | 使用正确的类目 ID | | Image upload failed | 图片 URL 无效 | 检查图片链接是否可访问 | ## 官方文档 - Ozon API 文档(英文):https://docs.ozon.ru/api/seller/en/ - Ozon API 文档(俄文):https://docs.ozon.ru/api/seller/ ## License MIT