查询接口
GET v1/mj/task/{id}/fetch通过任务id,查询任务信息。(可以通过轮询调用该接口,实现任务进行的查询。也可以通过回调接口获取)
请求参数
Authorization
在 Header 添加参数 Authorization,其值为在 Bearer 之后拼接 Token。
Authorization: Bearer ******************path 参数
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| id | string | 必填 | 任务id |
返回响应
200 成功
Content-Type: application/json
响应参数
| 字段名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| action | string | 必需 | 当前任务的执行动作(例如:IMAGINE 生成, UPSCALE 放大, VARIATION 变化)。 |
| buttons | array [object] | 必需 | 关联的交互按钮列表(如 U1-U4, V1-V4 等),通常包含 customId, label, style, type, emoji 等子字段。 |
| description | string | 必需 | 任务的详细描述信息。 |
| failReason | string | 必需 | 如果任务失败,这里会包含失败的具体原因。 |
| finishTime | integer | 必需 | 任务结束时的 Unix 时间戳。 |
| id | string | 必需 | 任务的唯一标识符(Task ID)。 |
| imageUrl | string | 必需 | 生成图片的最终访问地址(URL)。 |
| progress | string | 必需 | 任务当前的进度(例如 "100%" 或具体描述)。 |
| prompt | string | 必需 | 用户输入的原始提示词。 |
| promptEn | string | 必需 | 翻译后的英文提示词(因为 Midjourney 核心模型通常使用英文)。 |
| properties | object | 必需 | 扩展属性对象,包含其他未列出的具体参数。 |
| startTime | integer | 必需 | 任务开始执行时的 Unix 时间戳。 |
| state | string | 必需 | 自定义状态参数,通常由调用方传入并在回调中原样返回。 |
| status | string | 必需 | 任务当前的状态(例如:SUBMITTED, IN_PROGRESS, FINISHED, FAILURE)。 |
| submitTime | integer | 必需 | 任务提交时的 Unix 时间戳。 |
| customId | string | 可选 | 按钮的唯一标识,用于后续交互回调。 |
| emoji | string | 可选 | 按钮上显示的 Emoji 图标。 |
| label | string | 可选 | 按钮上显示的文本标签。 |
| style | integer | 可选 | 按钮的样式(如主色调、灰色等)。 |
| type | integer | 可选 | 组件类型(如按钮类型)。 |
响应示例
{
"action": "IMAGINE",
"buttons": [
{
"customId": "string",
"emoji": "string",
"label": "string",
"style": 0,
"type": 0
}
],
"description": "string",
"failReason": "string",
"finishTime": 0,
"id": "string",
"imageUrl": "string",
"progress": "string",
"prompt": "string",
"promptEn": "string",
"properties": {},
"startTime": 0,
"state": "string",
"status": "NOT_START",
"submitTime": 0
}示例代码
python
import http.client
import json
conn = http.client.HTTPSConnection("nxaiapp.com")
payload = json.dumps({})
headers = {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
}
conn.request("GET", "/v1/mj/task//fetch", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))