Jump to content
  • Sign Up

Q: (API newbie) How do I get character id?


Mauchkiv.8074

Recommended Posts

Hello guild devs!

 

I have plans to make some app for personal use and just explored the [gw2wiki](https://wiki.guildwars2.com/wiki/API:Main "gw2wiki Wiki") to check out the endpoints.

 

I'm especially interested in _/v2/characters_. What I wan to know is how can I get a list of my characters ids? This endpoint only list the character names.

But according to wiki I have to use _id_ if I want to get data for one character, like so _v2/characters/:id/core_. But how do I get it?

 

After playing around more I found I can get data for one character by URL encoding its _name_ and use it as _id_. That's a bit surprising.

 

• How do I get character _id_? Am I doing something wrong?

• Is using _name_ as _id_ intentional? Why?

 

Best regards!

Link to comment
Share on other sites

To get your list of character you need an API keys, you can create it [here](https://account.arena.net/applications "here")

 

To get list of character inside an account:

`https://api.guildwars2.com/v2/characters?access_token=`

 

To get basic info about an specific character

`https://api.guildwars2.com/v2/characters//core?access_token=`

 

For more info about character you can change the "core" text to "equipment" / "inventory" / etc. Example:

`https://api.guildwars2.com/v2/characters//inventory?access_token=`

 

Hope it helps ;)

Link to comment
Share on other sites

 

> I'm especially interested in _/v2/characters_. What I wan to know is how can I get a list of my characters ids? This endpoint only list the character names.

> But according to wiki I have to use _id_ if I want to get data for one character, like so _v2/characters/:id/core_. But how do I get it?

>

> After playing around more I found I can get data for one character by URL encoding its _name_ and use it as _id_. That's a bit surprising.

>

> • How do I get character _id_? Am I doing something wrong?

 

I also have never found out how to get a list of character-ids, so I use the characters names (encoded) as the ":id"-part of the api-endpoints.

 

It feels a little strange to use the character-name (that can have special characters) as an index/id. Maybe it was planned to return real IDs (e.g. numbers) but it was not finished and then it stayed that way.

 

 

Link to comment
Share on other sites

> It feels a little strange to use the character-name (that can have special characters) as an index/id. Maybe it was planned to return real IDs (e.g. numbers) but it was not finished and then it stayed that way.

>

>

 

You are doing the right thing. There isn't something like an id for a character. I totally agree, that using that character name as 'id' is a bad idea, because of special characters.

I think the whole game servers are not designed to have an API and therefore people have to do hacky things to get the information into a database.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...