查询模特类型模版接口
1. 接口地址
https://hidreamai.com/api-pub/ec/v3/template/model/human
2. 请求方式
GET
3. 请求参数
Header
参数 | 类型 | 是否必填 | 说明 |
---|---|---|---|
Authorization | string | 是 | 客户授权Token |
Query Params
参数 | 类型 | 是否必填 | 说明 |
---|---|---|---|
page_size | int | 否 | 数据分页参数,每页最大数据量,默认20, 最大100 |
page_index | int | 否 | 数据分页参数, 当前页数, 默认1 |
curl示例
curl -H 'Authorization: Bearer {USER_Authorization}' -X GET
-v 'https://hidreamai.com/api-pub/ec/v3/template/commerical'
Python示例
import pprint
import requests
import uuid
USER_Authorization = <token>
# 请求头
headers = {
'Authorization': f'Bearer {USER_Authorization}'
}
# 请求参数
params = {
"page_size": 50,
"page_index": 1
}
# 发送GET请求
url = 'https://hidreamai.com/api-pub/ec/v3/template/commerical'
response = requests.get(url, headers=headers, params=params)
# 处理响应
if response.status_code == 200:
if response.json()['code'] == 0:
results = response.json()['result']
pprint.pprint(results['templates'], indent=4)
print(f"total count is: {results['total_count']}")
else:
print(response.json()['code'], response.json()['message'])
else:
print(response.status_code)
4. 返回参数
参数 | 类型 | 说明 |
---|---|---|
code | int | 返回状态码 |
message | string | 返回状态信息 |
request_id | string | 本次请求的ID |
result | dict | 返回结果 |
其中返回结果 result
字段具体为:
参数 | 类型 | 说明 |
---|---|---|
templates | list | 模版信息列表 |
total_count | int | 模版总数量 |
total_page | int | 按当前分页后的总页数 |
其中templates
字段,具体为
参数 | 类型 | 说明 |
---|---|---|
id | str | 模版ID,发送生图任务时使用 |
show_image | string | 展示图。注:可在地址后拼接参数?width=512获取特定大小的图 |
name_zh | string | 中文名称 |
name_en | string | 英文名称 |
category_en | string | 英文类别名称 |
category_zh | string | 中文类别名称 |
location_desc | dict | 模版定义的位置描述信息 |
size | string | 模版定义的商品大小。商品长边与背景画布对应边的比例 |
custom_template | bool | 是否为自定义模版 |
negative_prompt | string | 负向提示词,custom_template is True时,无此字段 |
prompt | string | 提示词。custom_template is True时,无此字段 |
其中location_desc字段具体为
参数 | 类型 | 说明 |
---|---|---|
horizontal_direction | str | 水平位置描述。AlignLeft:商品图左边距背景图左边的比例; AlignCenter: 水平方向居中; AlignRight: 商品图右边距背景图右边的比例 |
horizontal_proportion | float | 水平方向位置占比。商品水平方向位置占比,AlignLeft和AlignRight的比例取值范围均为0-1(不含边界)的小数,AlignCenter=0.5 |
vertical_direction | string | 垂直方向位置描述。AlignTop:商品图上顶边距背景图上顶边的比例; AlignCenter: 垂直方向居中 AlignBottom: 商品图下底边距背景图下底边的比例 |
vertical_proportion | float | 商品垂直方向位置占比。AlignTop和AlignBottom的比例取值范围均为0-1(不含边界)的小数, AlignCenter=0.5 |
示例:
{
"code": 0,
"message": "Success",
"request_id": "c0e6bfde-7c8d-44b2-9ef4-7c7ac4e4390d",
"result": {
"page_index": 1,
"page_size": 2,
"templates": [
{
"category_en": "Studio",
"category_zh": "展台",
"custom_template": true,
"id": "58c1f1cb-fa91-4e8e-87d2-b2af66e475e6",
"location_desc": {
"horizontal_direction": "AlignLeft",
"horizontal_proportion": 0.3,
"vertical_direction": "AlignTop",
"vertical_proportion": 0.48
},
"name_en": "胡子造型及工具",
"name_zh": "胡子造型及工具",
"negative_prompt": "",
"prompt": "it is sitting on the barber countertop in the barbershop, with hairdressing tools behind it in the background, blurred background, extreme close-up view, overhead view,bright color",
"show_image": "https://storage.hidreamai.com/image/p_eb5e9a42-b024-11ee-9b25-ee2a3dcf5bcf.jpg",
"size": 0.4
},
{
"category_en": "Studio",
"category_zh": "展台",
"custom_template": false,
"id": 1436,
"name_en": "Marble",
"name_zh": "大理石展台",
"show_image": "https://storage.hidreamai.com/image/p_c021dd0c-e28a-45b6-840b-cc90c0e8d6eb.jpg"
}
],
"total_count": 46,
"total_page": 23
}
}
附
商品图位置描述示例
使用商品的边距对应背景边的比例描述进行定位商品的位置,水平方向和垂直方向各使用一个描述,如下图:
示例: 使用距右侧40%、距底部20%,则描述信息为:
{
"horizontal_direction": "AlignRight",
"horizontal_proportion": 0.4,
"vertical_direction": "AlignBottom",
"vertical_proportion": 0.2
}
使用距左侧30%、距上侧40%,则描述信息为:
{
"horizontal_direction": "AlignLeft",
"horizontal_proportion": 0.3,
"vertical_direction": "AlignTop",
"vertical_proportion": 0.4
}