This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
e621-sdk-go/example/lowlevel/tag.go
2023-10-16 21:48:14 +02:00

66 lines
1.4 KiB
Go

package main
import (
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/endpoints"
"git.dragse.it/anthrove/e621-to-graph/pkg/e621/model"
"log"
"net/http"
)
func main() {
requestContext := model.RequestContext{
Host: "https://e621.net",
UserAgent: "Go-e621-SDK (selloo)",
Username: "selloo",
APIKey: "XTkB5doD22vmMXr3yoNurQGH",
}
log.Println("Getting single tag: ")
client := http.Client{}
tag, err := endpoints.GetTag(client, requestContext, "1530")
if err != nil {
log.Println(err)
}
log.Println(tag.Name)
log.Println("----------")
log.Println("Getting list of tags: ")
query := map[string]string{
"limit": "5",
}
tagList, err := endpoints.GetTags(client, requestContext, query)
if err != nil {
log.Println(err)
}
log.Println(len(tagList))
log.Println("----------")
log.Println("seach for tags containing cat: ")
query = map[string]string{
"limit": "5",
"search[name_matches]": "cat*",
}
tagList, err = endpoints.GetTags(client, requestContext, query)
if err != nil {
log.Println(err)
}
log.Println(tagList)
log.Println("----------")
log.Println("seach for tags with the category artist: ")
query = map[string]string{
"limit": "5",
"search[category]": "1",
}
tagList, err = endpoints.GetTags(client, requestContext, query)
if err != nil {
log.Println(err)
}
log.Println(tagList)
log.Println("----------")
}