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/note.go

58 lines
1.4 KiB
Go
Raw Normal View History

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() {
// Define the request context with essential information.
requestContext := model.RequestContext{
Host: "https://e621.net",
UserAgent: "Go-e621-SDK (@username)",
Username: "", // Replace with your username
APIKey: "", // Replace with your API key
}
// Log: Getting a single note.
log.Println("Getting single note: ")
// Initialize an http.Client.
client := http.Client{}
// Specify the note ID for retrieval.
noteID := "36957" // Replace with the desired note's ID.
// Call the GetNote function to retrieve the specified note.
note, err := endpoints.GetNote(client, requestContext, noteID)
if err != nil {
log.Println(err)
} else {
// Log the body of the retrieved note.
log.Println(note.Body)
}
log.Println("----------")
// Log: Getting a list of notes.
log.Println("Getting a list of notes: ")
// Define query parameters for retrieving a list of notes.
query := map[string]string{
"limit": "5",
}
// Call the GetNotes function to retrieve a list of notes based on the query parameters.
notes, err := endpoints.GetNotes(client, requestContext, query)
if err != nil {
log.Println(err)
} else {
// Log the number of notes retrieved.
log.Println(len(notes))
}
log.Println("----------")
}