API talk:2/characters

From Guild Wars 2 Wiki
Jump to navigationJump to search

Add crafting response[edit]

The response section does not say anything about returning information about the crafting discipline although it does a very good job at it.

In the response, right after deaths:

  • crafting (array) - A list of objects of the character's crafting skills. An empty array is returned if the character has not learned a crafting discipline yet.

Each crafting object can have the following properties:

  • discipline (String) - The name of the crafting discipline. Possible values:
    • Artificer
    • Armorsmith
    • Chef
    • Huntsman
    • Jeweler
    • Leatherworker
    • Tailor
    • Weaponsmith
  • rating (number) - The level of the discipline
  • active (boolean) - The state of the discipline, if it is currently active or not


First example:

{
  "name": "My Character",
  "race": "Human",
  "gender": "Male",
  "profession": "Warrior",
  "level": 80,
  "guild": "3689E89F-7CB5-F611-9621-AC162CAE8ACA"
  "created": "2015-06-05T19:45:00Z",
  "age": 91,
  "deaths": 0,
  "crafting": [
    {
      "discipline": "Artificer",
      "rating": 500,
      "active": true
    },
    {
      "discipline": "Huntsman",
      "rating": 500,
      "active": true
    }
  ]
}

Second example:

{
  "name": "My Character",
  "race": "Human",
  "gender": "Male",
  "profession": "Warrior",
  "level": 80,
  "guild": "3689E89F-7CB5-F611-9621-AC162CAE8ACA"
  "created": "2015-06-05T19:45:00Z",
  "age": 91,
  "deaths": 0,
  "crafting": [
    {
      "discipline": "Artificer",
      "rating": 500,
      "active": true
    },
    {
      "discipline": "Huntsman",
      "rating": 347,
      "active": true
    }
  ],
  "equipment": [
    {
      "id": 6472,
      "slot": "Coat"
    },
    {
      "id": 6470,
      "slot": "Boots"
    },
    {
      "id": 6549,
      "slot": "Helm"
    },
    {
      "id": 6473,
      "slot": "Leggings"
    },
    {
      "id": 33345,
      "slot": "WeaponA1"
    },
    {
      "id": 49812,
      "slot": "WeaponB1"
      "upgrades": [
        24607,
        24548
      ]
    }
  ],
  "bags": [
    {
      "id": 8941,
      "size": 4
      "inventory": [
        null,
        {
          "id": 32134,
          "count": 1
        },
        null,
        null
      ]
    },
    null,
    {
      "id": 8932,
      "size": 20
      "inventory": [
        null,
        null,
        ...
      ]
    },
    {
      "id": 48715,
      "size": 20
    },
    null
  ]
}

For verification, here are one and two characters.

--Nithanim (talk) 10:12, 3 September 2015 (UTC)

Man, I've really been slacking on keeping these up-to-date. Added the new info. Eearslya (talk) 17:14, 3 September 2015 (UTC)
Thank you very much! I really hope I can help you with finding this little pieces. --Nithanim (talk) 19:10, 3 September 2015 (UTC)
Please do! I only ever edit the API section anyway, and a lot of the time I get distracted programming with the new features rather than documenting them. Eearslya (talk) 19:13, 3 September 2015 (UTC)
I had this endpoint already integrated when I found out that this was missing. I only checked back when I was working on integration of the /recipes and I was puzzled that I had something in my code that worked but was nowhere to be found in the wiki. Are the wiki pages only updated by the community or is there some official help? --Nithanim (talk) 19:31, 3 September 2015 (UTC)
It's mostly me and a few other community members, yeah. ANet devs aren't seen too often editing the wiki themselves, at least not here. The 'official help' is basically just what they tell us on the forums and on the github repo. Eearslya (talk) 19:46, 3 September 2015 (UTC)
Ah, ok. Thanks for clarification!

New Profession: Revenant[edit]

Since I'm not allowed to edit the page, could someone add the Revenant to the list of returned professions:

  • profession (string) - The character's profession. Possible values:
    • Elementalist
    • Engineer
    • Guardian
    • Mesmer
    • Necromancer
    • Ranger
    • Revenant
    • Thief
    • Warrior
Done and done. Eearslya (talk) 11:24, 15 September 2015 (UTC)

Negative ids in specialization[edit]

I get the following response from the api when querying a character not owned by me. I suspect that this character was not loaded since the overhaul of specializations and confusing the api. I can't test that so I am looking for someone who faced this weird occurrence already.

{
  ...
  "specializations": {
    "pve": [
      null,
      {
        "id": 80,
        "traits": [
          null,
          48,
          null
        ]
      },
      {
        "id": -1770672896,
        "traits": [
          135,
          -1770672943,
          135
        ]
      }
    ],
    "pvp": [
      {
        "id": 40,
        "traits": [
          null,
          null,
          null
        ]
      },
      null,
      null
    ],
    "wvw": [
      {
        "id": 256,
        "traits": [
          null,
          -1770672592,
          135
        ]
      },
      {
        "id": -1770672800,
        "traits": [
          135,
          1,
          null
        ]
      },
      {
        "id": -105611272,
        "traits": [
          32758,
          -106845954,
          32758
        ]
      }
    ]
  },
  ...
}

