GithubHelp home page GithubHelp logo

joaodanielrufino / goriot Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 43 KB

Riot Games SDK client written in Golang

License: MIT License

Go 99.28% Makefile 0.72%
api go league-of-legends riot-games sdk golang riot-api riot-games-api datadragon live-client-api

goriot's Introduction

Riot Games SDK for Go

goriot is a SDK written in Go to facilitate the use of Riot Games API. Currently the SDK implements the League of Legends, Live Client Data and Data Dragon API.

Installation

$ go get github.com/JoaoDanielRufino/goriot

Usage

To use League of Legends API, you need to provide your Riot Games API Key. You can generate a development key by accessing developer.riotgames.com

The default region of the SDK is Brazil (br1).

If you only want to use Live Client Data or Data Dragon, the API Key is not required.

Basic example

package main

import (
	"encoding/json"
	"fmt"

	"github.com/JoaoDanielRufino/goriot/riot"
	"github.com/JoaoDanielRufino/goriot/riot/lol"
)

func handleError(err error) {
	if err != nil {
		panic(err)
	}
}

func main() {
	client, err := lol.NewClient(lol.WithApiKey("API KEY"), lol.WithRegion(riot.RegionKorea))
	handleError(err)

	res, err := client.GetSummonerByName("Hide on bush")
	handleError(err)

	pretty, err := json.MarshalIndent(res, "", "  ")
	handleError(err)

	fmt.Println(string(pretty))
}

Live Client Data usage

To safely use Live Client Data API, it's recommended to download the root certificate to validate the HTTPS requests. You can find the certificate on developer.riotgames.com/docs/lol#game-client-api_root-certificatessl-errors

But if you wish, you can omit the lol.WithCertificate() option to use Live Client Data API without the certificate.

package main

import (
	"encoding/json"
	"fmt"

	"github.com/JoaoDanielRufino/goriot/riot"
	"github.com/JoaoDanielRufino/goriot/riot/lol"
)

func handleError(err error) {
	if err != nil {
		panic(err)
	}
}

func main() {
	client, err := lol.NewClient(lol.WithCertificate("./riotgames.pem"))
	handleError(err)

	res, err := client.LiveClientData.AllGameData()
	handleError(err)

	pretty, err := json.MarshalIndent(res, "", "  ")
	handleError(err)

	fmt.Println(string(pretty))
}

Data Dragon usage

package main

import (
	"encoding/json"
	"fmt"

	"github.com/JoaoDanielRufino/goriot/riot"
	"github.com/JoaoDanielRufino/goriot/riot/lol"
)

func handleError(err error) {
	if err != nil {
		panic(err)
	}
}

func main() {
	client, err := lol.NewClient()
	handleError(err)

	res, err := client.DataDragon.GetChampions()
	handleError(err)

	pretty, err := json.MarshalIndent(res, "", "  ")
	handleError(err)

	fmt.Println(string(pretty))
}

goriot's People

Contributors

joaodanielrufino avatar

Stargazers

Felipe Dornelas avatar peach-zhang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.