文档
查询模版信息接口

查询模特类型模版接口

1. 接口地址

https://hidreamai.com/api-pub/ec/v3/template/model/human

2. 请求方式

GET

3. 请求参数

Header

参数类型是否必填说明
Authorizationstring客户授权Token

Query Params

参数类型是否必填说明
page_sizeint数据分页参数,每页最大数据量,默认20, 最大100
page_indexint数据分页参数, 当前页数, 默认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. 返回参数

参数类型说明
codeint返回状态码
messagestring返回状态信息
request_idstring本次请求的ID
resultdict返回结果

其中返回结果 result字段具体为:

参数类型说明
templateslist模版信息列表
total_countint模版总数量
total_pageint按当前分页后的总页数

其中templates字段,具体为

参数类型说明
idstr模版ID,发送生图任务时使用
show_imagestring展示图。注:可在地址后拼接参数?width=512获取特定大小的图
name_zhstring中文名称
name_enstring英文名称
category_enstring英文类别名称
category_zhstring中文类别名称
location_descdict模版定义的位置描述信息
sizestring模版定义的商品大小。商品长边与背景画布对应边的比例
custom_templatebool是否为自定义模版
negative_promptstring负向提示词,custom_template is True时,无此字段
promptstring提示词。custom_template is True时,无此字段

其中location_desc字段具体为

参数类型说明
horizontal_directionstr水平位置描述。AlignLeft:商品图左边距背景图左边的比例;
AlignCenter: 水平方向居中;
AlignRight: 商品图右边距背景图右边的比例
horizontal_proportionfloat水平方向位置占比。商品水平方向位置占比,AlignLeft和AlignRight的比例取值范围均为0-1(不含边界)的小数,AlignCenter=0.5
vertical_directionstring垂直方向位置描述。AlignTop:商品图上顶边距背景图上顶边的比例;
AlignCenter: 垂直方向居中
AlignBottom: 商品图下底边距背景图下底边的比例
vertical_proportionfloat商品垂直方向位置占比。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
}