Skip to content

Latest commit

 

History

History
227 lines (167 loc) · 3.64 KB

File metadata and controls

227 lines (167 loc) · 3.64 KB

Raider.io API Go wrapper

Go Reference Go Build & Test

Wrapper for the raider.io API written in Go

Usage

Add the module

go get github.com/tmaffia/raiderio

Authentication

The Raider.IO API provides higher rate limits for authenticated requests. You can generate an API key by registering your application on the Raider.IO Application Settings page.

package main

import "github.com/tmaffia/raiderio"

func main() {
	_ = raiderio.NewClient("YOUR_API_KEY")
}

NewClient() with no argument works for unauthenticated requests.

Get a Character Profile

package main

import (
	"context"
	"fmt"

	"github.com/tmaffia/raiderio"
)

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

	profile, err := client.GetCharacter(context.Background(), &raiderio.CharacterQuery{
		Region:        raiderio.US,
		Realm:         "illidan",
		Name:          "thehighvalue",
		TalentLoadout: true,
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(profile.Class) // Mage
}

Get a Guild Profile

package main

import (
	"context"
	"fmt"

	"github.com/tmaffia/raiderio"
)

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

	profile, err := client.GetGuild(context.Background(), &raiderio.GuildQuery{
		Region:  raiderio.US,
		Realm:   "illidan",
		Name:    "warpath",
		Members: true,
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(profile.Name)
}

Get Raid Rankings for a specific raid

package main

import (
	"context"
	"fmt"

	"github.com/tmaffia/raiderio"
)

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

	rankings, err := client.GetRaidRankings(context.Background(), &raiderio.RaidRankingsQuery{
		RaidQuery: raiderio.RaidQuery{
			Slug:       "nerubar-palace",
			Difficulty: raiderio.MYTHIC_RAID,
			Region:     raiderio.US,
		},
		Limit: 10,
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(len(rankings.RaidRanking))
}

Get Static Raid data by expansion

package main

import (
	"context"
	"fmt"

	"github.com/tmaffia/raiderio"
)

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

	raids, err := client.GetRaids(context.Background(), raiderio.WAR_WITHIN)
	if err != nil {
		panic(err)
	}

	fmt.Println(len(raids.Raids))
}

Get the current Mythic+ affixes

package main

import (
	"context"
	"fmt"

	"github.com/tmaffia/raiderio"
)

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

	affixes, err := client.GetMythicPlusAffixes(context.Background(), &raiderio.AffixesQuery{
		Region: raiderio.US,
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(affixes.Title)
}

Get a character's Mythic+ score

package main

import (
	"context"
	"fmt"

	"github.com/tmaffia/raiderio"
)

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

	profile, err := client.GetCharacter(context.Background(), &raiderio.CharacterQuery{
		Region:                   raiderio.US,
		Realm:                    "illidan",
		Name:                     "thehighvalue",
		MythicPlusScoresBySeason: []string{"current"},
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(profile.MythicPlusScoresBySeason[0].Scores.All)
}

Get the Mythic+ runs leaderboard

package main

import (
	"context"
	"fmt"

	"github.com/tmaffia/raiderio"
)

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

	runs, err := client.GetMythicPlusRuns(context.Background(), &raiderio.MythicPlusRunsQuery{
		Region:  raiderio.US,
		Season:  "season-tww-3",
		Dungeon: "all",
		Affixes: "all",
	})
	if err != nil {
		panic(err)
	}

	fmt.Println(len(runs.Rankings))
}