Skip to content

jegfish/goroyale

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goroyale

GoDoc Go report

A Golang wrapper for the Clash Royale API at https://royaleapi.com/.

Installing

If you have Go installed you can run this command.

go get github.com/jegfish/goroyale

Example

package main

import (
	"fmt"

	"github.com/jegfish/goroyale"
)

var token = ""

func main() {
	c, err := goroyale.New(token, 0) // 0 will use the default request timeout of 10 seconds
	if err != nil {
		fmt.Println(err)
		return
	}

	ver, err := c.APIVersion()
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Println("API Version:", ver)
	}

	params := map[string][]string{
		"exclude": {"name"},
	}
	p, err := c.Player("8L9L9GL", params)
	if err != nil {
		fmt.Println(err)
	} else {
		// will just print "Name:" as p.Name is "" because it was excluded
		// more info about this at https://docs.royaleapi.com/#/field_filter
		fmt.Println("Name:", p.Name)

		fmt.Println("Tag:", p.Tag)
		fmt.Println("Clan:", p.Clan.Name)
	}
}