wayback

package
v0.1.31 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package wayback provides a client for the Internet Archive Wayback Machine API.

Index

Constants

View Source
const (

	// MaxItems sets the max items to fetch.
	MaxItems = 10
)

Variables

View Source
var (
	ErrAPIRequestFail     = errors.New("wayback machine: API request failed")
	ErrAlreadyArchived    = errors.New("wayback machine: URL already has archive")
	ErrNoSnapshots        = errors.New("wayback machine: no snapshots found")
	ErrNoVersionAvailable = errors.New("wayback machine: no version available")
	ErrSaveFailed         = errors.New("wayback machine: failed to save snapshot")
	ErrTooManyRecords     = errors.New("wayback machine: too many records")
)

Functions

This section is empty.

Types

type AvailableSnapshot

type AvailableSnapshot struct {
	ArchivedSnapshots struct {
		Closest struct {
			Available bool   `json:"available"`
			URL       string `json:"url"`
			Timestamp string `json:"timestamp"`
			Status    string `json:"status"`
		} `json:"closest"`
	} `json:"archived_snapshots"`
}

AvailableSnapshot represents the Wayback "available" API response.

type OptFn

type OptFn func(*Options)

func WithByYear

func WithByYear(n int) OptFn

WithByYear sets the year of the snapshots to fetch.

func WithLimit

func WithLimit(n int) OptFn

WithLimit sets the maximum number of snapshots to fetch.

type Options

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

type SnapshotInfo

type SnapshotInfo struct {
	ArchiveURL       string `json:"archive_url"`
	ArchiveTimestamp string `json:"timestamp"`
}

SnapshotInfo represents a single CDX snapshot record.

type WaybackMachine

type WaybackMachine struct {
	*Options
	// contains filtered or unexported fields
}

WaybackMachine provides methods to query the Internet Archive Wayback Machine.

func New

func New(opts ...OptFn) *WaybackMachine

New creates a new WaybackMachine with sensible defaults.

func (*WaybackMachine) ClosestSnapshot

func (wm *WaybackMachine) ClosestSnapshot(ctx context.Context, urlStr string) (*SnapshotInfo, error)

ClosestSnapshot returns the closest archived version of a URL.

func (*WaybackMachine) SaveSnapshot

func (wm *WaybackMachine) SaveSnapshot(ctx context.Context, urlStr string) (string, error)

SaveSnapshot requests the Wayback Machine to archive a URL (create new snapshot).

func (*WaybackMachine) Snapshots

func (wm *WaybackMachine) Snapshots(ctx context.Context, urlStr string) ([]SnapshotInfo, error)

Snapshots fetches the last N snapshots for a URL.

Jump to

Keyboard shortcuts

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