Skip to content

Official golang wrapper for Sv443's jokeapi.

License

Notifications You must be signed in to change notification settings

mihkelparna1/jokeapi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jokeapi-go

Official golang wrapper for Sv443's jokeapi.

Install- go get -u github.com/icelain/jokeapi

Basic Usage Without Parameters-

import "github.com/icelain/jokeapi"

func main(){
  api, err := jokeapi.New()
  
  if err != nil {
  	panic(err)
  }
  
  response := 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, err := jokeapi.New()
  
  if err != nil {
  	panic(err)
  }
  
  api.SetParams(&ctgs, &blacklist, &jt)
  response := api.Fetch()
}

Usage without all parameters(requires other params to be declared as nil)-

api.SetParams(&ctgs,nil, nil)

Or-

api.SetBlacklist(&blacklist)
api.SetCategory(&ctgs)
api.SetType(&joketype)

About

Official golang wrapper for Sv443's jokeapi.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%