文档
模版查询接口

查询模特套图模版接口

1. 接口地址

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

2. 请求方式

GET

3. 请求参数

Header

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

Query Params

参数类型是否必填说明
genderstring取值:man或woman
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/variation'

Python示例

import pprint
import requests
import uuid
 
USER_Authorization = <token>
 
# 请求头
headers = {
    'Authorization': f'Bearer {USER_Authorization}'
}
 
# 请求参数
params = {
    "gender": "man",
}
 
# 发送GET请求
url = 'https://hidreamai.com/api-pub/ec/v3/template/variation'
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字段具体为

参数类型说明
genderstring建议此模版适用的模特性别
idint模版ID,发送生图任务时使用
show_imagefloat模版封面图url。注:可在地址后拼接参数?width=512获取特定大小的图

示例:

{
    "code": 0,
    "message": "Success",
    "request_id": "a9e6ae3b-f038-4e0f-8564-5c5dbc6a152b",
    "result": {
        "page_index": 1,
        "page_size": 2,
        "templates": [
            {
                "gender": "woman",
                "id": 98,
                "show_image": "https://storage.hidreamai.com/image/p_eaa744c8-283e-489c-ab6b-994c7596cd83.jpg"
            },
            {
                "gender": "woman",
                "id": 97,
                "show_image": "https://storage.hidreamai.com/image/p_389237ca-c145-4485-b8c6-1cd13ca15f15.jpg"
            }
        ],
        "total_count": 98,
        "total_page": 49
    }
}