• Stars
    star
    22
  • Rank 1,013,154 (Top 21 %)
  • Language
    Go
  • License
    MIT License
  • Created over 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Official golang wrapper for Sv443's jokeapi.

jokeapi-go

GoDoc Go Report Card Test Coverage Mentioned in Awesome Go

Official golang wrapper for Sv443's jokeapi.

Install- Add github.com/icelain/jokeapito your go.mod(recommended) or:

EXPORT GO11MODULE=off
go get -u github.com/icelain/jokeapi

Basic Usage Without Parameters-

import "github.com/icelain/jokeapi"

func main(){
  api := jokeapi.New()
  response, err := api.Fetch()
}

Response Struct-

type JokesResp struct{
	Error bool
	Category string
	JokeType string
	Joke []string
	Flags map[string] bool
	Id float64
	Lang string
}

Usage with all parameters-

import "github.com/icelain/jokeapi"

func main(){
  jt := "single"
  blacklist := []string{"nsfw"}
  ctgs := []string{"Programming","Dark"}
  
  api:= jokeapi.New()
  
  api.Set(jokeapi.Params{Blacklist: blacklist, JokeType: jt, Categories: ctgs})
  response, err := api.Fetch()
}

Config struct-

api.Set(jokeapi.Params{})

Config methods-

api.SetBlacklist(blacklist)
api.SetCategories(ctgs)
api.SetJokeType(joketype)
api.SetLang(language)