digimon

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package digimon is the library behind the digimon command line: the HTTP client, request shaping, and the typed data models for the Digimon API at digi-api.com.

The Client sets a real User-Agent, paces requests so a busy session stays polite, and retries transient failures (429 and 5xx). Build your endpoint calls and JSON decoding on top of it.

Index

Constants

View Source
const DefaultUserAgent = "digimon/dev (+https://github.com/tamnd/digimon-cli)"

DefaultUserAgent identifies the client to digi-api.com.

View Source
const Host = "digi-api.com"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP      *http.Client
	UserAgent string
	// Rate is the minimum gap between requests. Zero means no pacing.
	Rate    time.Duration
	Retries int
	// contains filtered or unexported fields
}

Client talks to the Digimon API over HTTP.

func NewClient

func NewClient() *Client

NewClient returns a Client with sensible defaults.

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) ([]byte, error)

Get fetches url and returns the response body. It paces and retries according to the client settings. The body is read fully and closed here.

func (*Client) GetDigimon

func (c *Client) GetDigimon(ctx context.Context, nameOrID string) (*Digimon, error)

GetDigimon fetches full details for a single Digimon by name or numeric ID.

func (*Client) ListDigimon

func (c *Client) ListDigimon(ctx context.Context, limit int) ([]DigimonStub, error)

ListDigimon returns up to limit Digimon stubs from the first page.

func (*Client) SearchDigimon

func (c *Client) SearchDigimon(ctx context.Context, name string, limit int) ([]DigimonStub, error)

SearchDigimon returns up to limit Digimon stubs matching name.

type Digimon

type Digimon struct {
	ID          int      `kit:"id" json:"id"`
	Name        string   `json:"name"`
	Level       string   `json:"level"`
	Type        string   `json:"type"`
	Attribute   string   `json:"attribute"`
	Description string   `json:"description" kit:"body"`
	ReleaseDate string   `json:"release_date"`
	Image       string   `json:"image"`
	Skills      []string `json:"skills"`
	NextEvos    []string `json:"next_evolutions"`
	PriorEvos   []string `json:"prior_evolutions"`
}

Digimon is the full record returned by the digimon command.

type DigimonStub

type DigimonStub struct {
	ID    int    `kit:"id" json:"id"`
	Name  string `json:"name"`
	Image string `json:"image"`
}

DigimonStub is the lightweight record returned by list and search.

type Domain

type Domain struct{}

Domain is the Digimon API driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns any accepted input into the canonical (type, id) pair. A pure numeric string maps to ("id", input); a word-like string maps to ("name", input). Full digi-api.com URLs are unwrapped first.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse: the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL