pinterest-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePinterest Automation Dashboard — API Reference
Pinterest Automation Dashboard — API Reference
API endpoints on the prefix require authentication via either:
/api/- Session cookie (browser login)
- API key in header
Authorization: Bearer <key>
Base URL for API endpoints:
http://<host>:5000/api/Authentication endpoints (login/logout) are on the root path, not .
/api/所有以为前缀的API端点需要通过以下方式之一进行认证:
/api/- Session cookie(浏览器登录)
- API key,放在请求头中
Authorization: Bearer <key>
API端点的基础URL:
http://<host>:5000/api/认证端点(登录/登出)位于根路径,而非下。
/api/Authentication
认证
These endpoints are not under — they use the root URL .
/api/http://<host>:5000/| Method | Endpoint | Description |
|---|---|---|
| POST | | Login with username/password. Sets session cookie. Body: form |
| GET | | Logout and clear session. |
python
import requests
session = requests.Session()
session.post("http://host:5000/auth/login", data={"username": "admin", "password": "pass"})For all subsequent examples, we use API key auth instead of session cookies:
python
import requests
BASE = "http://host:5000/api"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}这些端点不在下——它们使用根URL 。
/api/http://<host>:5000/| Method | Endpoint | Description |
|---|---|---|
| POST | | 使用用户名/密码登录。设置会话Cookie。请求体为表单格式,包含 |
| GET | | 登出并清除会话。 |
python
import requests
session = requests.Session()
session.post("http://host:5000/auth/login", data={"username": "admin", "password": "pass"})在后续所有示例中,我们使用API key认证而非会话Cookie:
python
import requests
BASE = "http://host:5000/api"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}Accounts
账户
List & Detail
列表与详情
| Method | Endpoint | Description |
|---|---|---|
| GET | | List all accounts with stats (paginated). |
| GET | | Get full account detail: proxy, boards, stats, limits. |
GET /accounts query params:
- (int, default 1)
page - (int, default 50, max 200)
per_page - (string) — filter by username
search - (string) — filter by category name
category - (int) — filter by category ID
category_id - (string) —
proxy_mode,iproyal, orcustomdirect - (string) — automation status filter
status - (string) — filter by direct save enabled
direct_save - (string) — filter by smart saves week
week
Python:
python
resp = requests.get(f"{BASE}/accounts", headers=HEADERS, params={"per_page": 100})
data = resp.json()| Method | Endpoint | Description |
|---|---|---|
| GET | | 列出所有带统计数据的账户(支持分页)。 |
| GET | | 获取账户完整详情:代理、看板、统计数据、限制。 |
GET /accounts 查询参数:
- (整数,默认值1)
page - (整数,默认值50,最大值200)
per_page - (字符串)——按用户名筛选
search - (字符串)——按分类名称筛选
category - (整数)——按分类ID筛选
category_id - (字符串)——
proxy_mode、iproyal或customdirect - (字符串)——按自动化状态筛选
status - (字符串)——按是否启用直接保存筛选
direct_save - (字符串)——按智能保存周数筛选
week
Python示例:
python
resp = requests.get(f"{BASE}/accounts", headers=HEADERS, params={"per_page": 100})
data = resp.json(){"accounts": [...], "total": 13, "page": 1, "per_page": 100, "total_pages": 1,
{"accounts": [...], "total": 13, "page": 1, "per_page": 100, "total_pages": 1,
"total_all": 13, "categories_tree": [...], "uncategorized_count": 2}
"total_all": 13, "categories_tree": [...], "uncategorized_count": 2}
detail = requests.get(f"{BASE}/accounts/mindfulrecipes", headers=HEADERS).json()
detail = requests.get(f"{BASE}/accounts/mindfulrecipes", headers=HEADERS).json()
{"username": "mindfulrecipes", "has_cookies": true, "has_fingerprint": true,
{"username": "mindfulrecipes", "has_cookies": true, "has_fingerprint": true,
"proxy": "http://...", "proxy_mode": "direct", "boards": [...], "board_count": 12,
"proxy": "http://...", "proxy_mode": "direct", "boards": [...], "board_count": 12,
"stats": {"total_sessions": 61, "total_saved": 357, "today_saves": 0, ...}}
"stats": {"total_sessions": 61, "total_saved": 357, "today_saves": 0, ...}}
**cURL:**
```bash
curl -H "Authorization: Bearer $KEY" "http://host:5000/api/accounts?per_page=100"
curl -H "Authorization: Bearer $KEY" "http://host:5000/api/accounts/mindfulrecipes"
**cURL示例:**
```bash
curl -H "Authorization: Bearer $KEY" "http://host:5000/api/accounts?per_page=100"
curl -H "Authorization: Bearer $KEY" "http://host:5000/api/accounts/mindfulrecipes"Add & Import
添加与导入
| Method | Endpoint | Description |
|---|---|---|
| POST | | Add single account. Multipart form: |
| POST | | Import multiple accounts from JSON body. |
| POST | | Upload multiple accounts with files. Multipart form with folder structure. |
| POST | | One-time CSV→DB import. Reads |
Python — add single account:
python
with open("cookies.json", "rb") as c, open("fingerprint.json", "rb") as f:
resp = requests.post(f"{BASE}/accounts/add", headers=HEADERS,
data={"username": "myaccount", "proxy_mode": "iproyal", "category": "food"},
files={"cookies": c, "fingerprint": f})| Method | Endpoint | Description |
|---|---|---|
| POST | | 添加单个账户。多部分表单格式: |
| POST | | 通过JSON请求体批量导入多个账户。 |
| POST | | 上传包含文件的多个账户。带文件夹结构的多部分表单格式。 |
| POST | | 一次性CSV→数据库导入。读取 |
Python示例——添加单个账户:
python
with open("cookies.json", "rb") as c, open("fingerprint.json", "rb") as f:
resp = requests.post(f"{BASE}/accounts/add", headers=HEADERS,
data={"username": "myaccount", "proxy_mode": "iproyal", "category": "food"},
files={"cookies": c, "fingerprint": f}){"success": true, "username": "myaccount", "sync": {"fetched_boards": 12, ...}}
{"success": true, "username": "myaccount", "sync": {"fetched_boards": 12, ...}}
**Python — bulk import (JSON):**
```python
resp = requests.post(f"{BASE}/accounts/bulk-import", headers=HEADERS, json={
"accounts": [
{"username": "user1", "proxy": "http://...", "category": "food"},
{"username": "user2"}
]
})
**Python示例——批量导入(JSON格式):**
```python
resp = requests.post(f"{BASE}/accounts/bulk-import", headers=HEADERS, json={
"accounts": [
{"username": "user1", "proxy": "http://...", "category": "food"},
{"username": "user2"}
]
}){"success": true, "imported": 2, "skipped": 0, "sync_queued": 2, "errors": []}
{"success": true, "imported": 2, "skipped": 0, "sync_queued": 2, "errors": []}
**cURL — add account:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" \
-F "username=myaccount" -F "proxy_mode=iproyal" -F "cookies=@cookies.json" \
http://host:5000/api/accounts/add
**cURL示例——添加账户:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" \
-F "username=myaccount" -F "proxy_mode=iproyal" -F "cookies=@cookies.json" \
http://host:5000/api/accounts/addModify
修改
| Method | Endpoint | Description |
|---|---|---|
| PUT/POST | | Update account files/proxy/category. Multipart form: |
| POST | | Rename account. Body: |
| POST | | Set proxy mode. Body: `{"mode": "iproyal |
Python:
python
resp = requests.post(f"{BASE}/accounts/myaccount/proxy-mode", headers=HEADERS,
json={"mode": "direct"})| Method | Endpoint | Description |
|---|---|---|
| PUT/POST | | 更新账户文件/代理/分类。多部分表单格式: |
| POST | | 重命名账户。请求体: |
| POST | | 设置代理模式。请求体:`{"mode": "iproyal |
Python示例:
python
resp = requests.post(f"{BASE}/accounts/myaccount/proxy-mode", headers=HEADERS,
json={"mode": "direct"}){"success": true, "proxy_mode": "direct", "proxy": "", "location": ""}
{"success": true, "proxy_mode": "direct", "proxy": "", "location": ""}
undefinedundefinedDelete
删除
| Method | Endpoint | Description |
|---|---|---|
| DELETE | | Delete single account (removes folder + DB records). |
| POST | | Batch delete. Body: |
cURL:
bash
curl -X DELETE -H "Authorization: Bearer $KEY" http://host:5000/api/accounts/myaccount| Method | Endpoint | Description |
|---|---|---|
| DELETE | | 删除单个账户(移除文件夹和数据库记录)。 |
| POST | | 批量删除。请求体: |
cURL示例:
bash
curl -X DELETE -H "Authorization: Bearer $KEY" http://host:5000/api/accounts/myaccountBatch Operations
批量操作
| Method | Endpoint | Description |
|---|---|---|
| POST | | Set category for multiple accounts. Body: |
| POST | | Set proxy mode for multiple accounts. Body: |
| Method | Endpoint | Description |
|---|---|---|
| POST | | 为多个账户设置分类。请求体: |
| POST | | 为多个账户设置代理模式。请求体: |
Sync Status
同步状态
| Method | Endpoint | Description |
|---|---|---|
| GET | | Check bulk board sync progress after import. |
| Method | Endpoint | Description |
|---|---|---|
| GET | | 检查导入后的批量看板同步进度。 |
Automation (Save)
自动化(保存)
Enable/Disable
启用/禁用
| Method | Endpoint | Description |
|---|---|---|
| POST | | Enable save automation for account. |
| POST | | Disable save automation for account. |
| POST | | Batch enable. Body: |
| POST | | Batch disable. Body: |
Python:
python
requests.post(f"{BASE}/automation/mindfulrecipes/enable", headers=HEADERS)| Method | Endpoint | Description |
|---|---|---|
| POST | | 启用账户的保存自动化功能。 |
| POST | | 禁用账户的保存自动化功能。 |
| POST | | 批量启用。请求体: |
| POST | | 批量禁用。请求体: |
Python示例:
python
requests.post(f"{BASE}/automation/mindfulrecipes/enable", headers=HEADERS){"success": true, "message": "Automation enabled for mindfulrecipes"}
{"success": true, "message": "Automation enabled for mindfulrecipes"}
requests.post(f"{BASE}/automation/batch/enable", headers=HEADERS,
json={"usernames": ["user1", "user2", "user3"]})
requests.post(f"{BASE}/automation/batch/enable", headers=HEADERS,
json={"usernames": ["user1", "user2", "user3"]})
{"success": true, "results": {"user1": "enabled", "user2": "enabled", ...}}
{"success": true, "results": {"user1": "enabled", "user2": "enabled", ...}}
**cURL:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" http://host:5000/api/automation/mindfulrecipes/enable
**cURL示例:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" http://host:5000/api/automation/mindfulrecipes/enableStatus
状态
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get all automation statuses (running, sleeping, waiting, error). |
Response:
json
{
"jobs": {
"mindfulrecipes": {
"active": true, "status": "sleeping", "next_run": 1713300000,
"sessions_today": 1, "sessions_remaining": 2,
"pins_saved": 15, "pins_created": 0, "error": null
}
}
}| Method | Endpoint | Description |
|---|---|---|
| GET | | 获取所有自动化任务状态(运行中、休眠、等待、错误)。 |
响应示例:
json
{
"jobs": {
"mindfulrecipes": {
"active": true, "status": "sleeping", "next_run": 1713300000,
"sessions_today": 1, "sessions_remaining": 2,
"pins_saved": 15, "pins_created": 0, "error": null
}
}
}Limits
限制
| Method | Endpoint | Description |
|---|---|---|
| POST | | Set daily saves limit override. Body: |
| POST | | Batch set saves limit. Body: |
| Method | Endpoint | Description |
|---|---|---|
| POST | | 设置每日保存上限覆盖值。请求体: |
| POST | | 批量设置保存上限。请求体: |
Schedule
调度
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get account schedule (smart automation managed). |
| POST | | Update schedule (currently smart-managed, returns info). |
| Method | Endpoint | Description |
|---|---|---|
| GET | | 获取账户调度信息(由智能自动化管理)。 |
| POST | | 更新调度信息(当前为智能管理,返回相关信息)。 |
Automation (Create)
自动化(创建)
Enable/Disable
启用/禁用
| Method | Endpoint | Description |
|---|---|---|
| POST | | Enable create automation. |
| POST | | Disable create automation. |
| POST | | Batch enable create. Body: |
| POST | | Batch disable create. Body: |
| Method | Endpoint | Description |
|---|---|---|
| POST | | 启用创建自动化功能。 |
| POST | | 禁用创建自动化功能。 |
| POST | | 批量启用创建功能。请求体: |
| POST | | 批量禁用创建功能。请求体: |
Status & Limits
状态与限制
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get create automation statuses. |
| POST | | Set daily creates limit. Body: |
| POST | | Batch set creates limit. Body: |
| Method | Endpoint | Description |
|---|---|---|
| GET | | 获取创建自动化任务状态。 |
| POST | | 设置每日创建上限。请求体: |
| POST | | 批量设置创建上限。请求体: |
Direct Save
直接保存
| Method | Endpoint | Description |
|---|---|---|
| PATCH | | Toggle direct save. Body: |
| POST | | Batch toggle. Body: |
Python:
python
requests.patch(f"{BASE}/accounts/mindfulrecipes/direct-save", headers=HEADERS,
json={"enabled": True})| Method | Endpoint | Description |
|---|---|---|
| PATCH | | 切换直接保存功能。请求体: |
| POST | | 批量切换直接保存功能。请求体: |
Python示例:
python
requests.patch(f"{BASE}/accounts/mindfulrecipes/direct-save", headers=HEADERS,
json={"enabled": True}){"success": true, "direct_save_enabled": true}
{"success": true, "direct_save_enabled": true}
---
---Boards
看板
| Method | Endpoint | Description |
|---|---|---|
| GET | | List boards for account. |
| POST | | Fetch boards from Pinterest API and sync locally. |
| POST | | Create board(s) on Pinterest. |
| POST | | Upload boards CSV file. |
| DELETE | | Delete a board on Pinterest. |
POST /accounts/<username>/create-board body (single):
json
{"name": "Board Name", "description": "...", "privacy": "public"}POST /accounts/<username>/create-board body (multiple):
json
{
"boards": [
{"name": "Board 1", "description": "...", "privacy": "public"},
{"name": "Board 2", "privacy": "secret"}
]
}Or using names array:
json
{"names": ["Board 1", "Board 2"], "description": "...", "privacy": "public"}Python — sync boards:
python
resp = requests.post(f"{BASE}/accounts/mindfulrecipes/sync-boards", headers=HEADERS)| Method | Endpoint | Description |
|---|---|---|
| GET | | 列出账户的看板。 |
| POST | | 从Pinterest API获取看板并同步到本地。 |
| POST | | 在Pinterest上创建看板。 |
| POST | | 上传看板CSV文件。 |
| DELETE | | 在Pinterest上删除看板。 |
POST /accounts/<username>/create-board 请求体(单个看板):
json
{"name": "Board Name", "description": "...", "privacy": "public"}POST /accounts/<username>/create-board 请求体(多个看板):
json
{
"boards": [
{"name": "Board 1", "description": "...", "privacy": "public"},
{"name": "Board 2", "privacy": "secret"}
]
}或使用名称数组:
json
{"names": ["Board 1", "Board 2"], "description": "...", "privacy": "public"}Python示例——同步看板:
python
resp = requests.post(f"{BASE}/accounts/mindfulrecipes/sync-boards", headers=HEADERS){"success": true, "fetched_boards": 12, "created_boards": 0, "errors": [],
{"success": true, "fetched_boards": 12, "created_boards": 0, "errors": [],
"boards": [{"name": "Easy Recipes", "board_id": "123456789", "privacy": "public"}, ...]}
"boards": [{"name": "Easy Recipes", "board_id": "123456789", "privacy": "public"}, ...]}
**Python — upload boards CSV:**
```python
with open("boards.csv", "rb") as f:
resp = requests.post(f"{BASE}/accounts/mindfulrecipes/upload-boards",
headers=HEADERS, files={"csv": f})
**Python示例——上传看板CSV:**
```python
with open("boards.csv", "rb") as f:
resp = requests.post(f"{BASE}/accounts/mindfulrecipes/upload-boards",
headers=HEADERS, files={"csv": f}){"success": true, "board_count": 12, "synced": true, "boards": [...]}
{"success": true, "board_count": 12, "synced": true, "boards": [...]}
**cURL:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" http://host:5000/api/accounts/mindfulrecipes/sync-boards
curl -X POST -H "Authorization: Bearer $KEY" -F "csv=@boards.csv" http://host:5000/api/accounts/mindfulrecipes/upload-boards
**cURL示例:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" http://host:5000/api/accounts/mindfulrecipes/sync-boards
curl -X POST -H "Authorization: Bearer $KEY" -F "csv=@boards.csv" http://host:5000/api/accounts/mindfulrecipes/upload-boardsPin Queue (Create)
Pin创建队列
| Method | Endpoint | Description |
|---|---|---|
| GET | | List pin creation queue. Returns pins array + counts. |
| POST | | Add single pin to queue. |
| PUT | | Edit pin at index. |
| DELETE | | Remove pin at index. |
| POST | | Upload pins CSV file to queue. |
| POST | | Start pin creation job. Optional body: |
| GET | | Check pin creation job status. |
POST /accounts/<username>/pins/queue body:
json
{
"board_id": "123456789",
"image_url": "https://example.com/image.jpg",
"title": "My Pin",
"description": "Pin description",
"link": "https://example.com",
"alt_text": "Alt text"
}Python — upload CSV and start creation:
python
with open("pins.csv", "rb") as f:
resp = requests.post(f"{BASE}/accounts/mindfulrecipes/pins/upload-csv",
headers=HEADERS, files={"csv": f})| Method | Endpoint | Description |
|---|---|---|
| GET | | 列出Pin创建队列,返回Pin数组和统计数量。 |
| POST | | 添加单个Pin到队列。 |
| PUT | | 编辑队列中指定索引的Pin。 |
| DELETE | | 删除队列中指定索引的Pin。 |
| POST | | 上传Pin CSV文件到队列。 |
| POST | | 启动Pin创建任务。可选请求体: |
| GET | | 检查Pin创建任务状态。 |
POST /accounts/<username>/pins/queue 请求体:
json
{
"board_id": "123456789",
"image_url": "https://example.com/image.jpg",
"title": "My Pin",
"description": "Pin description",
"link": "https://example.com",
"alt_text": "Alt text"
}Python示例——上传CSV并启动创建任务:
python
with open("pins.csv", "rb") as f:
resp = requests.post(f"{BASE}/accounts/mindfulrecipes/pins/upload-csv",
headers=HEADERS, files={"csv": f}){"success": true, "added": 25, "skipped": 0, "total": 25}
{"success": true, "added": 25, "skipped": 0, "total": 25}
requests.post(f"{BASE}/accounts/mindfulrecipes/pins/create-run", headers=HEADERS)
requests.post(f"{BASE}/accounts/mindfulrecipes/pins/create-run", headers=HEADERS)
{"success": true, "message": "Pin creation started for mindfulrecipes"}
{"success": true, "message": "Pin creation started for mindfulrecipes"}
import time
while True:
status = requests.get(f"{BASE}/accounts/mindfulrecipes/pins/create-status",
headers=HEADERS).json()
print(f"{status['status']}: {status['created']}/{status['target']}")
if status["status"] in ("completed", "failed", "idle"):
break
time.sleep(5)
**cURL:**
```bash
curl -H "Authorization: Bearer $KEY" -F "csv=@pins.csv" http://host:5000/api/accounts/mindfulrecipes/pins/upload-csv
curl -X POST -H "Authorization: Bearer $KEY" http://host:5000/api/accounts/mindfulrecipes/pins/create-run
curl -H "Authorization: Bearer $KEY" http://host:5000/api/accounts/mindfulrecipes/pins/create-statusimport time
while True:
status = requests.get(f"{BASE}/accounts/mindfulrecipes/pins/create-status",
headers=HEADERS).json()
print(f"{status['status']}: {status['created']}/{status['target']}")
if status["status"] in ("completed", "failed", "idle"):
break
time.sleep(5)
**cURL示例:**
```bash
curl -H "Authorization: Bearer $KEY" -F "csv=@pins.csv" http://host:5000/api/accounts/mindfulrecipes/pins/upload-csv
curl -X POST -H "Authorization: Bearer $KEY" http://host:5000/api/accounts/mindfulrecipes/pins/create-run
curl -H "Authorization: Bearer $KEY" http://host:5000/api/accounts/mindfulrecipes/pins/create-statusSave Queue
保存队列
| Method | Endpoint | Description |
|---|---|---|
| GET | | List save queue items with counts. |
| DELETE | | Remove item at index. |
| POST | | Upload save queue file (.csv or .txt). |
| POST | | Remove all completed/failed items from queue. |
Python:
python
with open("saves.csv", "rb") as f:
resp = requests.post(f"{BASE}/accounts/mindfulrecipes/save-queue/upload",
headers=HEADERS, files={"file": f})| Method | Endpoint | Description |
|---|---|---|
| GET | | 列出保存队列项及统计数量。 |
| DELETE | | 删除队列中指定索引的项。 |
| POST | | 上传保存队列文件(.csv或.txt格式)。 |
| POST | | 从队列中移除所有已完成/失败的项。 |
Python示例:
python
with open("saves.csv", "rb") as f:
resp = requests.post(f"{BASE}/accounts/mindfulrecipes/save-queue/upload",
headers=HEADERS, files={"file": f}){"success": true, "added": 50, "total": 50}
{"success": true, "added": 50, "total": 50}
queue = requests.get(f"{BASE}/accounts/mindfulrecipes/save-queue", headers=HEADERS).json()
queue = requests.get(f"{BASE}/accounts/mindfulrecipes/save-queue", headers=HEADERS).json()
{"items": [...], "counts": {"total": 50, "pending": 48, "saved": 2, "failed": 0}}
{"items": [...], "counts": {"total": 50, "pending": 48, "saved": 2, "failed": 0}}
---
---Bulk Import (Files)
批量导入(文件)
| Method | Endpoint | Description |
|---|---|---|
| POST | | Upload ZIP of cookies/fingerprints. Structure: |
| POST | | Upload pin CSVs. Files named |
| POST | | Upload save queue files. Named |
| POST | | Upload board CSVs. Files named |
Python — import cookies ZIP:
python
with open("cookies.zip", "rb") as f:
resp = requests.post(f"{BASE}/import/cookies", headers=HEADERS, files={"zip": f})| Method | Endpoint | Description |
|---|---|---|
| POST | | 上传包含Cookie和指纹的ZIP文件。结构: |
| POST | | 上传Pin CSV文件。文件名格式为 |
| POST | | 上传保存队列文件。文件名格式为 |
| POST | | 上传看板CSV文件。文件名格式为 |
Python示例——导入Cookie ZIP包:
python
with open("cookies.zip", "rb") as f:
resp = requests.post(f"{BASE}/import/cookies", headers=HEADERS, files={"zip": f}){"success": true, "updated_count": 5, "skipped_count": 0, "error_count": 0,
{"success": true, "updated_count": 5, "skipped_count": 0, "error_count": 0,
"updated": [{"username": "user1", "cookies": true, "fingerprint": true}, ...]}
"updated": [{"username": "user1", "cookies": true, "fingerprint": true}, ...]}
**cURL:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" -F "zip=@cookies.zip" http://host:5000/api/import/cookies
curl -X POST -H "Authorization: Bearer $KEY" -F "zip=@pins.zip" http://host:5000/api/import/pins
**cURL示例:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" -F "zip=@cookies.zip" http://host:5000/api/import/cookies
curl -X POST -H "Authorization: Bearer $KEY" -F "zip=@pins.zip" http://host:5000/api/import/pinsProxy Management
代理管理
IPRoyal Configuration
IPRoyal配置
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get IPRoyal settings (password masked). |
| POST | | Save IPRoyal settings. |
POST /proxy/iproyal-config body:
json
{
"username": "ipr_user",
"password": "ipr_pass",
"host": "geo.iproyal.com",
"port": "12321",
"lifetime": "24h",
"high_end": "0",
"skip_static": "0"
}| Method | Endpoint | Description |
|---|---|---|
| GET | | 获取IPRoyal设置(密码已掩码)。 |
| POST | | 保存IPRoyal设置。 |
POST /proxy/iproyal-config 请求体:
json
{
"username": "ipr_user",
"password": "ipr_pass",
"host": "geo.iproyal.com",
"port": "12321",
"lifetime": "24h",
"high_end": "0",
"skip_static": "0"
}City Pool
城市池
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get city pool + location usage counts. |
| POST | | Update city pool. Body: |
| Method | Endpoint | Description |
|---|---|---|
| GET | | 获取城市池及位置使用统计。 |
| POST | | 更新城市池。请求体: |
Proxy Operations
代理操作
| Method | Endpoint | Description |
|---|---|---|
| POST | | Generate IPRoyal proxy for account. Body: |
| POST | | Assign IPRoyal proxies to all accounts. Body: |
| POST | | Assign cities to accounts without one. |
| POST | | Test a proxy connection. Body: |
Python:
python
result = requests.post(f"{BASE}/proxy/test", headers=HEADERS,
json={"proxy": "http://user:pass@host:port"}).json()| Method | Endpoint | Description |
|---|---|---|
| POST | | 为账户生成IPRoyal代理。请求体: |
| POST | | 为所有账户分配IPRoyal代理。请求体: |
| POST | | 为未分配城市的账户分配城市。 |
| POST | | 测试代理连接。请求体: |
Python示例:
python
result = requests.post(f"{BASE}/proxy/test", headers=HEADERS,
json={"proxy": "http://user:pass@host:port"}).json(){"ok": true, "ip": "1.2.3.4", "response_time": 1.23}
{"ok": true, "ip": "1.2.3.4", "response_time": 1.23}
requests.post(f"{BASE}/proxy/bulk-assign", headers=HEADERS, json={"overwrite": False})
requests.post(f"{BASE}/proxy/bulk-assign", headers=HEADERS, json={"overwrite": False})
{"ok": true, "assigned": 10, "skipped": 3, "total": 13}
{"ok": true, "assigned": 10, "skipped": 3, "total": 13}
**cURL:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{"proxy":"http://user:pass@host:port"}' http://host:5000/api/proxy/test
**cURL示例:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
-d '{"proxy":"http://user:pass@host:port"}' http://host:5000/api/proxy/testCategories
分类
| Method | Endpoint | Description |
|---|---|---|
| GET | | List all categories (flat). |
| GET | | Get categories as nested tree. |
| POST | | Create category. Body: |
| PUT | | Rename/move category. Body: |
| DELETE | | Delete category. |
Python:
python
resp = requests.post(f"{BASE}/categories", headers=HEADERS,
json={"name": "Food", "parent_id": None})| Method | Endpoint | Description |
|---|---|---|
| GET | | 列出所有分类(扁平结构)。 |
| GET | | 获取分类的嵌套树形结构。 |
| POST | | 创建分类。请求体: |
| PUT | | 重命名/移动分类。请求体: |
| DELETE | | 删除分类。 |
Python示例:
python
resp = requests.post(f"{BASE}/categories", headers=HEADERS,
json={"name": "Food", "parent_id": None}){"success": true, "category": {"id": 1, "name": "Food", "parent_id": null, "path": "Food"}}
{"success": true, "category": {"id": 1, "name": "Food", "parent_id": null, "path": "Food"}}
---
---Dashboard & Activity
仪表盘与活动
| Method | Endpoint | Description |
|---|---|---|
| GET | | Dashboard overview: total accounts, sessions, saves, creates, pending pins. |
| GET | | Recent automation runs. Query: |
| GET | | Currently running tasks per account. |
Python:
python
stats = requests.get(f"{BASE}/dashboard/stats", headers=HEADERS).json()| Method | Endpoint | Description |
|---|---|---|
| GET | | 仪表盘概览:账户总数、会话数、保存数、创建数、待处理Pin数。 |
| GET | | 最近的自动化任务运行记录。查询参数: |
| GET | | 每个账户当前运行的任务。 |
Python示例:
python
stats = requests.get(f"{BASE}/dashboard/stats", headers=HEADERS).json(){"total_accounts": 13, "connected_accounts": 3, "total_sessions": 61,
{"total_accounts": 13, "connected_accounts": 3, "total_sessions": 61,
"total_saved": 758, "total_created": 0, "total_pending_pins": 0, ...}
"total_saved": 758, "total_created": 0, "total_pending_pins": 0, ...}
recent = requests.get(f"{BASE}/activity/recent", headers=HEADERS, params={"limit": 10}).json()
recent = requests.get(f"{BASE}/activity/recent", headers=HEADERS, params={"limit": 10}).json()
{"runs": [{"username": "mindfulrecipes", "run_type": "save", "pins_saved": 8, ...}, ...]}
{"runs": [{"username": "mindfulrecipes", "run_type": "save", "pins_saved": 8, ...}, ...]}
**cURL:**
```bash
curl -H "Authorization: Bearer $KEY" http://host:5000/api/dashboard/stats
curl -H "Authorization: Bearer $KEY" "http://host:5000/api/activity/recent?limit=10"
**cURL示例:**
```bash
curl -H "Authorization: Bearer $KEY" http://host:5000/api/dashboard/stats
curl -H "Authorization: Bearer $KEY" "http://host:5000/api/activity/recent?limit=10"Analytics
分析
Profile Analytics
个人资料分析
| Method | Endpoint | Description |
|---|---|---|
| POST | | Start async analytics job (fetches Pinterest profile data for all accounts). |
| GET | | Poll job status. Returns results when complete. |
Python:
python
job = requests.post(f"{BASE}/analytics/check", headers=HEADERS).json()| Method | Endpoint | Description |
|---|---|---|
| POST | | 启动异步分析任务(获取所有账户的Pinterest个人资料数据)。 |
| GET | | 轮询任务状态。任务完成后返回结果。 |
Python示例:
python
job = requests.post(f"{BASE}/analytics/check", headers=HEADERS).json(){"job_id": "a1b2c3d4", "checker_username": "mindfulrecipes", "total": 13}
{"job_id": "a1b2c3d4", "checker_username": "mindfulrecipes", "total": 13}
import time
while True:
status = requests.get(f"{BASE}/analytics/status",
headers=HEADERS, params={"job_id": job["job_id"]}).json()
if status["status"] == "complete":
for r in status["results"]:
print(f"{r['username']}: {r['follower_count']} followers, {r['pin_count']} pins")
break
elif status["status"] == "error":
print(f"Error: {status['error']}")
break
time.sleep(3)
undefinedimport time
while True:
status = requests.get(f"{BASE}/analytics/status",
headers=HEADERS, params={"job_id": job["job_id"]}).json()
if status["status"] == "complete":
for r in status["results"]:
print(f"{r['username']}: {r['follower_count']} followers, {r['pin_count']} pins")
break
elif status["status"] == "error":
print(f"Error: {status['error']}")
break
time.sleep(3)
undefinedAnalytics Dashboard
分析仪表盘
| Method | Endpoint | Description |
|---|---|---|
| GET | | System overview, daily trends, account performance, hourly distribution. Query: |
Response:
json
{
"overview": {"today": {"saves": 15}, "yesterday": {"saves": 22}, "avg_7d": {"saves": 18}},
"trends": [{"date": "2025-04-15", "saves": 22, "creates": 0, "sessions": 3}, ...],
"performance": [{"username": "mindfulrecipes", "saves": 357, "sessions": 61}, ...],
"hourly": [{"hour": 8, "saves": 5}, {"hour": 9, "saves": 8}, ...]
}| Method | Endpoint | Description |
|---|---|---|
| GET | | 系统概览、每日趋势、账户表现、小时分布。查询参数: |
响应示例:
json
{
"overview": {"today": {"saves": 15}, "yesterday": {"saves": 22}, "avg_7d": {"saves": 18}},
"trends": [{"date": "2025-04-15", "saves": 22, "creates": 0, "sessions": 3}, ...],
"performance": [{"username": "mindfulrecipes", "saves": 357, "sessions": 61}, ...],
"hourly": [{"hour": 8, "saves": 5}, {"hour": 9, "saves": 8}, ...]
}Health
健康状态
| Method | Endpoint | Description |
|---|---|---|
| GET | | Health status for all accounts (healthy/warning/critical/inactive) with 24h stats. |
Python:
python
health = requests.get(f"{BASE}/health/accounts", headers=HEADERS).json()| Method | Endpoint | Description |
|---|---|---|
| GET | | 所有账户的健康状态(健康/警告/严重/未激活)及24小时统计数据。 |
Python示例:
python
health = requests.get(f"{BASE}/health/accounts", headers=HEADERS).json(){"summary": {"total": 13, "healthy": 2, "warning": 1, "critical": 0, "inactive": 10},
{"summary": {"total": 13, "healthy": 2, "warning": 1, "critical": 0, "inactive": 10},
"accounts": [{"username": "mindfulrecipes", "health_status": "healthy",
"accounts": [{"username": "mindfulrecipes", "health_status": "healthy",
"total_sessions_24h": 3, "total_saves_24h": 15, "failure_rate": 0, ...}, ...]}
"total_sessions_24h": 3, "total_saves_24h": 15, "failure_rate": 0, ...}, ...]}
**cURL:**
```bash
curl -H "Authorization: Bearer $KEY" http://host:5000/api/health/accounts
**cURL示例:**
```bash
curl -H "Authorization: Bearer $KEY" http://host:5000/api/health/accountsLogs
日志
| Method | Endpoint | Description |
|---|---|---|
| GET | | List accounts that have log files. |
| GET | | Download all logs as ZIP. |
| GET | | Download logs for single account as ZIP. |
cURL:
bash
curl -H "Authorization: Bearer $KEY" -o all_logs.zip http://host:5000/api/logs/download-all
curl -H "Authorization: Bearer $KEY" -o user_logs.zip http://host:5000/api/logs/download/mindfulrecipes| Method | Endpoint | Description |
|---|---|---|
| GET | | 列出拥有日志文件的账户。 |
| GET | | 下载所有日志为ZIP包。 |
| GET | | 下载单个账户的日志为ZIP包。 |
cURL示例:
bash
curl -H "Authorization: Bearer $KEY" -o all_logs.zip http://host:5000/api/logs/download-all
curl -H "Authorization: Bearer $KEY" -o user_logs.zip http://host:5000/api/logs/download/mindfulrecipesSimulator
模拟器
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get simulation status. |
| POST | | Start simulation. |
| POST | | Stop running simulation. |
| GET | | Get simulation logs. |
| POST | | Clean up simulation log files. |
POST /simulator/start body:
json
{
"accounts": ["user1", "user2"],
"days": 3,
"fast": false,
"max_workers": 6,
"stages": [
{"week": 1, "days": 3},
{"week": 2, "days": 4}
]
}| Method | Endpoint | Description |
|---|---|---|
| GET | | 获取模拟状态。 |
| POST | | 启动模拟。 |
| POST | | 停止正在运行的模拟。 |
| GET | | 获取模拟日志。 |
| POST | | 清理模拟日志文件。 |
POST /simulator/start 请求体:
json
{
"accounts": ["user1", "user2"],
"days": 3,
"fast": false,
"max_workers": 6,
"stages": [
{"week": 1, "days": 3},
{"week": 2, "days": 4}
]
}Backup & Restore
备份与恢复
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get S3 backup settings. |
| POST | | Save S3 backup settings. |
| POST | | Test S3 connection. |
| POST | | Create a new backup. |
| GET | | List available backups. |
| GET | | Get current backup/restore status. |
| POST | | Restore from backup. Body: |
| DELETE | | Delete a backup. |
Python:
python
requests.post(f"{BASE}/backup/create", headers=HEADERS)| Method | Endpoint | Description |
|---|---|---|
| GET | | 获取S3备份设置。 |
| POST | | 保存S3备份设置。 |
| POST | | 测试S3连接。 |
| POST | | 创建新备份。 |
| GET | | 列出可用备份。 |
| GET | | 获取当前备份/恢复状态。 |
| POST | | 从备份恢复。请求体: |
| DELETE | | 删除备份。 |
Python示例:
python
requests.post(f"{BASE}/backup/create", headers=HEADERS){"ok": true, "message": "Backup started"}
{"ok": true, "message": "Backup started"}
import time
while True:
status = requests.get(f"{BASE}/backup/status", headers=HEADERS).json()
if not status.get("running"):
break
time.sleep(10)
backups = requests.get(f"{BASE}/backup/list", headers=HEADERS).json()
import time
while True:
status = requests.get(f"{BASE}/backup/status", headers=HEADERS).json()
if not status.get("running"):
break
time.sleep(10)
backups = requests.get(f"{BASE}/backup/list", headers=HEADERS).json()
{"backups": [{"key": "backups/20250416_020000.tar.gz", "size": 1234567, ...}]}
{"backups": [{"key": "backups/20250416_020000.tar.gz", "size": 1234567, ...}]}
**cURL:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" http://host:5000/api/backup/create
curl -H "Authorization: Bearer $KEY" http://host:5000/api/backup/list
**cURL示例:**
```bash
curl -X POST -H "Authorization: Bearer $KEY" http://host:5000/api/backup/create
curl -H "Authorization: Bearer $KEY" http://host:5000/api/backup/listSettings
设置
General
常规设置
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get current settings (username, concurrency, version). |
| POST | | Change password. Body: |
| POST | | Change login username. Body: |
| POST | | Set max concurrent automations (1-20). Body: |
| Method | Endpoint | Description |
|---|---|---|
| GET | | 获取当前设置(用户名、并发数、版本)。 |
| POST | | 修改密码。请求体: |
| POST | | 修改登录用户名。请求体: |
| POST | | 设置最大并发自动化任务数(1-20)。请求体: |
Security
安全设置
| Method | Endpoint | Description |
|---|---|---|
| POST | | Regenerate Flask secret key (invalidates all sessions). |
| GET | | Get API key info (exists, prefix). |
| POST | | Generate new API key. Returns the raw key once. |
| POST | | Revoke API key. |
Python:
python
result = requests.post(f"{BASE}/settings/api-key/regenerate", headers=HEADERS).json()| Method | Endpoint | Description |
|---|---|---|
| POST | | 重新生成Flask密钥(会使所有会话失效)。 |
| GET | | 获取API密钥信息(是否存在、前缀)。 |
| POST | | 生成新的API密钥。仅返回一次原始密钥。 |
| POST | | 吊销API密钥。 |
Python示例:
python
result = requests.post(f"{BASE}/settings/api-key/regenerate", headers=HEADERS).json(){"ok": true, "api_key": "18ef47f3a...", "message": "Copy it now — it will not be shown again."}
{"ok": true, "api_key": "18ef47f3a...", "message": "Copy it now — it will not be shown again."}
info = requests.get(f"{BASE}/settings/api-key", headers=HEADERS).json()
info = requests.get(f"{BASE}/settings/api-key", headers=HEADERS).json()
{"exists": true, "prefix": "18ef47f3", "masked": "18ef47f3...************************"}
{"exists": true, "prefix": "18ef47f3", "masked": "18ef47f3...************************"}
undefinedundefinedSmart Saves Schedule
智能保存调度
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get smart saves schedule (week thresholds + min/max saves). |
| POST | | Update schedule. |
| POST | | Reset to defaults. |
POST /settings/smart-saves-schedule body:
json
{
"schedule": [
{"day_threshold": 7, "min_saves": 3, "max_saves": 8},
{"day_threshold": 14, "min_saves": 5, "max_saves": 15},
{"day_threshold": 999999, "min_saves": 10, "max_saves": 25}
]
}| Method | Endpoint | Description |
|---|---|---|
| GET | | 获取智能保存调度(周阈值及最小/最大保存数)。 |
| POST | | 更新调度。 |
| POST | | 重置为默认设置。 |
POST /settings/smart-saves-schedule 请求体:
json
{
"schedule": [
{"day_threshold": 7, "min_saves": 3, "max_saves": 8},
{"day_threshold": 14, "min_saves": 5, "max_saves": 15},
{"day_threshold": 999999, "min_saves": 10, "max_saves": 25}
]
}Database & Reset
数据库与重置
| Method | Endpoint | Description |
|---|---|---|
| GET | | Get row counts for runs, daily_activity, automation_status, active_jobs, csv_pins. |
| POST | | Reset history. Target: |
| POST | | Reset all pin CSV statuses to pending. Body: |
| Method | Endpoint | Description |
|---|---|---|
| GET | | 获取runs、daily_activity、automation_status、active_jobs、csv_pins的行数统计。 |
| POST | | 重置历史数据。目标值: |
| POST | | 将所有Pin CSV状态重置为待处理。请求体: |
Error Responses
错误响应
All errors return JSON with an field:
errorjson
{"error": "Account not found"}Common HTTP status codes:
- — Bad request / validation error
400 - — Not authenticated
401 - — Forbidden (wrong password)
403 - — Resource not found
404 - — Conflict (already exists, already running)
409 - — Server error
500 - — Proxy error (proxy test failures)
502
所有错误返回包含字段的JSON:
errorjson
{"error": "Account not found"}常见HTTP状态码:
- — 错误请求/验证错误
400 - — 未认证
401 - — 禁止访问(密码错误)
403 - — 资源未找到
404 - — 冲突(已存在、已在运行)
409 - — 服务器错误
500 - — 代理错误(代理测试失败)
502