Messages

Generations from Midjourney take some time to complete. In this guide, we'll show you how to accomplish retrieving a result from Midjourney.

The Message model

After sending a request to the API you'll receive a messageId you can use to retrieve the result of your request.

Properties

  • Name
    messageId
    Type
    string
    Description

    The message ID for teh request.


GET/v1/message/:messageId

Get Message

Get the result of a message.

Optional attributes

  • Name
    expireMins (optional parameter)
    Type
    string
    Description

    The number of minutes before the message retrieval expires. Default 10.

Request

POST
/v1/message
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer {token}");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://api.justimagineapi.org/v1/message/:messageId", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

The In Progress Response

Properties

  • Name
    progressImageUrl (coming soon)
    Type
    string
    Description

    The URL of the image that was generated.

  • Name
    progress
    Type
    number
    Description

    The progress of the job.

Response

{
  "progressImageUrl": "https://cdn....",
  "progress": 92
}

The Completion Response

Properties

  • Name
    buttons
    Type
    string
    Description

    A list of buttons that can be used to invoke follow up actions.

  • Name
    buttonMessageId
    Type
    string
    Description

    The message ID of the image that was generated. You need this ID to invoke subsequent follow up actions.

  • Name
    imageUrl
    Type
    string
    Description

    The URL of the image that was generated.

  • Name
    originatingMessageId
    Type
    string
    Description

    The message ID of the original message that was sent to the bot.

  • Name
    content
    Type
    string
    Description

    The content of the original message that was sent to the bot.

  • Name
    ref (optional)
    Type
    string
    Description

    A unique identifier for the job.

Response

{
  "progress": 100,
  "buttons": ["U1", "U2", "U3", "U4", "🔄", "V1", "V2", "V3", "V4"],
  "imageUrl": "",
  "imageUrls": [...],
  "buttonMessageId": "buttonMessageId",
  "originatingMessageId": "originatingMessageId",
  "content": "content",
  "ref": "",
}