pubg

package module
Version: v0.0.0-...-a3142eb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2017 License: MIT Imports: 5 Imported by: 0

README

go-pubg

API wrapper for Playerunknown's Battlegrounds using the API from http://pubgtracker.com.

Getting Started

1. Install the package

Install the package and import it

go get github.com/albshin/go-pubg
2. Obtain API Key

Create an account at https://pubgtracker.com/site-api and request an API Key.

Usage

client, err := pubg.New("YOURAPIKEYHERE")
if err != nil {
    log.Fatal(err)
}
info, err := client.GetPlayer("JohnDoe") // Returns JSON unfiltered for player "JohnDoe"
if err != nil {
    log.Fatal(err)
}
fmt.Printf("%+v\n", info)

steaminfo, err := client.GetSteamInfo("76561198396852397") // Returns Steam information for user based on SteamId
if err != nil {
    log.Fatal(err)
}
fmt.Printf("%+v\n", steaminfo)

To-Do

  • Documentation
  • Tests
  • Filtered results

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	APIKey  string
	BaseURL *url.URL
}

API holds configuration variables for accessing the API.

func New

func New(key string) (*API, error)

New creates a new API client.

func (*API) Do

func (a *API) Do(req *http.Request, i interface{}) error

Do sends out a request to the API and unmarshals the data.

func (*API) GetPlayer

func (a *API) GetPlayer(uname string) (*Player, error)

GetPlayer returns a player's stats.

func (*API) GetSteamInfo

func (a *API) GetSteamInfo(sid string) (*SteamInfo, error)

GetSteamInfo retrieves a player's steam information.

func (*API) NewRequest

func (a *API) NewRequest(endpoint string) (*http.Request, error)

NewRequest creates the GET request to access the API.

type Player

type Player struct {
	PlatformID     int       `json:"platformId"`
	AccountID      string    `json:"AccountId"`
	Avatar         string    `json:"Avatar"`
	SelectedRegion string    `json:"selectedRegion"`
	DefaultSeason  string    `json:"defaultSeason"`
	SeasonDisplay  string    `json:"seasonDisplay"`
	LastUpdated    time.Time `json:"LastUpdated"`
	LiveTracking   []struct {
		Match        int         `json:"Match"`
		MatchDisplay string      `json:"MatchDisplay"`
		Season       int         `json:"Season"`
		RegionID     int         `json:"RegionId"`
		Region       string      `json:"Region"`
		Date         string      `json:"Date"`
		Delta        float64     `json:"Delta"`
		Value        float64     `json:"Value"`
		Message      interface{} `json:"message"`
	} `json:"LiveTracking"`
	PlayerName    string `json:"PlayerName"`
	PubgTrackerID int    `json:"PubgTrackerId"`
	Stats         []struct {
		Region string `json:"Region"`
		Season string `json:"Season"`
		Match  string `json:"Match"`
		Stats  []struct {
			Partition    interface{} `json:"partition"`
			Label        string      `json:"label"`
			SubLabel     interface{} `json:"subLabel"`
			Field        string      `json:"field"`
			Category     string      `json:"category"`
			ValueInt     interface{} `json:"ValueInt"`
			ValueDec     float64     `json:"ValueDec"`
			Value        string      `json:"value"`
			Rank         interface{} `json:"rank"`
			Percentile   float64     `json:"percentile"`
			DisplayValue string      `json:"displayValue"`
		} `json:"Stats"`
	} `json:"Stats"`
	MatchHistory []struct {
		Id                   int     `json:"Id"`
		Updated              string  `json:"Updated"`
		UpdatedJS            string  `json:"UpdatedJS"`
		Season               int     `json:"Season"`
		SeasonDisplay        string  `json:"SeasonDisplay"`
		Match                int     `json:"Match"`
		MatchDisplay         string  `json:"MatchDisplay"`
		Region               int     `json:"Region"`
		RegionDisplay        string  `json:"RegionDisplay"`
		Rounds               int     `json:"Rounds"`
		Wins                 int     `json:"Wins"`
		Kills                int     `json:"Kills"`
		Assists              int     `json:"Assists"`
		Top10                int     `json:"Top10"`
		Rating               float64 `json:"Rating"`
		RatingChange         float64 `json:"RatingChange"`
		RatingRank           int     `json:"RatingRank"`
		RatingRankChange     int     `json:"RatingRankChange"`
		Kd                   float64 `json:"Kd"`
		Damage               int     `json:"Damage"`
		TimeSurvived         float64 `json:"TimeSurvived"`
		WinRating            int     `json:"WinRating"`
		WinRank              int     `json:"WinRank"`
		WinRatingChange      int     `json:"WinRatingChange"`
		WinRatingRankChange  int     `json:"WinRatingRankChange"`
		KillRating           int     `json:"KillRating"`
		KillRank             int     `json:"KillRank"`
		KillRatingChange     int     `json:"KillRatingChange"`
		KillRatingRankChange int     `json:"KillRatingRankChange"`
		MoveDistance         float64 `json:"MoveDistance"`
	} `json:"MatchHistory"`
}

Player holds the information returned from the API.

type SteamInfo

type SteamInfo struct {
	AccountID   string `json:"AccountId"`
	Nickname    string `json:"Nickname"`
	AvatarURL   string `json:"AvatarUrl"`
	SteamID     string `json:"SteamId"`
	SteamName   string `json:"SteamName"`
	State       string `json:"State"`
	InviteAllow string `json:"InviteAllow"`
}

SteamInfo holds information returned from GetSteamInfo.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL