osrswiki

package module
v0.0.0-...-a68244d Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: MIT Imports: 8 Imported by: 0

README

osrswiki

A library for interacting with the Old School Runescape Wiki API.

Usage

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/joeychilson/osrswiki"
)

func main() {
	client := osrswiki.NewClient("osrswiki-cli/0.0.1")

	data, err := client.Timeseries(context.Background(), osrswiki.WorldRegular, osrswiki.FiveMinutes, 4151)
	if err != nil {
		log.Fatalf("error getting latest prices: %v", err)
	}

	fmt.Println(data)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(userAgent string) *Client

func (*Client) ItemMapping

func (c *Client) ItemMapping(ctx context.Context, world World) ([]ItemMapping, error)

func (*Client) LatestPrices

func (c *Client) LatestPrices(ctx context.Context, world World, itemIDs ...int16) (map[int16]LatestPrice, error)

func (*Client) PriceData

func (c *Client) PriceData(ctx context.Context, world World, interval TimeInterval, timestamp *time.Time) (map[int16]PriceData, error)

func (*Client) Timeseries

func (c *Client) Timeseries(ctx context.Context, world World, timestep TimeInterval, itemID int16) ([]TimeseriesData, error)

type ItemMapping

type ItemMapping struct {
	ID       int    `json:"id"`
	Icon     string `json:"icon"`
	Name     string `json:"name"`
	Examine  string `json:"examine"`
	Members  bool   `json:"members"`
	Value    int    `json:"value"`
	HighAlch int    `json:"highalch"`
	LowAlch  int    `json:"lowalch"`
	Limit    int    `json:"limit"`
}

type LatestPrice

type LatestPrice struct {
	High     int64 `json:"high"`
	HighTime int64 `json:"highTime"`
	Low      int64 `json:"low"`
	LowTime  int64 `json:"lowTime"`
}

type PriceData

type PriceData struct {
	AvgHighPrice    int64 `json:"avgHighPrice"`
	HighPriceVolume int64 `json:"highPriceVolume"`
	AvgLowPrice     int64 `json:"avgLowPrice"`
	LowPriceVolume  int64 `json:"lowPriceVolume"`
}

type TimeInterval

type TimeInterval string
const (
	FiveMinutes     TimeInterval = "5m"
	OneHour         TimeInterval = "1h"
	SixHours        TimeInterval = "6h"
	TwentyFourHours TimeInterval = "24h"
)

type TimeseriesData

type TimeseriesData struct {
	Timestamp       int64 `json:"timestamp"`
	AvgHighPrice    int64 `json:"avgHighPrice"`
	AvgLowPrice     int64 `json:"avgLowPrice"`
	HighPriceVolume int64 `json:"highPriceVolume"`
	LowPriceVolume  int64 `json:"lowPriceVolume"`
}

type World

type World string
const (
	WorldRegular    World = "osrs"
	WorldDeadman    World = "dmm"
	WorldFreshStart World = "fsw"
)

Jump to

Keyboard shortcuts

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