Skip to content

jyggen/go-metron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-metron

go-metron is an API client enabling Go programs to interact with Metron.

Features

Caching

go-metron can optionally use heuristic caching.

Filtering

go-metron supports all filtering capabilities of Metron's API.

Pagination

go-metron will automatically fetch the next page while iterating over results.

Rate Limiting

go-metron will at most make 30 requests per minute and 10,000 requests per day, adhering to Metron's API guidelines.

Example Usage

package main

import (
	"context"
	"fmt"
	"time"

	"cloud.google.com/go/civil"
	"github.com/jyggen/go-metron"
)

func main() {
	c := metron.NewClient(
		metron.WithAuthentication("username", "password"),
		metron.WithCaching(""),
		metron.WithTimeout(10 * time.Second),
	)

	after, _ := civil.ParseDate("2021-06-07")
	before, _ := civil.ParseDate("2021-06-13")

	// Get all Marvel comics for the week of 2021-06-07
	for i, err := range c.Issues(
		context.Background(),
		metron.FilterByStoreDateRangeAfter(after),
		metron.FilterByStoreDateRangeBefore(before),
		metron.FilterByPublisherName("marvel"),
	) {
		if err != nil {
			panic(err)
		}

		fmt.Printf("%d %s\n", i.ID, i.Name)
	}

	// Retrieve the detail for an individual issue
	asm68, err := c.IssueByID(context.Background(), 31660)

	if err != nil {
		panic(err)
	}

	fmt.Println(asm68.Description)
}

About

An API client allowing Go programs to interact with Metron.

Resources

License

Stars

Watchers

Forks

Contributors

Languages