SwapFace API
TTAPI SwapFace face-changing service
Create SwapFace
POST
https://api.ttapi.io/insightFace/v1/swap
Create a face swap request. Task results is async
Headers
Name | Type | Description |
---|---|---|
TT-API-KEY* | String | Your API Key in TT API used for request authorization |
Request Body
Name | Type | Required | Description |
---|---|---|---|
targetImage | String | true | URL(jpg,jpeg,png,webp) string for the image whose face will be swapped with the swap_image face |
swapImage | String | true | URL(jpg,jpeg,png,webp) string for the image whose face will be swapped with |
hookUrl | String | false | Send a request to the address for task completion or failed notification. If not set you need to request fetch endpoint to get response |
Example Request
import requests
endpoint = "https://api.ttapi.io/insightFace/v1/swap"
headers = {
"TT-API-KEY": your_key
}
data = {
"targetImage": "https://cdnb.ttapi.io/2024-04-23/tar_image.jpg",
"swapImage": "https://cdnb.ttapi.io/2024-04-23/face_image.jpg",
"hookUrl": "https://webhook-test.com/10ffa7e6d1e6886e746d19a5458d167d"
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.status_code)
print(response.json())
Example Response
{
"status": "SUCCESS",
"message": "",
"data": {
"jobId": "SWAP-FACE-171349414479347616"
}
}
Fetch SwapFace
POST/GET
https://api.ttapi.io/insightFace/v1/fetch
Get the face-changing task result query, the returned json data is same with the return in hookUrl
Headers
Name | Type | Description |
---|---|---|
TT-API-KEY* | String | Your API Key in TT API used for request authorization |
Request Body / Query param
Name | Type | Required | Description |
---|---|---|---|
jobId | String | true | SWAP-FACE-171349414479347616 |
Example Request
import requests
endpoint = "https://api.ttapi.io/insightFace/v1/fetch"
headers = {
"TT-API-KEY": your_key
}
data = {
"jobId": "SWAP-FACE-171349414479347616",
}
response = requests.post(endpoint, headers=headers, json=data)
print(response.status_code)
print(response.json())
Async callback & fetch json
{
"status": "SUCCESS",
"jobId": "SWAP-FACE-171383611748093575",
"data": {
"jobId": "SWAP-FACE-171383611748093575",
"targetImage": "https://cdnb.ttapi.io/2024-04-23/tar_image.jpg",
"swapImage": "https://cdnb.ttapi.io/2024-04-23/face_image.jpg",
"discordImage": "https://cdn.discordapp.com/attachments/1225427359679909939/1232142735067054162/fef8556fdd514b29b42f7c464cb4efb9_ins.jpg?ex=662861d8&is=66271058&hm=91e513ad6a48350f1c97a3bb367e1f1902bf26265bc1de5ac0968afcaa94e93f&",
"cdnImage": "https://mjcdn.ttapi.io/attachments/1225427359679909939/1232142735067054162/fef8556fdd514b29b42f7c464cb4efb9_ins.jpg?ex=662861d8&is=66271058&hm=91e513ad6a48350f1c97a3bb367e1f1902bf26265bc1de5ac0968afcaa94e93f&",
"hookUrl": "https://webhook-test.com/10ffa7e6d1e6886e746d19a5458d167d",
"quota": 2
}
}