查询任务
更新时间
7 天前
接口描述
查询已提交的任务的状态和结果。
请求
TIP
{api_url}
为你实际使用的 API 节点,请根据实际情况填写。例如:
www.dmxapi.cn
www.dmxapi.com
ssvip.dmxapi.com
请求方式: GET
请求地址:
/mj/task/{task_id}/fetch
例如针对 提交任务 API:
https://{api_url}/mj/task/{task_id}/fetch
请求参数
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
task_id | string | 是 | 任务ID |
代码示例
深色背景为可以修改的参数,非必选参数已经注释,可以按照自己的需求启用。
py
import http.client
import json
# 配置全局变量
API_URL = "www.dmxapi.cn" # API 节点
DMX_API_TOKEN = "sk-XXXXXXXXXXXXX" # API 密钥
# 创建HTTP连接对象,用于后续所有API请求
conn = http.client.HTTPSConnection(API_URL)
def query_midjourney_task_api(task_id):
# 设置 Request headers
headers = {
'Authorization': f'Bearer {DMX_API_TOKEN}',
'Content-Type': 'application/json'
}
# 根据请求接口,构建完整的查询路径,包含task_id参数
query_path = f"/mj/task/{task_id}/fetch"
try:
# request 请求规范:方法, URL, body, headers
conn.request("GET", query_path, None, headers)
# 获取响应并解析JSON数据
res = conn.getresponse()
json_data = json.loads(res.read().decode("utf-8"))
return json_data
except Exception as e:
print(f"query midjourney task api error: {e}")
if __name__ == "__main__":
task_id = "1747132423020537" # 替换为你的实际任务ID
print(query_midjourney_task_api(task_id))
响应参数示例
{
"id": "1747132423020537",
"action": "IMAGINE",
"customId": "",
"botType": "",
"prompt": "这是一个视频截图,请生成对应的吉卜力风格的图片",
"promptEn": "http://upload.mjdjourney.top/fileSystem/mj/133/2025/05/13/1747132422998780679_3218.png This is a video screenshot, please generate the corresponding Ghibli style image",
"description": "提交成功",
"state": "",
"mode": "",
"proxy": "",
"submitTime": 1747132423020,
"startTime": 1747132424482,
"finishTime": 1747132463701,
"imageUrl": "https://cdn.gptbest.vip/mj/attachments/1371679336578420847/1371797719932469310/bodnarovataisiia_This_is_a_video_screenshot_please_generate_the_6dc7beb8-8310-4fd4-b46c-716b422ddffc.png?ex=682471af&is=6823202f&hm=f7bcaa9bf369b81525fda9c1320bd98633c20e21bbbf7c003dbc99911a317f2c&",
"imageHeight": 0,
"imageWidth": 0,
"status": "SUCCESS",
"progress": "100%",
"failReason": "",
"buttons": [
{
"customId": "MJ::JOB::upsample::1::6dc7beb8-8310-4fd4-b46c-716b422ddffc",
"emoji": "",
"label": "U1",
"type": 2,
"style": 2
},
{
"customId": "MJ::JOB::upsample::2::6dc7beb8-8310-4fd4-b46c-716b422ddffc",
"emoji": "",
"label": "U2",
"type": 2,
"style": 2
},
{
"customId": "MJ::JOB::upsample::3::6dc7beb8-8310-4fd4-b46c-716b422ddffc",
"emoji": "",
"label": "U3",
"type": 2,
"style": 2
},
{
"customId": "MJ::JOB::upsample::4::6dc7beb8-8310-4fd4-b46c-716b422ddffc",
"emoji": "",
"label": "U4",
"type": 2,
"style": 2
},
{
"customId": "MJ::JOB::reroll::0::6dc7beb8-8310-4fd4-b46c-716b422ddffc::SOLO",
"emoji": "🔄",
"label": "",
"type": 2,
"style": 2
},
{
"customId": "MJ::JOB::variation::1::6dc7beb8-8310-4fd4-b46c-716b422ddffc",
"emoji": "",
"label": "V1",
"type": 2,
"style": 2
},
{
"customId": "MJ::JOB::variation::2::6dc7beb8-8310-4fd4-b46c-716b422ddffc",
"emoji": "",
"label": "V2",
"type": 2,
"style": 2
},
{
"customId": "MJ::JOB::variation::3::6dc7beb8-8310-4fd4-b46c-716b422ddffc",
"emoji": "",
"label": "V3",
"type": 2,
"style": 2
},
{
"customId": "MJ::JOB::variation::4::6dc7beb8-8310-4fd4-b46c-716b422ddffc",
"emoji": "",
"label": "V4",
"type": 2,
"style": 2
}
],
"maskBase64": "",
"properties": {
"notifyHook": "string",
"flags": 0,
"messageId": "1371797720431464448",
"messageHash": "6dc7beb8-8310-4fd4-b46c-716b422ddffc",
"nonce": "1922238820857864192",
"customId": "",
"finalPrompt": "<https://s.mj.run/RdNm0xs6fRI> This is a video screenshot, please generate the corresponding Ghibli style image --fast",
"progressMessageId": "1371797720431464448",
"messageContent": "**<https://s.mj.run/RdNm0xs6fRI> This is a video screenshot, please generate the corresponding Ghibli style image --fast** - <@1364921896055083058> (fast)",
"discordInstanceId": "1371679336578420847",
"discordChannelId": "1371679336578420847"
}
}