Retrieve Pika job status and results

Table of contents

  1. Request Headers
  2. Query Parameter
  3. Responses
  4. Model
  5. Examples
  6. Try It

Use this endpoint to retrieve status and results of

If you specified optional parameter replyUrl you technically do not need to use this endpoint to retrieve results since API will call provided replyUrl once job generation completed.

Important API periodically polls (checks) Discord every 15 to 60 seconds (depending on the load) and updates all currently executed jobs statuses and results. Polling interval is used for safety reasons, aiming to prevent any potential issues with Discord and Pika, such as bans or excessive requests.

Jobs lifespan guaranteed to be at least 31 days, after that they will be expired and may be recycled.

https://api.useapi.net/v1/pika/jobs/?jobid=jobid

Request Headers
Authorization: Bearer {API token}
Query Parameter

jobid is required, use value returned by

Responses
  • 200 OK

    If field status value is created, started or progress wait in a loop for at least 10..30 seconds and retry again. When completed retrieve generated video from attachments field. Field content contains message generated by Pika reflecting current generation parameters and progress. Optional array embeds contains additional information.

    {
        "jobid": "<jobid>",
        "verb": "pika-create",
        "status": "completed",
        "created": "2023-09-09T02:04:49.667Z",
        "updated": "2023-09-09T02:19:20.256Z",
        "prompt": "smiling and blinking",
        "buttons": [ "retry" ],
        "image": { "size": 1628384, "type": "image/png" },
        "discord": "<ABC…secured…xyz>",
        "channel": "<Discord channel id>",
        "maxJobs": 10,
        "messageId": "<Discord message id>",
        "content": "<@Discord user id> Prompt: smiling and blinking --size 100  Image: 1 Attachment  Author: <@Discord user id>)",
        "timestamp": "2023-09-09T02:05:24.991000+00:00",
        "attachments": [
            {
                "url": "<generated video url>",
                "proxy_url": "<generated proxy video url>",
                "width": 768,
                "height": 768,
                "content_type": "<generated video type>",
                "id": "<Discord attachment id>",
                "filename": "<generated video filename>",
                "size": 7204115
            }
        ],
        "code": 200
    }
    
  • 400 Bad Request

    {
        "error": "Query param jobid not provided",
        "code": 400
    }
    
  • 401 Unauthorized

    {
        "error": "Unauthorized",
        "code": 401
    }
    
  • 402 Payment Required

    {
        "error": "Account has no subscription or subscription expired",
        "code": 402
    }
    
  • 404 Not Found

    {
        "error": "Unable to locate job <jobid>",
        "code": 404
    }
    
Model
{ // TypeScript, all fields are optional
  jobid: string,
  parentJobId: string,
  verb: 'pika-create' | 'pika-animate' | 'pika-encrypt_text' | 'pika-encrypt_image' | 'pika-button',
  status: 'created' | 'started' | 'moderated' | 'progress' | 
          'completed' | 'failed' | 'cancelled',
  created: string, // YYYY-MM-DDTHH:mm:ss.sssZ, IS0 8601, UTC
  updated: string, // YYYY-MM-DDTHH:mm:ss.sssZ, IS0 8601, UTC
  prompt: string,
  font: 'MODERN' | 'COMICS' | 'SANS SERIF' | 'BAUHAUS' | 'RETRO',
  message: string | { size: number, type: string },
  image: { size: number, type: string
  },
  button: 'retry',
  buttons: [ 'retry' ],
  discord: string, // Provided for debugging purposes only, contains the first 3 and the last 3 characters of the original value
  channel: string,
  maxJobs: number,
  messageId: string,
  content: string, // Contains message generated by Pika reflecting current generation parameters and progress
  timestamp: string,
  attachments: [
      {
          id: string,
          content_type: string,
          filename: string,
          url: string,
          proxy_url: string,
          size: number,
          width: number,
          height: number
      }
  ],
  embeds: [
      {
          type: string,
          description: string,
          image: {
              url: string,
              proxy_url: string,
              width: number,
              height: number
          }
      }
  ], 
  error: string,
  errorDetails: string,
  code: 200
}
Examples
  • curl https://api.useapi.net/v1/pika/jobs/?jobid=\
       -H "Accept: application/json" \
       -H "Authorization: Bearer …" 
    
  • const token = "API token";
    const jobid = "jobid returned by pika/create, pika/animate, pika/encrypt_text, pika/encrypt_image' or pika/button";      
    const apiUrl = `https://api.useapi.net/v1/pika/jobs/?jobid=${jobid}`; 
    const response = await fetch(apiUrl, {
      headers: {
        "Authorization": `Bearer ${token}`,
      },
    });
    const result = await response.json();
    console.log("response", {response, result});
    
  • import requests
    token = "API token"
    jobid = "jobid returned by pika/create, pika/animate, pika/encrypt_text, pika/encrypt_image' or pika/button"
    apiUrl = f"https://api.useapi.net/v1/pika/jobs/?jobid={jobid}"
    headers = {
        "Content-Type": "application/json", 
        "Authorization" : f"Bearer {token}"
    }
    response = requests.get(apiUrl, headers=headers)
    print(response, response.json())
    
Try It