8000 GitHub - go-api-libs/cat-facts: Go library for the Cat Fact API. An API that shows different Cat Facts!
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

go-api-libs/cat-facts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

😽 Cat Fact API

Go Reference Official Documentation OpenAPI Go Report Card Code Coverage API Health License: MIT

An API that shows different Cat Facts! (Source)

Installation

To install the library, use the following command:

go get github.com/go-api-libs/cat-facts/pkg/catfacts

Usage

Example 1: Get random animal facts

package main

import (
	"context"

	"github.com/go-api-libs/cat-facts/pkg/catfacts"
)

func main() {
	c, err := catfacts.NewClient()
	if err != nil {
		panic(err)
	}

	ctx := context.Background()
	facts, err := c.GetRandom(ctx, catfacts.GetRandomParams{
		Amount:     2,
		AnimalType: "cat",
	})
	if err != nil {
		panic(err)
	}

	// Use facts slice
}

Example 2: Get a fact by its ID

package main

import (
	"context"

	"github.com/go-api-libs/cat-facts/pkg/catfacts"
)

func main() {
	c, err := catfacts.NewClient()
	if err != nil {
		panic(err)
	}

	ctx := context.Background()
	fact, err := c.GetFactByID(ctx, "591f9890d369931519ce3564")
	if err != nil {
		panic(err)
	}

	// Use fact object
}

Additional Information

Contributing

If you have any contributions to make, please submit a pull request or open an issue on the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Releases

No releases published

Packages

No packages published
0