Skip to content

Icelain/jokeapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

Official golang wrapper for Sv443's jokeapi.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages