A Go wrapper for the Jikan v4 API.
Notice: Jikan v4 introduces breaking changes. You will need to make changes to your code when upgrading to v1.2.0+.
Documentation can be found at go.dev.
To install/update: go install github.com/darenliang/jikan-go@latest
To import: import "github.com/darenliang/jikan-go"
and use as jikan
package main
import (
"fmt"
"github.com/darenliang/jikan-go"
)
func main() {
// Get anime
anime, err := jikan.GetAnimeById(1)
if err != nil {
panic(err)
}
fmt.Println(anime.Data.Title)
}
Output:
Cowboy Bebop
Please refer to the official Jikan API documentation for clarification on query parameters.
package main
import (
"fmt"
"github.com/darenliang/jikan-go"
"net/url"
)
func main() {
// Setup query
query := url.Values{}
query.Set("q", "Cowboy Bebop")
query.Set("type", "tv")
// Search anime
search, err := jikan.GetAnimeSearch(query)
if err != nil {
panic(err)
}
fmt.Println(search.Data[0].Score)
}
Output:
8.79
If it is necessary to modify the http client (eg. modify timeout), you can
access the client via jikan.Client
.
Example: setting the client timeout from 60 seconds (default) to 10 seconds.
jikan.Client.Timeout = time.Second * 10