Quick Start

A quick look on all the functions that this library has to offer!

Generating a random cat image

To generate a random cat image, you can use the randomImage function. This function returns the URL of the image.

src/index.js
import { randomImage } from "@kittyjs/kitty-js"

async function main() {
  const url = await randomImage();
  console.log(url);
}

main()

Why are we calling randomImage in a wrapper function? It's because the await keyword cannot be used in a top-level statement in JavaScript. But this can be avoided if you're using ES7+ JavaScript.

Cat Breeds

We can get information about various cat breeds using 2 options:

  • catBreeds() --> Lists various cat breeds sorted alphabetically.

  • catBreed() --> Lists one cat breed using the search query.

Using catBreeds()

catBreeds() returns an alphabetical array of Breed objects. You can control the limit by passing in the limit parameter.

import { catBreeds } from "@kittyjs/kitty-js";

const main = async () => {
  const breeds = await catBreeds(10); // gimme only 10 breeds
  console.log(breeds);
}

main();

The output from this code will look something like this:

[
  {
    weight: { imperial: '7  -  10', metric: '3 - 5' },
    id: 'abys',
    name: 'Abyssinian',
    cfa_url: 'http://cfa.org/Breeds/BreedsAB/Abyssinian.aspx',
    vetstreet_url: 'http://www.vetstreet.com/cats/abyssinian',
    vcahospitals_url: 'https://vcahospitals.com/know-your-pet/cat-breeds/abyssinian',
    temperament: 'Active, Energetic, Independent, Intelligent, Gentle',
    origin: 'Egypt',
    country_codes: 'EG',
    country_code: 'EG',
    description: 'The Abyssinian is easy to care for, and a joy to have in your home. They’re affectionate cats and love both people and other animals.',
    life_span: '14 - 15',
    indoor: 0,
    lap: 1,
    alt_names: '',
    adaptability: 5,
    affection_level: 5,
    child_friendly: 3,
    dog_friendly: 4,
    energy_level: 5,
    grooming: 1,
    health_issues: 2,
    intelligence: 5,
    shedding_level: 2,
    social_needs: 5,
    stranger_friendly: 5,
    vocalisation: 1,
    experimental: 0,
    hairless: 0,
    natural: 1,
    rare: 0,
    rex: 0,
    suppressed_tail: 0,
    short_legs: 0,
    wikipedia_url: 'https://en.wikipedia.org/wiki/Abyssinian_(cat)',
    hypoallergenic: 0,
    reference_image_id: '0XYvRd7oD',
    image: {
      id: '0XYvRd7oD',
      width: 1204,
      height: 1445,
      url: 'https://cdn2.thecatapi.com/images/0XYvRd7oD.jpg'
    }
  },
  {
    weight: { imperial: '7 - 10', metric: '3 - 5' },
    id: 'aege',
    name: 'Aegean',
    vetstreet_url: 'http://www.vetstreet.com/cats/aegean-cat',
    temperament: 'Affectionate, Social, Intelligent, Playful, Active',
    origin: 'Greece',
    country_codes: 'GR',
    country_code: 'GR',
    description: 'Native to the Greek islands known as the Cyclades in the Aegean Sea, these are natural cats, meaning they developed without humans getting involved in their breeding. As a breed, Aegean Cats are rare, although they are numerous on their home islands. They are generally friendly toward people and can be excellent cats for families with children.',
    life_span: '9 - 12',
    indoor: 0,
    alt_names: '',
    adaptability: 5,
    affection_level: 4,
    child_friendly: 4,
    dog_friendly: 4,
    energy_level: 3,
    grooming: 3,
    health_issues: 1,
    intelligence: 3,
    shedding_level: 3,
    social_needs: 4,
    stranger_friendly: 4,
    vocalisation: 3,
    experimental: 0,
    hairless: 0,
    natural: 0,
    rare: 0,
    rex: 0,
    suppressed_tail: 0,
    short_legs: 0,
    wikipedia_url: 'https://en.wikipedia.org/wiki/Aegean_cat',
    hypoallergenic: 0,
    reference_image_id: 'ozEvzdVM-',
    image: {
      id: 'ozEvzdVM-',
      width: 1200,
      height: 800,
      url: 'https://cdn2.thecatapi.com/images/ozEvzdVM-.jpg'
    }
  }

Using catBreed()

catBreed() returns a Breed object with the name similar to the query parameter.

import { catBreed } from "@kittyjs/kitty-js"

const main = async () => {
  const siamese = await catBreed("siame"); // get info about siamese cats
  console.log(siamese);
}

main();

The output will look something like this:

{
  weight: { imperial: '8 - 15', metric: '4 - 7' },
  id: 'siam',
  name: 'Siamese',
  cfa_url: 'http://cfa.org/Breeds/BreedsSthruT/Siamese.aspx',
  vetstreet_url: 'http://www.vetstreet.com/cats/siamese',
  vcahospitals_url: 'https://vcahospitals.com/know-your-pet/cat-breeds/siamese',
  temperament: 'Active, Agile, Clever, Sociable, Loving, Energetic',
  origin: 'Thailand',
  country_codes: 'TH',
  country_code: 'TH',
  description: 'While Siamese cats are extremely fond of their people, they will follow you around and supervise your every move, being talkative and opinionated. They are a demanding and social cat, that do not like being left alone for long periods.',
  life_span: '12 - 15',
  indoor: 0,
  lap: 1,
  alt_names: 'Siam, Thai Cat',
  adaptability: 5,
  affection_level: 5,
  child_friendly: 4,
  dog_friendly: 5,
  energy_level: 5,
  grooming: 1,
  health_issues: 1,
  intelligence: 5,
  shedding_level: 2,
  social_needs: 5,
  stranger_friendly: 5,
  vocalisation: 5,
  experimental: 0,
  hairless: 0,
  natural: 0,
  rare: 0,
  rex: 0,
  suppressed_tail: 0,
  short_legs: 0,
  wikipedia_url: 'https://en.wikipedia.org/wiki/Siamese_(cat)',
  hypoallergenic: 1,
  reference_image_id: 'ai6Jps4sx'
}

Get an image of a cat breed

The function catBreedImage returns the URL of an image of the breed given by the user.

import { catBreedImage } from "@kittyjs/kitty-js";

const main = async () => {
  const img = await catBreedImage("norweg"); // gimme an image of a norwegian forest
  console.log(img);
}

Get specific information about a breed

The function catBreedImage returns the URL of an image of the breed given by the user.

import { 
  catBreedDescription,
  catBreedChildFriendliness,
  breedTemparament,
  breedAffection,
  breedIntelligence,
  breedLifeSpan
} from "@kittyjs/kitty-js";

const main = async () => {
  const desc = await catBreedDescription("norweg"); // gimme the description of a norwegian forest
  // output: The Norwegian Forest Cat is a sweet, loving cat. She appreciates praise and loves to interact with her parent. She makes a loving companion and bonds with her parents once she accepts them for her own. She is still a hunter at heart. She loves to chase toys as if they are real. She is territorial and patrols several times each day to make certain that all is fine.
  
  const cf = await catBreedChildFriendliness("norweg") // How friendly is the cat with kids, on a scale of 1-5?
  // output: 4
  
  const temp = await breedTemparament("norweg"); // self-explanatory
  // output: Sweet, Active, Intelligent, Social, Playful, Lively, Curious
  
  const affekshun = await breedAffection("norweg") // how affectionate it is, on a scale of 1-5
  // output: 5
  
  const intelligence = await breedIntelligence("norweg") // how "intelligent" the cat is, on a scale of 1-5
  // output: 4
  
  const lifeSpan = await breedLifeSpan("norweg") // life-span in years
  // output: 12 - 16
}

main();

Last updated