package main import ( "git.dragse.it/anthrove/e621-sdk-go/pkg/e621/endpoints" "git.dragse.it/anthrove/e621-sdk-go/pkg/e621/model" "io" "log" "net/http" "os" ) func main() { // Define the request context with essential information. requestContext := model.RequestContext{ Client: http.Client{}, Host: "https://e621.net", UserAgent: "Go-e621-SDK (@username)", Username: os.Getenv("API_USER"), // Replace with your username APIKey: os.Getenv("API_KEY"), // Replace with your API key } log.Println("Getting a list of DB Exports: ") dbExportFiles, err := endpoints.GetDBExportList(requestContext) if err != nil { panic(err) } log.Printf("%d files found", len(dbExportFiles)) for _, v := range dbExportFiles { log.Printf("File found: %s", v) } exportFileName := dbExportFiles[0] log.Println("Downloading DB export") log.Printf("File to download: %s", exportFileName) rawFile, err := endpoints.GetDBExportFile(requestContext, exportFileName) file, err := os.Create(exportFileName) if err != nil { panic(err) } defer file.Close() _, err = io.Copy(file, rawFile) if err != nil { panic(err) } log.Printf("File %s downloaded", exportFileName) }