Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Icelain/jokeapi
Official golang wrapper for Sv443's jokeapi.
https://github.com/Icelain/jokeapi
api-client api-wrapper go golang jokeapi
Last synced: about 1 month ago
JSON representation
Official golang wrapper for Sv443's jokeapi.
- Host: GitHub
- URL: https://github.com/Icelain/jokeapi
- Owner: Icelain
- License: mit
- Created: 2020-11-22T10:43:16.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-12-30T03:34:02.000Z (12 months ago)
- Last Synced: 2024-08-03T19:09:59.885Z (5 months ago)
- Topics: api-client, api-wrapper, go, golang, jokeapi
- Language: Go
- Homepage:
- Size: 83 KB
- Stars: 23
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go-extra - jokeapi - 11-22T10:43:16Z|2022-04-28T14:33:11Z| (Third-party APIs / Fail injection)
README
# jokeapi-go
[![GoDoc](https://godoc.org/github.com/icelain?status.png)](https://godoc.org/github.com/icelain/jokeapi)
[![Go Report Card](https://goreportcard.com/badge/github.com/icelain/jokeapi)](https://goreportcard.com/report/github.com/icelain/jokeapi)
[![Test Coverage](https://gocover.io/_badge/github.com/icelain/jokeapi)](https://gocover.io/github.com/icelain/jokeapi)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)Official golang wrapper for Sv443's jokeapi.
Install-
Add ```github.com/icelain/jokeapi```to your go.mod(recommended) or:
```
EXPORT GO11MODULE=off
go get -u github.com/icelain/jokeapi
```Basic Usage Without Parameters-
```go
import "github.com/icelain/jokeapi"func main(){
api := jokeapi.New()
response, err := api.Fetch()
}
```
Response Struct-
```go
type JokesResp struct{
Error bool
Category string
JokeType string
Joke []string
Flags map[string] bool
Id float64
Lang string
}
```Usage with all parameters-
```go
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-
```go
api.Set(jokeapi.Params{})
```
Config methods-
```go
api.SetBlacklist(blacklist)
api.SetCategories(ctgs)
api.SetJokeType(joketype)
api.SetLang(language)
```