hypixel

package
v0.0.0-...-5ca07f5 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2016 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package hypixel provides a client for using the Hypixel API.

Construct a new Hypixel client to access the various aspects of their public api. For example, to show an api keys statistics:

client := hypixel.NewClient("your-api-key", nil)
response, err := client.KeyInfo()

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {

	// The base url of the API requests. Default to the Hypixel API.
	BaseURL string

	// The api key.
	APIKey string

	// The user agent. Default to "go-hypixel/0.1 (see https://github.com/maxikg/go-hypixel)".
	UserAgent string
	// contains filtered or unexported fields
}

A Client manages communication with the Hypixel API.

func NewClient

func NewClient(key string, httpClient *http.Client) *Client

NewClient returns a new Hypixel API client. If a nil httpClient is provided, http.DefaultClient will be used.

func (*Client) CreateRequest

func (c *Client) CreateRequest(method string, params map[string]string) (*http.Request, error)

CreateRequest creates an http.Request for querying the API. method specify which method should be called. Optional a map can be provided for additional parameters.

func (*Client) FindGuildByName

func (c *Client) FindGuildByName(name string) (string, error)

FindGuildByName finds a guild id by the guilds name. Returns an empty string as the id if no guild data is available.

func (*Client) FindGuildByPlayer

func (c *Client) FindGuildByPlayer(player string) (string, error)

FindGuildByPlayer finds a guild id by an name of a guilds member. Returns an empty string as the id if no guild data is available.

func (*Client) FindGuildByUUID

func (c *Client) FindGuildByUUID(uuid string) (string, error)

FindGuildByUUID finds a guild id by an uuid of a guilds member. Returns an empty string as the id if no guild data is available.

func (*Client) FriendsByName

func (c *Client) FriendsByName(name string) ([]map[string]interface{}, error)

FriendsByName queries friends of the player name.

func (*Client) FriendsByUUID

func (c *Client) FriendsByUUID(uuid string) ([]map[string]interface{}, error)

FriendsByUUID queries friends of the player uuid.

func (*Client) Guild

func (c *Client) Guild(id string) (map[string]interface{}, error)

Guild queries a guilds information by its id. Returns nil if no guild with this id is known.

func (*Client) KeyInfo

func (c *Client) KeyInfo() (map[string]interface{}, error)

KeyInfo calls the API at /key. It will returns an error or a KeyInfo which contains statistics about the usage of the currently used key.

func (*Client) PlayerByName

func (c *Client) PlayerByName(name string) (map[string]interface{}, error)

PlayerByName queries a player by its name.

func (*Client) PlayerByUUID

func (c *Client) PlayerByUUID(uuid string) (map[string]interface{}, error)

PlayerByUUID queries a player by its uuid.

func (*Client) Query

func (c *Client) Query(method string, parameters map[string]string, result interface{}) error

Query queries the remote API for a specified method, an optional map of parameters and an instance of a struct in which the response will be deserialized.

func (*Client) SessionByName

func (c *Client) SessionByName(name string) (map[string]interface{}, error)

SessionByName queries a players session by its name.

func (*Client) SessionByUUID

func (c *Client) SessionByUUID(uuid string) (map[string]interface{}, error)

SessionByUUID queries a players session by its uuid.

type FriendsResponse

type FriendsResponse struct {
	Records []map[string]interface{} `json:"records"`
	Cause   string                   `json:"cause"`
	Success bool                     `json:"success"`
}

FriendsResponse is the bare response of the API containing maybe an array of friends, maybe a cause and a bool determine if the request was successful.

type GuildIDResponse

type GuildIDResponse struct {
	Guild   string `json:"guild"`
	Cause   string `json:"cause"`
	Success bool   `json:"success"`
}

GuildIDResponse is the bare response of the API containing maybe a guild id, maybe a cause and a bool determine if the request was successful.

type GuildResponse

type GuildResponse struct {
	Guild   map[string]interface{} `json:"guild"`
	Cause   string                 `json:"cause"`
	Success bool                   `json:"success"`
}

GuildResponse is the bare response of the API containing maybe a guild, maybe a cause and a bool determine if the request was successful.

type KeyInfoResponse

type KeyInfoResponse struct {
	Record  map[string]interface{} `json:"record"`
	Cause   string                 `json:"cause"`
	Success bool                   `json:"success"`
}

KeyInfoResponse is the bare response of the API containing maybe the record, maybe a cause and a bool determine if the request was successful.

type PlayerResponse

type PlayerResponse struct {
	Player  map[string]interface{} `json:"player"`
	Cause   string                 `json:"cause"`
	Success bool                   `json:"success"`
}

PlayerResponse is the bare response of the API containing maybe the player, maybe a cause and a bool determine if the request was successful.

type SessionResponse

type SessionResponse struct {
	Session map[string]interface{} `json:"session"`
	Cause   string                 `json:"cause"`
	Success bool                   `json:"success"`
}

SessionResponse is the bare response of the API containing maybe the session, maybe a cause and a bool determine if the request was successful.

Jump to

Keyboard shortcuts

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