To make use of our API versioning, you need to include the desired version in the Accept-Version header of your API requests. This header allows you to explicitly specify the version of the API you want to interact with, ensuring that your code remains compatible and predictable, even as newer versions become available.
If you do not specify a version, the api will use the latest available, this behaviour may break your app if breaking changes has been released.
import requests
url = 'https://api.waifu.im/search'
headers = {
'Accept-Version': 'v6'
}
response = requests.get(url, headers=headers)
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';
const headers = new Headers();
headers.append('Accept-Version', 'v6');
fetch(apiUrl, { headers })
.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);
});