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/highlevel/post.go

46 lines
1.0 KiB
Go
Raw Normal View History

package main
import (
"git.dragse.it/anthrove/e621-sdk-go/pkg/e621"
_ "github.com/joho/godotenv/autoload"
"log"
"os"
)
func main() {
client := e621.NewE621Client(os.Getenv("API_USER"), os.Getenv("API_KEY"))
posts, err := client.GetPosts().Execute()
if err != nil {
log.Panic(err)
}
log.Printf("Post 0 has following tags: %s", posts[0].Tags)
postWithTags, err := client.GetPosts().Tags("fennec male solo order:score").Execute()
if err != nil {
log.Panic(err)
}
log.Printf("Post 0 with tags has following ID: %d", postWithTags[0].ID)
post, err := client.GetPostByID(1337).Execute()
if err != nil {
log.Panic(err)
}
log.Printf("Post 1337 has following tags: %s", post.Tags)
postBuilder := client.GetPosts()
posts1, err := client.GetNPosts(600, postBuilder)
if err != nil {
log.Panic(err)
}
log.Println(len(posts1))
postBuilder = client.GetPosts().Tags("how_to_dragon_your_train")
posts, err = client.GetAllPosts(postBuilder)
if err != nil {
log.Panic(err)
}
log.Println(len(posts))
}