Skip to content

42atomys/gw2api-go

Repository files navigation

gw2api-go

A Go Wrapper to your GuildWars 2 Go Project

What's is GW2-API

At the start GW2-API as created to be a wrapper of the GuildWars2 Official API. After few months of use in private projects, I decide to make it public and rewrite the library.

GW2-API is a complete and up-to-date wrapper in Golang.

Getting Start / How to use ?

To use Gw2APIGO, it's really simple. All requests and API context is managed by a gw2api.Requestor

  // Create a new gw2api Requestor
  r := gw2api.NewRequestor()

  // Initialize api object 
  var world gw2api.World

  // Perform a request with our defined api object
  r.World(&world, 2101)

  // Show magic
  log.Printf("Awesome world: %s", world.Name)

The best pratice is ti check if the request pipeline encountered an error

  // Create a new gw2api Requestor
  if err := r.World(&world, 2101).Err(); err != nil {
    panic(err.Error())
  }

In some endpoints you can need a translation, you can do a request with a specific lang with .Lang(gw2api.Lang)

  r.Lang(gw2api.LangFR).Title(&title, 1)

On endpoints who needs API Key and permission, you can give to requestor an APIKey, the requestor will fetch permission of APIKey to prevent any call to the API if your API Key don't have needed permission

  r.Auth(apiKey).Account(&account)

In some advanced case, you can edit the timeout of the requestor too with .Timeout(time.Duration)

  r.Timeout(5 * time.Second).Title(&title, 1)

When you try to call an authenticated endpoints without APIKey, the Requestor will return you an error accessible on .Err() method. You can check the Err wirh errors package. Its the same process when your API Key dont have the required scope

  err := r.Account(&account).Err()
  if errors.Is(err, gw2api.ErrRequireAuthentication) { // => true
    log.Printf("Give an api key")
  }
Err Description
ErrTooManyRequest too many request: 429. You have reach API limitations
ErrRequireAuthentication API endpoint needs authentication
ErrMissingScope missing scope permissions for this endpoint

TODO

  • Core wrapper
  • Language support
  • API Token Permissions
  • Route active support
  • Subtoken support
  • v2/
    • account
      • account/achievements
      • account/bank
      • account/buildstorage
      • account/dailycrafting
      • account/dungeons
      • account/dyes
      • account/emotes
      • account/finishers
      • account/gliders
      • account/home
        • account/home/cats
        • account/home/nodes
      • account/inventory
      • account/legendaryarmory
      • account/luck
      • [-] account/mail (API not active)
      • account/mailcarriers
      • account/mapchests
      • account/masteries
      • account/mastery/points
      • account/materials
      • account/minis
      • account/mounts
        • account/mounts/skins
        • account/mounts/types
      • account/novelties
      • account/outfits
      • account/pvp/heroes
      • account/raids
      • account/recipes
      • account/skins
      • account/titles
      • account/wallet
      • account/worldbosses
    • achievements
      • achievements/categories
      • achievements/daily
      • achievements/daily/tomorrow
      • achievements/groups
    • [-] adventures (API not active)
      • [-] adventures/:id/leaderboards (API not active)
        • [-] adventures/:id/leaderboards/:board/:region (API not active)
    • backstory/answers
    • backstory/questions
    • build
    • characters
      • (characters all and single)
      • characters/:id/backstory
      • characters/:id/buildtabs
      • characters/:id/buildtabs/active
      • characters/:id/core
      • characters/:id/crafting
      • [-] characters/:id/dungeons (API not active)
      • characters/:id/equipment
      • characters/:id/equipmenttabs
      • characters/:id/equipmenttabs/active
      • characters/:id/heropoints
      • characters/:id/inventory
      • characters/:id/quests
      • characters/:id/recipes
      • characters/:id/sab
      • characters/:id/skills
      • characters/:id/specializations
      • characters/:id/training
    • colors
    • commerce/delivery
    • commerce/exchange
    • commerce/listings
    • commerce/prices
    • commerce/transactions
      • Pagination System
    • continents
    • createsubtoken
    • currencies
    • dailycrafting
    • dungeons
    • emblem
    • emotes
    • [-] events (API not active)
    • [-] events-state (API not active)
    • files
    • finishers
    • [-] gemstore/catalog (API not active)
    • gliders
    • guild/:id
      • guild/:id/log
      • guild/:id/members
      • guild/:id/ranks
      • guild/:id/stash
      • guild/:id/storage
      • guild/:id/teams - needs /v2/pvp/stats.
      • guild/:id/treasury
      • guild/:id/upgrades
    • guild/permissions
    • guild/search
    • guild/upgrades
    • home
      • home/cats
      • home/nodes
    • items
    • itemstats
    • legendaryarmory
    • legends
    • mailcarriers
    • mapchests
    • maps
    • masteries
    • materials
    • minis
    • mounts
      • mounts/skins
      • mounts/types
    • novelties
    • outfits
    • pets
    • professions
    • pvp
      • pvp/amulets
      • pvp/games
      • pvp/heroes
      • pvp/ranks
      • pvp/rewardtracks
      • pvp/runes
      • pvp/seasons
        • pvp/seasons/:id/leaderboards
          • pvp/seasons/:id/leaderboards/:board/:region
      • pvp/sigils
      • pvp/standings
      • pvp/stats
    • quaggans
    • quests
    • races
    • raids
    • recipes
      • recipes/search
    • skills
    • skins
    • specializations
    • stories
      • stories/seasons
    • titles
    • tokeninfo
    • traits
    • [-] vendors (API not active)
    • worldbosses
    • worlds
    • wvw/abilities
    • wvw/matches
    • wvw/matches/overview
    • wvw/matches/scores
    • wvw/matches/stats
    • wvw/matches/stats/:id/guilds/:guild_id (no doc)
    • wvw/matches/stats/:id/teams/:team/top/kdr (no doc)
    • wvw/matches/stats/:id/teams/:team/top/kills (no doc)
    • wvw/objectives
    • wvw/ranks
    • [-] wvw/rewardtracks (API not active)
    • wvw/upgrades

About

A simple go SDK for Guild Wars 2 API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages