获取全部类别的部分词条信息

1. 接口地址

https://www.hidreamai.com/api-pub/dc/v1/phrases

 

2. 请求方式

GET

 

3. 请求参数

Header

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

Query Params

参数 类型 是否必填 说明
size int 获取每个分类的词条数据量, 最大值50

curl示例

curl -H 'Authorization: Bearer {USER_Authorization}' -X GET 
-v 'https://www.hidreamai.com/api-pub/dc/v1/phrases?size=20'

Python示例

import requests
import json
import uuid

USER_Authorization = <token>  # 获取方式详见接口文档https://www.hidreamai.com/docs/pixeling/user/token.html


# 请求头
headers = {
    'Authorization': f'Bearer {USER_Authorization}'
}

# 请求参数
size = 20

# 发送GET请求
url = f'https://www.hidreamai.com/api-pub/dc/v1/phrases?size={size}'
response = requests.get(url, headers=headers)

# 处理响应
if response.status_code == 200:
    if response.json()['code'] == 0:
        result = response.json()['result']
        print(result)
    else:
        print(response.json()['message'])
else:
    print(response.status_code)

 

4. 返回参数

参数 类型 说明
code int 返回状态码
message string 返回状态信息
request_id string 本次请求的ID
result list 返回结果

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

参数 类型 说明
category_zh string 中文类别名称
category_en string 英文类别名称
phrases list 当前分类的词条信息

result字段中phrases字段具体为:

参数 类型 说明
phrase_en string 词条的英文名称
phrase_zh string 词条的中文名称
image string 词条的示意图url

示例:

{
    "code": 0,
    "message": "Success",
    "request_id": "db6f69e2-8f32-4e77-996f-23797863e170",
    "result": [
        {
            "category_zh": "配色",
            "category_en": "Color",
            "phrases": [
                {
                    "phrase_en": "Lavender",
                    "phrase_zh": "薰衣草色",
                    "image": "https://storage.hidreamai.com/image/p_68286058-775e-11ee-9959-9a031c994b02.jpg"
                },
                {
                    "phrase_en": "Reflections Transparent Iridescent Colors",
                    "phrase_zh": "反射透明彩虹色",
                    "image": "https://storage.hidreamai.com/image/p_79da83da-775e-11ee-a06a-5a045ac7ac09.jpg"
                }
            ]
        },
        {
            "category_zh": "构图",
            "category_en": "Composition",
            "phrases": [
                {
                    "phrase_en": "Canon",
                    "phrase_zh": "佳能",
                    "image": "https://storage.hidreamai.com/image/p_64d1ffb4-28f0-4e7f-a179-1718b9d470ef.jpg"
                },
                {
                    "phrase_en": "Fujifilm",
                    "phrase_zh": "富士",
                    "image": "https://storage.hidreamai.com/image/p_4e1021f5-3146-47aa-86ae-e7aeb2821bd8.jpg"
                }
            ]
        }
    ]
}

results matching ""

    No results matching ""

    results matching ""

      No results matching ""