Retrieve InsightFaceSwap 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 InsightFaceSwap, 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/faceswap/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 images or video from attachments array. Field content contains message generated by InsightFaceSwap reflecting current generation parameters and progress. Optional array embeds contains additional information.

    {
        "jobid": "<jobid>",
        "verb": "faceswap-headshot",
        "status": "completed",
        "created": "2023-09-09T02:04:49.667Z",
        "updated": "2023-09-09T02:19:20.256Z",
        "prompt": "me, a mad king with an evil smile, wearing medieval royal blue attire and a crown. --no green --square",
        "discord": "<ABC…secured…xyz>",
        "server": "<Discord server id>",
        "channel": "<Discord channel id>",
        "messageId": "<Discord message id>",
        "content": "<@Discord user id>  Picsi.Ai Headshot Job Submitted [jobid: 8a1f574fdbf79e8cd57e070476d9d5f3] [credits: 4] [prompt: 'a mad king with an evil smile, wearing medieval royal blue attire and a crown. --no green --square'] [time: <time>] [SaveID: 'me'] (796/800 credits remaining)",
        "timestamp": "2023-09-09T02:05:24.991000+00:00",
        "attachments": [
            {
                "url": "<generated image url>",
                "proxy_url": "<generated proxy image url>",
                "width": 768,
                "height": 768,
                "content_type": "<generated image type>",
                "id": "<Discord attachment id>",
                "filename": "<generated image 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
    }
    
  • 410 Gone

    {
        "error": "Job has expired",
        "code": 410
    }
    
Model
{ // TypeScript, all fields are optional
  jobid: string,
  parentJobId: string,
  verb:  'faceswap-changebg' | 'faceswap-headshot' | 'faceswap-picsi' |
         'faceswap-swapid' | 'faceswap-saveid' | 'faceswap-setid' | 'faceswap-INSwapper' | 
         'faceswap-listid' | 'faceswap-delall' | 'faceswap-delid' | 'faceswap-swap',
  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,
  a_background_photo_of: string,
  options: string,
  image: { size: number, type: string  },
  source_image: { size: number, type: string  },
  target_image_gif_or_video: { size: number, type: string  },
  idname: string,
  saveid_idname: string,
  saveid_image: { size: number, type: string  },
  swapid_idname: string,
  swapid_image: { size: number, type: string  },
  targetMessageId: string,
  discord: string, // Provided for debugging purposes only, contains the first 3 and the last 3 characters of the original value
  server: string,
  channel: string,
  messageId: string,
  content: string, // Contains message generated by InsightFaceSwap 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/faceswap/jobs/?jobid=\
       -H "Accept: application/json" \
       -H "Authorization: Bearer …" 
    
  • const token = "API token";
    const jobid = "jobid returned by faceswap/changebg, faceswap/headshot or faceswap/picsi";      
    const apiUrl = `https://api.useapi.net/v1/faceswap/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 faceswap/changebg, faceswap/headshot or faceswap/picsi"
    apiUrl = f"https://api.useapi.net/v1/faceswap/jobs/?jobid={jobid}"
    headers = {
        "Content-Type": "application/json", 
        "Authorization" : f"Bearer {token}"
    }
    response = requests.get(apiUrl, headers=headers)
    print(response, response.json())
    
Try It