osrsapi

package module
v0.0.0-...-e306bd2 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

osrsapi

A library for interacting with the Old School Runescape API.

Usage

package main

import (
	"context"
	"fmt"

	"github.com/joeychilson/osrsapi"
)

func main() {
	client := osrsapi.NewClient()

	item, err := client.Item(context.Background(), 4151)
	if err != nil {
		panic(err)
	}

	fmt.Println(item)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Name  string `json:"name"`
	Rank  int    `json:"rank"`
	Score int    `json:"score"`
}

type ChangeTrend

type ChangeTrend struct {
	Change PercentChange `json:"change"`
	Trend  string        `json:"trend"`
}

type Client

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

func NewClient

func NewClient() *Client

func (*Client) Hiscores

func (c *Client) Hiscores(ctx context.Context, username string, mode GameMode, format ResponseFormat) (*PlayerStats, error)

func (*Client) Item

func (c *Client) Item(ctx context.Context, itemID int) (*Item, error)

func (*Client) ItemGraph

func (c *Client) ItemGraph(ctx context.Context, itemID int) (*GraphData, error)

func (*Client) Items

func (c *Client) Items(ctx context.Context, alpha string, page int) (*Items, error)

type GameMode

type GameMode string
const (
	ModeRegular         GameMode = ""
	ModeIronman         GameMode = "_ironman"
	ModeHardcoreIronman GameMode = "_hardcore_ironman"
	ModeUltimateIronman GameMode = "_ultimate"
	ModeDeadman         GameMode = "_deadman"
	ModeSeasonal        GameMode = "_seasonal"
	ModeTournament      GameMode = "_tournament"
	ModeFreshStart      GameMode = "_fresh_start"
)

type GraphData

type GraphData struct {
	Daily   map[string]int `json:"daily"`
	Average map[string]int `json:"average"`
}

type Item

type Item struct {
	ID          int         `json:"id"`
	Icon        string      `json:"icon"`
	IconLarge   string      `json:"icon_large"`
	Type        string      `json:"type"`
	TypeIcon    string      `json:"typeIcon"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Members     string      `json:"members"`
	Current     PriceTrend  `json:"current"`
	Today       PriceTrend  `json:"today"`
	Day30       ChangeTrend `json:"day30"`
	Day90       ChangeTrend `json:"day90"`
	Day180      ChangeTrend `json:"day180"`
}

type Items

type Items struct {
	Total int `json:"total"`
	Items []struct {
		ID          int        `json:"id"`
		Icon        string     `json:"icon"`
		IconLarge   string     `json:"icon_large"`
		Type        string     `json:"type"`
		TypeIcon    string     `json:"typeIcon"`
		Name        string     `json:"name"`
		Description string     `json:"description"`
		Members     string     `json:"members"`
		Current     PriceTrend `json:"current"`
		Today       PriceTrend `json:"today"`
	} `json:"items"`
}

type PercentChange

type PercentChange float64

func (PercentChange) String

func (pc PercentChange) String() string

func (*PercentChange) UnmarshalJSON

func (pc *PercentChange) UnmarshalJSON(data []byte) error

type PlayerStats

type PlayerStats struct {
	Skills     []Skill    `json:"skills"`
	Activities []Activity `json:"activities"`
}

type Price

type Price int

func (*Price) UnmarshalJSON

func (p *Price) UnmarshalJSON(data []byte) error

type PriceTrend

type PriceTrend struct {
	Price Price  `json:"price"`
	Trend string `json:"trend"`
}

type ResponseFormat

type ResponseFormat string
const (
	FormatCSV  ResponseFormat = "csv"
	FormatJSON ResponseFormat = "json"
)

type Skill

type Skill struct {
	Name       string `json:"name"`
	Rank       int    `json:"rank"`
	Level      int    `json:"level"`
	Experience int    `json:"experience"`
}

Jump to

Keyboard shortcuts

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