--Nithanim (talk) 19:15, 6 February 2016 (UTC)

backstory[edit]

I get a backstory return as well (just after deaths and crafting). This is not mentioned in the article. It's a vector of IDs (e.g. "55, 86, 87, 94, 168"). Is there anywhere I can cross-reference the IDs? The preceding unsigned comment was added by 193.138.66.10 (talkcontribs) at 13:10, July 28, 2016 (UTC).

I'm going to work on going through all the API wiki pages and making sure they're up-to-date. But for your information, the backstory IDs are referenced by /v2/backstory/answers, which itself references /v2/backstory/questions. Eearslya (talk) 13:22, 28 July 2016 (UTC)
many thanks! :)
I've got all of the backstory and story APIs documented and up. Backstory returns ids that resolve against API:2/backstory/answers which then have an id that will resolve against API:2/backstory/questions for the question. - Bandlero (talk) 12:36, 8 August 2016 (UTC)

Page structure[edit]

So it seems like this endpoint might of had some rework over time. For one, when you enter /v2/character/name you get all the information, and adding, say "/backstory" will limit the query to ONLY the backstory array. Was this always the case and this page written as it is regardless or does that page need updating?

If it does need updating I can work on it, but I rather not remake a full page if it is intended to be the way it is. -Darqam 17:17, 7 December 2016 (UTC)

Ok, so update. How I see it we can either keep all the information on one page (and have a MASSIVE page), or split it up according to the sub-endpoints. I've made a page according to how I imagine it in my sandbox. I've not included the examples since that is not necessary to understand the structure. My personal vote would be to split each character endpoint into their own page as to not bloat the main page, but to link to each page from the this main page so anyone can easily navigate it. The exception would be the "extra" section which doesn't seem to belong to any sub-endpoint.
If no one objects to me rebuilding this page into multiple sub-pages and this main page, then I'll get to it in a few days (in order to give people time to speak up). -Darqam 21:09, 7 December 2016 (UTC)

New look at the page[edit]

Bringing this back up to have a place to talk about it. I've changed the page to collapse basically all the information. This has the advantage of not making it a pain to navigate, but also now hides all info until you click show, which might not be what is wanted.

So, if people have an alternate option speak up. I think chieftain alex has already mentioned maybe only collapsing examples and leaving the info up as normal. Speak up, cause I couldn't find webpage beauty if it slapped me in the face. -Darqam 20:05, 8 April 2017 (UTC)

Collapsed sections make documentation worse to navigate, not better... Why not use the table of contents?--Relyk ~ talk < 02:22, 9 April 2017 (UTC)
Please move the objects returned by the sub-endpoints to their respective pages, but also keep the information here too because this endpoint returns those objects (I think that each endpoint page should mirror the data it returns, even if it is shared by another endpoint). I would prefer to not have collapsed sections, and to just have an example using an all-permission token and perhaps one using a minimum-permission ("account", "characters") token. If you wanted an example of layout, look at API:2/items: the response section goes into enough detail of what to expect, and the example section shows some different outputs to support the details. --BryghtShadow (talk) 05:44, 17 December 2018 (UTC)
So you are wanting a duplicate of information? From what I recall of my thoughts at the time and convo in-game, placing everything here was more streamline and gave access to all the information properly compartmentalized (Though I guess examples could be bumped into the appropriate sub sections).
Is there a reason where one would want to only see a portion of this and the sub-section would not be enough? I'm all for changes, but duplicating info and placing it in different spots makes it annoying to maintain and can, in my opinion, lead to confusion as to why things are written in two spots. -Darqam 13:49, 24 December 2018 (UTC)

Fetching all character information[edit]

Rather than iterate over each of the characters listed by /v2/characters in turn, use /v2/characters?ids=all This will return all subsections for all of the characters in the account.

Do not use ?page=0 as that apparently starts paginating by default after 50 characters so you would lose the last 19 (69 is the maximum number of characters). This was mentioned by dsnider in the GW2 Development Community Discord server at 23:25 UTC on 23rd May 2019. Leaky (talk) 23:57, 23 May 2019 (UTC)

Pagination sucks. Can't think of an example where i'd ever use it. -Chieftain AlexUser Chieftain Alex sig.png 06:23, 24 May 2019 (UTC)

How to use it in combination with API?[edit]

How to use it in combination with API? Cause it somehow not recognise my API or my all ID:

Thanks in advance AxleOdy -Axleody (talk) 18:27, 9 November 2022 (UTC)

Assuming that you are replacing "#API" with your actual token, the request string should look like https://api.guildwars2.com/v2/characters?ids=all&access_token=#API
In terms of what you were doing wrong, URLs are formed with a question mark (?) before the first key/value token, and an ampersand (&) for all subsequent key/value tokens (stackoverflow explanation). -Chieftain AlexUser Chieftain Alex sig.png 18:33, 9 November 2022 (UTC)