The Animals API provides interesting scientific facts on thousands of different animal species.
HTTP GET
Returns up to 10 results matching the input name parameter.
name
(required) - common name of animal to search. This parameter supports partial matches (e.g. fox
will match gray fox
and red fox
)
X-Api-Key
(required) - API Key associated with your account.
Live Demo!
https://api.api-ninjas.com/v1/animals?name=
[
{
"name": "Cheetah",
"taxonomy": {
"kingdom": "Animalia",
"phylum": "Chordata",
"class": "Mammalia",
"order": "Carnivora",
"family": "Felidae",
"genus": "Acinonyx",
"scientific_name": "Acinonyx jubatus"
},
"locations": [
"Africa",
"Asia",
"Eurasia"
],
"characteristics": {
"prey": "Gazelle, Wildebeest, Hare",
"name_of_young": "Cub",
"group_behavior": "Solitary/Pairs",
"estimated_population_size": "8,500",
"biggest_threat": "Habitat loss",
"most_distinctive_feature": "Yellowish fur covered in small black spots",
"gestation_period": "90 days",
"habitat": "Open grassland",
"diet": "Carnivore",
"average_litter_size": "3",
"lifestyle": "Diurnal",
"common_name": "Cheetah",
"number_of_species": "5",
"location": "Asia and Africa",
"slogan": "The fastest land mammal in the world!",
"group": "Mammal",
"color": "BrownYellowBlackTan",
"skin_type": "Fur",
"top_speed": "70 mph",
"lifespan": "10 - 12 years",
"weight": "40kg - 65kg (88lbs - 140lbs)",
"height": "115cm - 136cm (45in - 53in)",
"age_of_sexual_maturity": "20 - 24 months",
"age_of_weaning": "3 months"
}
}
]
import requests
name = 'cheetah'
api_url = 'https://api.api-ninjas.com/v1/animals?name={}'.format(name)
response = requests.get(api_url, headers={'X-Api-Key': 'YOUR_API_KEY'})
if response.status_code == requests.codes.ok:
print(response.text)
else:
print("Error:", response.status_code, response.text)
var name = 'cheetah'
$.ajax({
method: 'GET',
url: 'https://api.api-ninjas.com/v1/animals?name=' + name,
headers: { 'X-Api-Key': 'YOUR_API_KEY'},
contentType: 'application/json',
success: function(result) {
console.log(result);
},
error: function ajaxError(jqXHR) {
console.error('Error: ', jqXHR.responseText);
}
});
const request = require('request');
var name = 'cheetah';
request.get({
url: 'https://api.api-ninjas.com/v1/animals?name=' + name,
headers: {
'X-Api-Key': 'YOUR_API_KEY'
},
}, function(error, response, body) {
if(error) return console.error('Request failed:', error);
else if(response.statusCode != 200) return console.error('Error:', response.statusCode, body.toString('utf8'));
else console.log(body)
});
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import com.fasterxml.jackson.databind.ObjectMapper;
URL url = new URL("https://api.api-ninjas.com/v1/animals?name=cheetah");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("accept", "application/json");
InputStream responseStream = connection.getInputStream();
ObjectMapper mapper = new ObjectMapper();
JsonNode root = mapper.readTree(responseStream);
System.out.println(root.path("fact").asText());
let name = "cheetah".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
let url = URL(string: "https://api.api-ninjas.com/v1/animals?name="+name!)!
var request = URLRequest(url: url)
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "X-Api-Key")
let task = URLSession.shared.dataTask(with: request) {(data, response, error) in
guard let data = data else { return }
print(String(data: data, encoding: .utf8)!)
}
task.resume()