No description
Find a file
2023-06-19 15:35:33 +02:00
nimcatapi fixed typo in source 2023-06-19 15:35:33 +02:00
tests jesus christ, this sucked - added proper breed support 2023-06-19 15:03:48 +02:00
.gitignore jesus christ, this sucked - added proper breed support 2023-06-19 15:03:48 +02:00
LICENSE added licence 2023-05-29 21:34:25 +02:00
nimcatapi.nim calm before the storm... adding support for thedogapi 2023-06-18 15:13:27 +02:00
nimcatapi.nimble fixed .nimble file 2023-06-19 15:27:12 +02:00
README.md updated docs 2023-06-19 15:23:46 +02:00
run_tests.sh fixed .nimble file 2023-06-19 15:27:12 +02:00
update_docs.sh updated docs functionality 2023-06-13 01:57:18 +02:00

nimcatapi

About

nimcatapi is a library that lets you easily request images from thecatapi and/or thedogapi.

Installation

nimble install nimcatapi

To use it in your projects, include requires "nimcatapi" in your .nimble file and import it!

Usage

Most of the functionality works without a token. If you however would like to request a specific amount of images (except just one or ten), you will need to request an API token: thecatapi / thedogapi

Requesting images

You can easily request one or multiple random images.

import std/options
import nimcatapi

# Both APIs work the same way:
let
    cats*: TheCatApi = newCatApiClient(token = "meow")
    dogs*: TheDogApi = newDogApiClient() # works without a token as well!

# A single image:
let singleImage*: string = cats.requestImageUrl()

# Multiple images (without token you can only request 1 or 10 images, with a token 1-100):
let multipleImages*: seq[string] = cats.requestImageUrls(10)

# Customise search patterns:
let customImages*: seq[string] = cats.requestImageUrls(
    size = sizeFull,
    formats = @[formatGif, formatJpg, formatPng],
    amount = 5
)

# Same but with Request object (used internally):
let customImagesWithObj*: seq[string] = cats.requestImageUrls(Request(
    size: some sizeFull,
    mime_types: some @[formatGif, formatJpg, formatPng],
    limit: some 5
))

Requesting breeds

Requesting breeds functions the same across both APIs, however you will get differently structured responses.

import nimcatapi

let
    dogs: TheDogApi = newDogApiClient()
    breeds: seq[DogBreed] = dogs.requestBreeds()
echo "Got " & breeds.len() & " dog breeds!"

For proper documentation about DogBreed and CatBreed objects, please visit the docs!

Documentation

For detiled documentation, please visit the nim generated docs page!