Waifu.im API Docs
  • Introduction
  • Quick Start
  • Versioning
  • Rate Limiting
  • Tags
  • Authentication
  • Permissions
  • Authorization
  • Resources
  • Contact us
  • Reference
    • API Reference
      • Tags
      • Search
      • Favorites
      • Report
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub

Quick Start

PreviousIntroductionNextVersioning

Last updated 1 year ago

Was this helpful?

This small tutorial will only provide you with minimal knowledge of the API, if you wish to learn more just continue reading the docs step by step

Alternatively you can also use one of the packages mentioned in

Get a random image

The easiest and most common way to use the API is to get a random waifu images.

Here is an example to get a random image with the raiden-shogun and maid tags with an height superior or equal to 2000 pixels:

curl -X GET \
  'https://api.waifu.im/search?included_tags=raiden-shogun&included_tags=maid&height=>=2000' \
  -H 'Content-Type: application/json'
import requests

url = 'https://api.waifu.im/search'
params = {
    'included_tags': ['raiden-shogun', 'maid'],
    'height': '>=2000'
}

response = requests.get(url, params=params)

if response.status_code == 200:
    data = response.json()
    # Process the response data as needed
else:
    print('Request failed with status code:', response.status_code)
const apiUrl = 'https://api.waifu.im/search';  // Replace with the actual API endpoint URL
const params = {
  included_tags: ['raiden-shogun', 'maid'],
  height: '>=2000'
};

const queryParams = new URLSearchParams();

for (const key in params) {
  if (Array.isArray(params[key])) {
    params[key].forEach(value => {
      queryParams.append(key, value);
    });
  } else {
    queryParams.set(key, params[key]);
  }
}
const requestUrl = `${apiUrl}?${queryParams.toString()}`;

fetch(requestUrl)
  .then(response => {
    if (response.ok) {
      return response.json();
    } else {
      throw new Error('Request failed with status code: ' + response.status);
    }
  })
  .then(data => {
    // Process the response data as needed
    console.log(data);
  })
  .catch(error => {
    console.error('An error occurred:', error.message);
  });

It is recommended to checkout the API Reference.

You can find a more detailed guide for this route here :

Packages
#search-images.