boredapi

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 boredapi is the library behind the boredapi command line: the HTTP client, request shaping, and typed data models for the Bored API.

The Client sets a real User-Agent, paces requests, and retries transient failures (429 and 5xx) with exponential backoff. One operation is provided: get a random activity suggestion, with optional filters by type, participants, or key.

Index

Constants

View Source
const BaseURL = "https://" + Host

BaseURL is the root every request is built from.

View Source
const Host = "bored.api.lewagon.com"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Key           string `kit:"id" json:"key"`
	Activity      string `json:"activity"`
	Type          string `json:"type"`
	Participants  int    `json:"participants"`
	Price         string `json:"price"`
	Accessibility string `json:"accessibility"`
	Link          string `json:"link"`
}

Activity is the public output record for the activity operation.

type ActivityFilter

type ActivityFilter struct {
	Type         string
	Participants int
	Key          string
}

ActivityFilter holds optional query parameters for GetActivity.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to the Bored API over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) GetActivity

func (c *Client) GetActivity(ctx context.Context, f ActivityFilter) (*Activity, error)

GetActivity returns a random activity, optionally filtered.

type Config

type Config struct {
	BaseURL   string
	UserAgent string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
}

Config holds tunable knobs for the HTTP client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults for production use.

type Domain

type Domain struct{}

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

func (Domain) Classify

func (Domain) Classify(input string) (string, string, error)

Classify turns a reference into (type, id). A key is a numeric string.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, hostnames, and the identity used in help and version.

func (Domain) Locate

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

Locate returns the live API URL for a (type, id) pair.

func (Domain) Register

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

Register installs the client factory and all operations onto app.

Jump to

Keyboard shortcuts

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