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.

The output from this code will look something like this:

Using catBreed()

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

The output will look something like this:

Get an image of a cat breed

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

Get specific information about a breed

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

Last updated