查询模特套图模版接口
1. 接口地址
https://hidreamai.com/api-pub/ec/v3/template/variation
2. 请求方式
GET
3. 请求参数
Header
参数 | 类型 | 是否必填 | 说明 |
---|---|---|---|
Authorization | string | 是 | 客户授权Token |
Query Params
参数 | 类型 | 是否必填 | 说明 |
---|---|---|---|
gender | string | 否 | 取值:man或woman |
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/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. 返回参数
参数 | 类型 | 说明 |
---|---|---|
code | int | 返回状态码 |
message | string | 返回状态信息 |
request_id | string | 本次请求的ID |
result | dict | 返回结果 |
其中返回结果 result
字段具体为:
参数 | 类型 | 说明 |
---|---|---|
templates | list | 模版信息列表 |
total_count | int | 模版总数量 |
total_page | int | 按当前分页后的总页数 |
其中templates
字段具体为
参数 | 类型 | 说明 |
---|---|---|
gender | string | 建议此模版适用的模特性别 |
id | int | 模版ID,发送生图任务时使用 |
show_image | float | 模版封面图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
}
}