import requestsurl ='https://api.waifu.im/fav'headers ={'Accept-Version':'v5','Authorization':'Bearer TjBY0MBcS3-SEc3Ms6T4GKjHGJkbqM6McejlQdnqo2y47jWNLa4agsWYdJukocDqHpm2zYFO5z2AjMzkUSfLsCz1AgbDhSjKLMIOnhJGFgODgOkSnzaAWzvGZZPdbm6vOTxs2chmz-3DSRVzwQLl__eYE4Wnjtr0aIGzXlo82M0',}response = requests.get(url, headers=headers)if response.status_code ==200: data = response.json()# Process the response data as neededelse:print('Request failed with status code:', response.status_code)
constapiUrl='https://api.waifu.im/fav';constheaders=newHeaders();headers.append('Accept-Version','v5');headers.append('Authorization','Bearer TjBY0MBcS3-SEc3Ms6T4GKjHGJkbqM6McejlQdnqo2y47jWNLa4agsWYdJukocDqHpm2zYFO5z2AjMzkUSfLsCz1AgbDhSjKLMIOnhJGFgODgOkSnzaAWzvGZZPdbm6vOTxs2chmz-3DSRVzwQLl__eYE4Wnjtr0aIGzXlo82M0');fetch(apiUrl, { headers }).then(response => {if (response.ok) {returnresponse.json(); } else {thrownewError('Request failed with status code: '+response.status); } }).then(data => {// Process the response data as neededconsole.log(data); }).catch(error => {console.error('An error occurred:',error.message); });
Manage your favorites
Inserts an image into the user
POSThttps://api.waifu.im/fav/insert
Requires
manage_favorites
permission.
Headers
Name
Type
Description
Authorization*
string
Bearer followed by a space and your token
Request Body
Name
Type
Description
image_id*
integer
The ID of the image to insert.
user_id
integer
The user ID of the user whose favorites you want to edit.
{"state":"INSERTED"}
{"detail":"Bad Request"}
{"detail":"Unauthorized"}
{"detail":"Forbidden"}
{"detail":"Not Found"}
{"detail":"The image you provided is already in the user favorites, consider using /fav/toggle instead."}
{"detail":"Internal Server Error"}
Here is an example to insert the image ID 8008 into your favorites:
import requestsurl ='https://api.waifu.im/fav/insert'headers ={'Accept-Version':'v5','Authorization':'Bearer TjBY0MBcS3-SEc3Ms6T4GKjHGJkbqM6McejlQdnqo2y47jWNLa4agsWYdJukocDqHpm2zYFO5z2AjMzkUSfLsCz1AgbDhSjKLMIOnhJGFgODgOkSnzaAWzvGZZPdbm6vOTxs2chmz-3DSRVzwQLl__eYE4Wnjtr0aIGzXlo82M0','Content-Type':'application/json',}data ={'image_id':8008}response = requests.post(url, headers=headers, json=data)if response.status_code ==200: data = response.json()# Process the response data as neededelse:print('Request failed with status code:', response.status_code)
constapiUrl='https://api.waifu.im/fav/insert';constheaders=newHeaders();headers.append('Accept-Version','v5');headers.append('Authorization','Bearer TjBY0MBcS3-SEc3Ms6T4GKjHGJkbqM6McejlQdnqo2y47jWNLa4agsWYdJukocDqHpm2zYFO5z2AjMzkUSfLsCz1AgbDhSjKLMIOnhJGFgODgOkSnzaAWzvGZZPdbm6vOTxs2chmz-3DSRVzwQLl__eYE4Wnjtr0aIGzXlo82M0');headers.append('Content-Type','application/json');constdata= { image_id:8008};fetch(apiUrl, { method:'POST', headers: headers, body:JSON.stringify(data)}).then(response => {if (response.ok) {returnresponse.json(); } else {thrownewError('Request failed with status code: '+response.status); } }).then(data => {// Process the response data as neededconsole.log(data); }).catch(error => {console.error('An error occurred:',error.message); });
Removes an image from the user
POSThttps://api.waifu.im/fav/delete
Requires
manage_favorites
permission.
Headers
Name
Type
Description
Authorization*
string
Bearer followed by a space and your token
Request Body
Name
Type
Description
image_id*
integer
The ID of the image to remove.
user_id
integer
The user ID of the user whose favorites you want to edit.
{"state":"DELETED"}
{"detail":"Bad Request"}
{"detail":"Unauthorized"}
{"detail":"Forbidden"}
{"detail":"Not Found"}
{"detail":"Internal Server Error"}
Here is an example to remove the image ID 8008 from your favorites:
import requestsurl ='https://api.waifu.im/fav/delete'headers ={'Accept-Version':'v5','Authorization':'Bearer TjBY0MBcS3-SEc3Ms6T4GKjHGJkbqM6McejlQdnqo2y47jWNLa4agsWYdJukocDqHpm2zYFO5z2AjMzkUSfLsCz1AgbDhSjKLMIOnhJGFgODgOkSnzaAWzvGZZPdbm6vOTxs2chmz-3DSRVzwQLl__eYE4Wnjtr0aIGzXlo82M0','Content-Type':'application/json',}data ={'image_id':8008}response = requests.post(url, headers=headers, json=data)if response.status_code ==200: data = response.json()# Process the response data as neededelse:print('Request failed with status code:', response.status_code)
constapiUrl='https://api.waifu.im/fav/delete';constheaders=newHeaders();headers.append('Accept-Version','v5');headers.append('Authorization','Bearer TjBY0MBcS3-SEc3Ms6T4GKjHGJkbqM6McejlQdnqo2y47jWNLa4agsWYdJukocDqHpm2zYFO5z2AjMzkUSfLsCz1AgbDhSjKLMIOnhJGFgODgOkSnzaAWzvGZZPdbm6vOTxs2chmz-3DSRVzwQLl__eYE4Wnjtr0aIGzXlo82M0');headers.append('Content-Type','application/json');constdata= { image_id:8008};fetch(apiUrl, { method:'POST', headers: headers, body:JSON.stringify(data)}).then(response => {if (response.ok) {returnresponse.json(); } else {thrownewError('Request failed with status code: '+response.status); } }).then(data => {// Process the response data as neededconsole.log(data); }).catch(error => {console.error('An error occurred:',error.message); });
Toggles an image in the user
POSThttps://api.waifu.im/fav/toggle
If the image is already in the user's favorites, it will be removed. If it was not in the favorites, it will be inserted.
Requires manage_favorites permission.
Headers
Name
Type
Description
Authorization*
string
Bearer followed by a space and your token
Request Body
Name
Type
Description
image_id*
integer
The ID of the image to toggle.
user_id
integer
The user ID of the user whose favorites you want to edit.
{"state":"DELETED"}
{"state":"INSERTED"}
{"detail":"Bad Request"}
{"detail":"Unauthorized"}
{"detail":"Forbidden"}
{"detail":"Not Found"}
{"detail":"Internal Server Error"}
Here is an example to toggle the image ID 8008 from your favorites:
import requestsurl ='https://api.waifu.im/fav/toggle'headers ={'Accept-Version':'v5','Authorization':'Bearer TjBY0MBcS3-SEc3Ms6T4GKjHGJkbqM6McejlQdnqo2y47jWNLa4agsWYdJukocDqHpm2zYFO5z2AjMzkUSfLsCz1AgbDhSjKLMIOnhJGFgODgOkSnzaAWzvGZZPdbm6vOTxs2chmz-3DSRVzwQLl__eYE4Wnjtr0aIGzXlo82M0','Content-Type':'application/json',}data ={'image_id':8008}response = requests.post(url, headers=headers, json=data)if response.status_code ==200: data = response.json()# Process the response data as neededelse:print('Request failed with status code:', response.status_code)
constapiUrl='https://api.waifu.im/fav/toggle';constheaders=newHeaders();headers.append('Accept-Version','v5');headers.append('Authorization','Bearer TjBY0MBcS3-SEc3Ms6T4GKjHGJkbqM6McejlQdnqo2y47jWNLa4agsWYdJukocDqHpm2zYFO5z2AjMzkUSfLsCz1AgbDhSjKLMIOnhJGFgODgOkSnzaAWzvGZZPdbm6vOTxs2chmz-3DSRVzwQLl__eYE4Wnjtr0aIGzXlo82M0');headers.append('Content-Type','application/json');constdata= { image_id:8008};fetch(apiUrl, { method:'POST', headers: headers, body:JSON.stringify(data)}).then(response => {if (response.ok) {returnresponse.json(); } else {thrownewError('Request failed with status code: '+response.status); } }).then(data => {// Process the response data as neededconsole.log(data); }).catch(error => {console.error('An error occurred:',error.message); });