Loading...
Loading...
Compare original and translation side by side
POLY_PIZZA_KEYX-Auth-Token: <your_api_key>X-Auth-Token: <your_api_key>https://api.poly.pizza/v1/https://api.poly.pizza/v1/GET /search/{query}| Param | Type | Default | Description |
|---|---|---|---|
| integer | 12 | Max results to return (max ~50) |
| string | — | Pagination cursor from a previous response |
| string | | File format filter ( |
| boolean | — | Filter to only animated models |
| string | — | Triangle count range, e.g. |
GET https://api.poly.pizza/v1/search/tree?limit=5
X-Auth-Token: your_key_here{
"cursor": "some_cursor_string_or_null",
"results": [
{
"ID": "5EGWBMpuXq",
"Title": "Oak Tree",
"Description": "A simple low poly oak tree",
"Creator": {
"Username": "someartist",
"PURL": "https://poly.pizza/u/someartist"
},
"Thumbnail": "https://...jpg",
"Download": "https://...glb",
"DownloadFBX": "https://...fbx",
"Licence": "CC-BY 4.0",
"Tags": ["nature", "tree", "foliage"],
"TriangleCount": 320,
"Animated": false,
"PublishedAt": "2021-08-15T04:32:11.000Z"
}
// ... more results
]
}GET /search/{query}| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| 整数 | 12 | 返回的最大结果数(上限约为50) |
| 字符串 | — | 来自上一次响应的分页游标 |
| 字符串 | | 文件格式筛选( |
| 布尔值 | — | 仅筛选带动画的模型 |
| 字符串 | — | 三角形数量范围,例如 |
GET https://api.poly.pizza/v1/search/tree?limit=5
X-Auth-Token: your_key_here{
"cursor": "some_cursor_string_or_null",
"results": [
{
"ID": "5EGWBMpuXq",
"Title": "Oak Tree",
"Description": "A simple low poly oak tree",
"Creator": {
"Username": "someartist",
"PURL": "https://poly.pizza/u/someartist"
},
"Thumbnail": "https://...jpg",
"Download": "https://...glb",
"DownloadFBX": "https://...fbx",
"Licence": "CC-BY 4.0",
"Tags": ["nature", "tree", "foliage"],
"TriangleCount": 320,
"Animated": false,
"PublishedAt": "2021-08-15T04:32:11.000Z"
}
// ... more results
]
}GET /popularlimitcursorformatanimatedtricountGET https://api.poly.pizza/v1/popular?limit=10
X-Auth-Token: your_key_hereGET /popularlimitcursorformatanimatedtricountGET https://api.poly.pizza/v1/popular?limit=10
X-Auth-Token: your_key_hereGET /model/{id}GET https://api.poly.pizza/v1/model/5EGWBMpuXq
X-Auth-Token: your_key_hereresultsGET /model/{id}GET https://api.poly.pizza/v1/model/5EGWBMpuXq
X-Auth-Token: your_key_hereresultsDownload.glbimport requestsDownloadimport requests
---
---| License | Requirements |
|---|---|
| CC0 | No attribution required — public domain |
| CC-BY 4.0 | Must credit the creator. Format: |
model.Licence"Oak Tree" by someartist (https://poly.pizza/u/someartist) CC-BY 4.0| 许可证 | 要求 |
|---|---|
| CC0 | 无需署名——属于公有领域 |
| CC-BY 4.0 | 必须注明创作者。格式: |
model.Licence"Oak Tree" by someartist (https://poly.pizza/u/someartist) CC-BY 4.0cursor?cursor=<value>results = []
cursor = None
while True:
params = {"limit": 24}
if cursor:
params["cursor"] = cursor
data = requests.get(url, headers=headers, params=params).json()
results.extend(data["results"])
cursor = data.get("cursor")
if not cursor:
breakcursor?cursor=<value>results = []
cursor = None
while True:
params = {"limit": 24}
if cursor:
params["cursor"] = cursor
data = requests.get(url, headers=headers, params=params).json()
results.extend(data["results"])
cursor = data.get("cursor")
if not cursor:
break| Status | Meaning |
|---|---|
| 200 | OK |
| 401 | Missing or invalid API key |
| 404 | Model ID not found |
| 429 | Rate limit exceeded — back off |
| 500 | Server error — retry |
| 状态码 | 含义 |
|---|---|
| 200 | 请求成功 |
| 401 | API密钥缺失或无效 |
| 404 | 模型ID不存在 |
| 429 | 请求频率超限——请暂停后重试 |
| 500 | 服务器错误——请重试 |
GET /search/{keyword}?limit=5TriangleCountGET /search/{keyword}?limit=5import requests, os
def fetch_model(api_key: str, keyword: str, out_dir: str) -> dict:
headers = {"X-Auth-Token": api_key}
r = requests.get(
f"https://api.poly.pizza/v1/search/{keyword}",
headers=headers,
params={"limit": 1}
)
r.raise_for_status()
results = r.json().get("results", [])
if not results:
raise ValueError(f"No models found for '{keyword}'")
model = results[0]
glb = requests.get(model["Download"])
glb.raise_for_status()
safe_name = model["Title"].replace(" ", "_")
path = os.path.join(out_dir, f"{safe_name}.glb")
with open(path, "wb") as f:
f.write(glb.content)
attribution = None
if "CC-BY" in model.get("Licence", ""):
attribution = (
f'"{model["Title"]}" by {model["Creator"]["Username"]} '
f'({model["Creator"]["PURL"]}) {model["Licence"]}'
)
return {"path": path, "model": model, "attribution": attribution}import requests, os
def fetch_model(api_key: str, keyword: str, out_dir: str) -> dict:
headers = {"X-Auth-Token": api_key}
r = requests.get(
f"https://api.poly.pizza/v1/search/{keyword}",
headers=headers,
params={"limit": 1}
)
r.raise_for_status()
results = r.json().get("results", [])
if not results:
raise ValueError(f"No models found for '{keyword}'")
model = results[0]
glb = requests.get(model["Download"])
glb.raise_for_status()
safe_name = model["Title"].replace(" ", "_")
path = os.path.join(out_dir, f"{safe_name}.glb")
with open(path, "wb") as f:
f.write(glb.content)
attribution = None
if "CC-BY" in model.get("Licence", ""):
attribution = (
f'"{model["Title"]}" by {model["Creator"]["Username"]} '
f'({model["Creator"]["PURL"]}) {model["Licence"]}'
)
return {"path": path, "model": model, "attribution": attribution}.glbDownloadFBXThumbnailDownloadFBXThumbnail