Guide to the Black Lion Trading Co API

Guide to the Black Lion Trading Co API

in API Development

Posted by: The Talcmaster.7391

The Talcmaster.7391

Since we now have a dedicated spot for API discussions, I figured I would take the liberty of sharing what I know about the Trading Post / Gem Store API so that anyone interested in making something with it will have a thorough reference to go off of. Thanks to all the people in the #gw2spidy chatroom who showed me much of this.

DISCLAIMER: This API is not an official-release API and is not intended for public use. Therefore, it is unsupported by Arenanet, NCsoft or any other company. It is subject to change without any notification. USE AT YOUR OWN RISK.

Web addresses involved:

Accessing the Trading Post:
The external login page is /authenticate after one of the above address:

These pages use a fairly standard SSO (Single Sign On) setup, so if you are already logged into the forum, it will check against the forum and automatically redirect you to that particular site’s landing page. If you are not logged in, it will redirect you to account.guildwars2.com so you can enter your information. If you already have a valid session ID, you can add it as a parameter: <site>/authenticate?id=<session-id>

If, like me, you are trying to access these parameters outside of a web browser and don’t retain cookies, you can add the session-id in the form of s=<session-id> as a custom header called Cookie (this is how cookies are automatically passed in a browser) whenever you make an API call.

Note that session-ids do expire, and you will need to update these regularly or finding a way of retrieving a new one automatically as necessary.

tradingpost outputs:

  • https://tradingpost-live.ncplatform.net/ws/search.json
    This output is the one that does the majority of functions on the TP. By default it won’t return anything as it requires a combination of different parameters depending on what you are trying to accomplish.
  • ?text=&levelmin=0&levelmax=80
    This combination will return a list of all the items along with their buy and sell listings and prices. By default this only returns 10 items at a time, but this is adjustable by the count= parameter. If count=0 it will return all of the items in the list. The offset= parameter starts the listing based on that number in the list (1 is the first item) The text= can be filled in to filter by the item name, but leaving it blank is still valid. levelmin and levelmax require valid numbers to be entered. Other filters that are optional are removeunavailable=true, rarity=, type=, and subtype= (these last 3 require their numeric representation, not characters). WARNING: This can pull in ALL ITEMS and can take a long time to run and take a great deal of memory to process
  • ?text=text&typeahead=1
    This combination returns just the type, id, and name of an item. This is what is called when you type something into the search box and it gives you a list of items. It requires some sort of text to be entered to work. The count=0 trick works on this as well, and you can use offset= as well. Optional parameters levelmin, levelmax, removeunavailable, rarity, type, and subtype all function the same as above.
  • ?ids=27321,24354
    This allows you to enter a comma delimited list of item ids (up to 250) and pull in the same info as you do from the first set of parameters. All of the other parameters are rendered inoperable when this parameter is specified.

Continued in next post…

Fort Aspenwood – [fury], [SAO], [NICE]
Fun on someone else’s schedule is not fun

(edited by The Talcmaster.7391)

Guide to the Black Lion Trading Co API

in API Development

Posted by: The Talcmaster.7391

The Talcmaster.7391

…Continued from above

  • https://tradingpost-live.ncplatform.net/ws/listings.json?id=27321
    This will pull in the buy and sell listings for the first 20 prices as seen when you click on a specific item in the trading post. It returns the price, number of listings at that price, and the total of numbers ordered at that price. If you specify type=buys or type=sells it will return that type, but by default returns both. The data is not all listings for an item, and since only one item can be returned at a time is a much slower way of getting data out than search.json so if you have no reason to look at specific listings, just stick to search.json
  • https://tradingpost-live.ncplatform.net/ws/trends.json
    This odd little output shows all the trending information you see on the main page. It has all the standard item information for the items, and a list if IDs for each category. There are no parameters for it, and may not even be up to date at a given time. I would not rely on it for much, but am including it here for the sake of completeness.
  • https://tradingpost-live.ncplatform.net/ws/me.json
    This output actually requires a session-id that originates in game to be able to access. I won’t get into how to retrieve that particular session-id. This is what you see when you view your transactions, and requires a combination of parameters to return a valid result. The type=buy or type=sell will return either your buy or sell transactions respectively. The time=now or time=past shows either your current listings or your historical transactions.

gemstore outputs:

  • https://gemstore-live.ncplatform.net/ws/search.json
    This outputs all of the information about a given gemstore item and requires either the discounted=1 parameter, the category= parameter, or the text= to return a valid list. Using a combination will limit it further. The category= uses actual words for the categories, and the following are valid: decorative, consumable, convenience, boosts, minipets, account. The text= parameter must have a valid text search after it to return results. Optional parameters are offset and count, which behave the same as the tradingpost search.json.
  • https://gemstore-live.ncplatform.net/ws/history.json
    This outputs items previously bought on the gemstore, and requires a session-id that originates from the game. It is the same information as the search returns, except historical based on your account. The only known parameter is count=

exchange outputs:

  • https://exchange-live.ncplatform.net/ws/trends.json
    This outputs the raw data powering the little graph seen on the bottom of the exchange. With no type specified, it by default outputs the equivalent of a type=ReceivingCoins parameter, with the gem counterpart being type=ReceivingGems.
  • https://exchange-live.ncplatform.net/ws/rates.json
    This is another one that requires a session-id from the game. It is what provides the conversion rates between coins and gems. It requires a coins= and/or gems= number parameter added on to return values of that type. I have not managed to get this to successfully work myself, so I think this also requires some sort of character id to be passed. I do know that it is how Gw2spidy and some others pull in data.

That’s pretty much everything I know about these APIs. If there is anything I missed that needs to be clarified or if you have anything to share, let me know and I will add it.

Fort Aspenwood – [fury], [SAO], [NICE]
Fun on someone else’s schedule is not fun

Guide to the Black Lion Trading Co API

in API Development

Posted by: marnick.4305

marnick.4305

Is it possible to buy with this api or merely watch prices?

If I can’t play Guild Wars 2 at work, I won’t work in Guild Wars 2 either.
Delayed content is eventually good. Rushed content is eternally bad. ~ Shigeru Miyamoto

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

Is it possible to buy with this api or merely watch prices?

Yes it is possible to buy. For buy, you have to do a https post

https://tradingpost-live.ncplatform.net/ws/item/<itemId>/buy

with the following parameters:

{count=int,price=int,charid=<char guid>}

You also need your game session key.

(edited by DarkSpirit.7046)

Guide to the Black Lion Trading Co API

in API Development

Posted by: Killer Rhino.6794

Killer Rhino.6794

The Talcmaster, this is phenomenal! Thank you!

Creator of GW2Kit

Guide to the Black Lion Trading Co API

in API Development

Posted by: The Talcmaster.7391

The Talcmaster.7391

I believe it is possible to do any of the functions that you can do normally in those pages, such as buying and selling items, buying and redeeming gems, buying gemstore items, etc. I haven’t played with any of these functions because 1) I don’t know how to retrieve my charid, 2) I don’t want to mess with things that can cause permanent unwanted changes, and 3) I’m currently only interested in pulling out the data so I can create some nifty visualizations. I didn’t mention them in the doc for much the same reasons, as well as not wanting to be responsible for people playing with things they may regret. Of course, I welcome DarkSpirit and other people who have played with it to add to this in their own posts and make it more thorough and complete.

Fort Aspenwood – [fury], [SAO], [NICE]
Fun on someone else’s schedule is not fun

Guide to the Black Lion Trading Co API

in API Development

Posted by: Healix.5819

Healix.5819

Selling and picking up items are done directly though the client. Basically, you can’t “touch” items through the API.

The charid has to be intercepted by either reading memory or the url used to authenticate. The in-game session key has to be obtained the same way or by reading the cookie file located in gw2cache.

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

I would be surprised if ArenaNet finally decides to release their trading post API as it is right now. I don’t think it is ready.

Most of the interesting functions require the game session key and char id guid and having this requirement hampers their use in mobile apps, which is why I didn’t post any detail information about their Trading Post API. I also would not know what I post would be outdated by the time ArenaNet decides to officially release this.

However, since The Talcmaster has already posted this information, I can help by supplementing any info that he may have missed out.

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

If you want complete C# code using this API, you can look at Zicore’s TP Notifier:

https://forum-en.gw2archive.eu/forum/game/bltc/Zicore-s-Trading-Post-Notifier-Open-Source/first

It uses .NET 4.0. I have also written my own C# app in .NET 4.5 (for its async programming) but it is still work-in-progress.

Here are some of the enums that I use:

public enum RarityEnum
{
Junk = 0,
Basic,
Fine,
Masterwork,
Rare,
Exotic,
Ascended,
Legendary
};

public enum TypeEnum
{
Armor = 0,
Back = 1,
Bag = 2,
Consumable,
Container,
[EnumMember(Value = “CraftingMaterial”)]
Crafting_Material,
Gathering,
Gizmo,
MiniPet = 11,
Tool = 13,
Trinket = 15,
Trophy,
[EnumMember(Value = “UpgradeComponent”)]
Upgrade_Component,
Weapon
};

// for TypeEnum.Armor
public enum ArmorSubTypeEnum
{
Coat = 0,
Leggings,
Gloves,
Helm,
[EnumMember(Value = “HelmAquatic”)]
Aquatic_Helm,
Boots,
Shoulders
};

// for TypeEnum.Consumable
public enum ConsumableSubTypeEnum
{
Alcohol = 1,
Generic,
Food = 3,
Tonics = 4, // Suppose to be Generic?
Transmutation = 5,
Unlock,
Skins = 7,
Dyes_and_Recipes = 8, // Suppose to be Unlock?
Utility = 9,
[EnumMember(Value = “ContractNpc”)]
Contract_Npc,
[EnumMember(Value = “AppearanceChange”)]
Appearance_Change,
Immediate,
Halloween
};

// for TypeEnum.Container
public enum ContainerSubTypeEnum
{
Default = 0,
[EnumMember(Value = “GiftBox”)]
Gift_Box
};

// for TypeEnum.Gathering
public enum GatheringSubTypeEnum
{
Foraging = 0,
Logging,
Mining
};

// for TypeEnum.Gizmo
public enum GizmoSubTypeEnum
{
Default = 0,
Salvage = 2,
[EnumMember(Value = “RentableContractNpc”)]
Rentable_Contract_Npc,
[EnumMember(Value = “UnlimitedConsumable”)]
Unlimited_Consumable
};

// for TypeEnum.Tool
public enum ToolSubTypeEnum
{
Crafting = 0,
Salvage = 2
};

// for TypeEnum.Trinket
public enum TrinketSubTypeEnum
{
Accessory = 0,
Amulet,
Ring
};

// for TypeEnum.UpgradeComponent
public enum UpgradeComponentSubTypeEnum
{
Default = 0,
Gem = 1,
Rune = 2,
Sigil = 3
};

// for TypeEnum.Weapon
public enum WeaponSubTypeEnum
{
Sword = 0,
Hammer,
[EnumMember(Value = “LongBow”)]
Long_Bow,
[EnumMember(Value = “ShortBow”)]
Short_Bow,
Axe,
Dagger,
Greatsword,
Mace,
Pistol,
Rifle = 10,
Scepter,
Staff,
Focus,
Torch,
Warhorn,
Shield,
[EnumMember(Value = “Harpoon”)]
Spear = 19,
[EnumMember(Value = “Speargun”)]
Harpoon_Gun,
Trident,
[EnumMember(Value = “TwoHandedToy”)]
Toy
};

Note that there are currently some bugs surrounding ArenaNet’s search filters. They don’t have Back Item search and some of the consumable sub types that I have above, implemented in their TP dialog web page. So keep in mind that these enums may change by the time ArenaNet releases this api.

(edited by DarkSpirit.7046)

Guide to the Black Lion Trading Co API

in API Development

Posted by: The Talcmaster.7391

The Talcmaster.7391

I totally agree, DarkSpirit. As it stands, the API that the trading post comes with exists primarily for facilitating its in game functionality, which is why it is a little bit more confusing than the newer API stuff just released. It was built a bit with external applications in mind, otherwise it wouldn’t be accessible outside the game at all. This hasn’t stopped people from figuring out how to pull all sorts of useful information from it and building those many excellent sites. I’ve been informed that the ability to check prices without needing to authenticate may be in the cards but right now it is necessary to prevent people from abusing the TP with too many calls. I don’t expect this to be truly outdated any time soon since right now is more of a focus on making new information available. The only changes that I know of was the last release adding the count= parameter to the trading post’s search.json and the release before that making the listings.json not require an in-game session-id. If people let me know about small changes like that, I’ll try my best to keep this up to date.

Fort Aspenwood – [fury], [SAO], [NICE]
Fun on someone else’s schedule is not fun

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

Thanks for the update, The Talcmaster. Personally, I am so glad that they added the count parameter to the trading post’s search.json. My app sorting feature for computed columns, is much faster now.

I would be very excited when they officially release their trading post api.

Guide to the Black Lion Trading Co API

in API Development

Posted by: The Talcmaster.7391

The Talcmaster.7391

Yeah, that count feature reduced the run time of my ETL from around an hour to less than a minute. Being able to pull in item and recipe information from the game itself will go a long way towards making people’s Trading post apps more robust than before.

Fort Aspenwood – [fury], [SAO], [NICE]
Fun on someone else’s schedule is not fun

Guide to the Black Lion Trading Co API

in API Development

Posted by: zaced.7948

zaced.7948

dear dudes and dudesses from anet. this thread needs a sticky before it leaves the front page and people start making new threads with the same questions over and over again.
centralist organization always pays off in terms of administration efficiency, i won’t mention examples since you probably are selling copies there.
greetings
zach

Guide to the Black Lion Trading Co API

in API Development

Posted by: anzenketh.3759

anzenketh.3759

dear dudes and dudesses from anet. this thread needs a sticky before it leaves the front page and people start making new threads with the same questions over and over again.
centralist organization always pays off in terms of administration efficiency, i won’t mention examples since you probably are selling copies there.
greetings
zach

Problem is I don’t think they want it there yet. This API is not likely the one ready for Prime Time.

In Game: Storm Bluff Isle — Anzz, Anzenketh Kyoto

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

I have updated my enums above as best as I can with the current schema from the items api shown here:

http://wiki.guildwars2.com/wiki/API/item_details

There are still some confusion with the subtypes because the items api returns strings while the TP api returns integer ids. Plus the fact that there are existing bugs surrounding the TP search filters so items may not have been listed correctly on the TP at the moment. However, in the context of the TP, they should not matter since the items in the new enums, returned by the items api, are bounded and are not able to be traded in the TP.

If my enum value is spelled differently as the strings returned from the items api, I have indicated those through the EnumMember attribute.

(edited by DarkSpirit.7046)

Guide to the Black Lion Trading Co API

in API Development

Posted by: athanor.7410

athanor.7410

There is a JAVA implementation here:
Java class
You can connect and get trading post outputs

Guide to the Black Lion Trading Co API

in API Development

Posted by: Lil Puppy.5216

Lil Puppy.5216

Does the parameter &weight=[0,1,2] no longer do anything? I think it was 0,1,2 but it might be 1,2,3. It was used to filter out light, medium, and heavy armor types in the beginning.

tested 1: yep, it doesn’t do anything now… that’s a shame since it worked beautifully.
tested 2: &weightclass=[integer] is a parameter but integer values don’t return anything useful – still getting mixed weight classes returned (heavy,medium,light).

https://tradingpost-live.ncplatform.net/ws/search.json?text=&levelmin=80&levelmax=80&rarity=5&type=0&weightclass=0
Returns Aidan’s medium armors and just after that is Apothecary’s Draconic heavy armors.


{
	"args": {
		"offset": 1,
		"count": 10,
		"rarity": 5,
		"weightclass": 0,
		"levelmin": 80,
		"levelmax": 80,
		"type": 0
	},
	"total": "326",
	"results": [
		{
			"type_id": "3",
			"data_id": "323",
			"item_image_hash": "761944b",
			"guid": "AD0B4245-74D8-4713-88D2-EABA36DEF013",
			"name": "Aidan's Boots",
			"description": "",
			"level": "80",
			"rarity": "5",
			"vendor": "264",
			"sell_price": "30192",
			"sell_count": "101",
			"buy_price": "21801",
			"buy_count": "127",
			"passwords": [],
			"rarity_word": "Exotic",
			"img": "https://dfach8bufmqqv.cloudfront.net/gw2/img/content/761944b_icon_small.png",
			"tradeable": true
		}, {...}
	]
}

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

Interesting, I never knew that the TP server supported armor weight class filtering. My app search function simply applies a second filter to the returned result matched against the weight class specified by the official API or GW2DB, if armor weight class is specified by the user.

Guide to the Black Lion Trading Co API

in API Development

Posted by: Lil Puppy.5216

Lil Puppy.5216

During beta the check box that currently filters things that are currently available was used to filter items the character could use like armor and weapons. The API had it as &weight=[int] parameter, now &weightclass=[int].

Guide to the Black Lion Trading Co API

in API Development

Posted by: enjoyaol.2398

enjoyaol.2398

Any way to get the historical prices of the items from the API ? (sell and buy sides)
Right now I’m using GW2Spidy api but relying on GW2 servers would be better for me.
thx !

Guide to the Black Lion Trading Co API

in API Development

Posted by: Killer Rhino.6794

Killer Rhino.6794

Any way to get the historical prices of the items from the API ? (sell and buy sides)
Right now I’m using GW2Spidy api but relying on GW2 servers would be better for me.
thx !

Nope. In order to aggregate TP data over time, you would need to do exactly what gw2spidy.com is already doing, which is to say, constantly poll, collect and store the TP data in some manner.

If you don’t want to rely on gw2spidy.com remotely, you can fire up your own version of the site. For some time, the author of gw2spidy.com has graciously open sourced his code and provided detailed instructions on how to use it on the project’s GitHub page

Shameless Plug: If you want to write iOS or OS X apps which can query gw2spidy.com, check out GW2Kit

Creator of GW2Kit

Guide to the Black Lion Trading Co API

in API Development

Posted by: BlazingZero.9702

BlazingZero.9702

hello everyone, firstly thank you The Talcmaster for creating this awesome post. This really helps a lot for people like me who want to write a bit of program to access the TP outside of the game.

As I’m pretty new to using JSON, I would like to know how can I authenticate myself when accessing the TP? I’m using C# on Unity.

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

hello everyone, firstly thank you The Talcmaster for creating this awesome post. This really helps a lot for people like me who want to write a bit of program to access the TP outside of the game.

As I’m pretty new to using JSON, I would like to know how can I authenticate myself when accessing the TP? I’m using C# on Unity.

The purpose of authenticating is to obtain a session key which you can then set in your cookie (i.e. s=<your session key guid>) to accompany further transactions with the TP server. 2 ways of authenticating:

1. Obtain a higher privileged session key that has access to your account transactions, etc. :- You need to login with your GW2 client then obtain this session key either through fiddler or through other means (e.g. reading it off the GW2 client process memory or reading it off the GW2 browser cache).

2. Obtain a lower privileged session key by doing a HTTPS POST to https://account.guildwars2.com/login?redirect_uri=http%3A%2F%2Ftradingpost-live.ncplatform.net%2Fauthenticate%3Fsource%3D%252F&game_code=gw2 with the following parameters:

email = <your email address that you use to login to GW2>
password = <your password that you use to login to GW2>

Note that method 2 doesn’t require your GW2 client to be running and is useful for querying most of the data that you may need from the TP. I recommend using method 2 as your default means of authentication and only fall back to method 1 when you need to perform privileged transactions (e.g. create buy orders, cancel transactions, query current or past transactions, etc.) on your account.

(edited by DarkSpirit.7046)

Guide to the Black Lion Trading Co API

in API Development

Posted by: Tonikor.5637

Tonikor.5637

What do I do when i get an “ERROR: Invalid authorization” message?

I’m asking this (and on an “old” post) because I used the tool a couple of days ago and it worked fine.

(edited by Tonikor.5637)

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

What do I do when i get an “ERROR: Invalid authorization” message?

I’m asking this (and on an “old” post) because I used the tool a couple of days ago and it worked fine.

Since it worked fine earlier, I suggest that you check the status of your account. Do a login at this URL and check your credentials:

https://account.guildwars2.com/login?redirect_uri=http%3A%2F%2Ftradingpost-live.ncplatform.net%2Fauthenticate%3Fsource%3D%252F&game_code=gw2

Guide to the Black Lion Trading Co API

in API Development

Posted by: Tonikor.5637

Tonikor.5637

works perfect now, thank you

Guide to the Black Lion Trading Co API

in API Development

Posted by: DasPatAttack.2516

DasPatAttack.2516

1. Obtain a higher privileged session key that has access to your account transactions, etc. :- You need to login with your GW2 client then obtain this session key either through fiddler or through other means (e.g. reading it off the GW2 client process memory or reading it off the GW2 browser cache).

Awesome job guys.
I’m actually interested in knowing how to pass the higher privileged session key to connect and get my personal ackitten info.
I manage to get this session id, I’ll find my way fining the well formed url to get my specific user account transaction details but I’m missing the way to connect to your services using the higher privileged session key.
Could you help?
Thanks a bunch.

Guide to the Black Lion Trading Co API

in API Development

Posted by: Ryan.9387

Ryan.9387

The SessionID is included in most of the API requests you send. How I went about it was by using fiddler and copying the format of the requests sent by the game.

Go into the game with fiddler running and open something like “my buy orders.” The youcan minimize the game and look at the request that the game sent to the TP website. From there you simply have to copy the headers and values in your program’s html request.

Here is an example function from python that returns a list of your over cut WTBs. You can see where I pass the SessionID to the TPAPI.

import urllib
import urllib2
import json

def TPMyBuys(SessionID,count):
values = {"time" : “now”,“type” : “buy”,“charid” : "",“offset” : “1”,“count” : count}
data = urllib.urlencode(values)
req = urllib2.Request(“%s” %data)
req.add_header(“Accept” , “/”)
req.add_header(“Accept-Charset” , “iso-8859-1,*,utf-8”)
req.add_header( “Accept-Encoding” , “gzip;q=0”)
req.add_header(“Accept-Language” , “en”)
req.add_header(“Cookie” , SessionID) #<—————-
req.add_header( “User-Agent” , “Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1003.1 Safari/535.19 Awesomium/1.7.1”)
req.add_header(“Connection” , “keep-alive”)
req.add_header(“Host” , “tradingpost-live.ncplatform.net”)
req.add_header(“Referer” ,“https://tradingpost-live.ncplatform.net/me”)
req.add_header( “X-Requested-With” , “XMLHttpRequest”)
response = urllib2.urlopen(req)
parsed_json = json.loads(response.read())
return parsed_json

def TPMyBuysCheck(SessionID):
list = []
OBJ = TPMyBuys(SessionID,0)
OBJ = TPMyBuys(SessionID,str(OBJ[u’total’]))
for Item in OBJ[u’listings’]:
if int(Item[u’buy_price’]) > int(Item[u’unit_price’]):
list.append([str(Item[u’listing_id’]),str(Item[u’data_id’])])
return list

Ranger | Elementalist

(edited by Ryan.9387)

Guide to the Black Lion Trading Co API

in API Development

Posted by: DasPatAttack.2516

DasPatAttack.2516

thanks a lot, going to try that ASAP.

Guide to the Black Lion Trading Co API

in API Development

Posted by: Maximilian.1926

Maximilian.1926

regarding SessionID, how long is it active for after log-out from the game client? and is there a way to “refresh” it to keep it alive? or would something like that be a violation of the rules?

Guide to the Black Lion Trading Co API

in API Development

Posted by: Ryan.9387

Ryan.9387

I found it expires within 10 min or less. Constant use has no effect on it. It seems that you must have the client running to use the API.

Ranger | Elementalist

Guide to the Black Lion Trading Co API

in API Development

Posted by: Galowin.6089

Galowin.6089

is it possible to extract ur bought/sold items lists (to datasheet)?

For Glade and Glory

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

is it possible to extract ur bought/sold items lists (to datasheet)?

Yes you can do that programmatically.

In fact, I did that for my historical records of past items bought/sold, when I realized that I can do this to optimize my app.

My app saves a copy of my past items bought/sold in persistent memory. The next time I launch my app, it only downloads my past transactions up to the latest transactions stored in my persistent memory, saving on downloads, then does a merge of both the newer and older lists dynamically.

Guide to the Black Lion Trading Co API

in API Development

Posted by: Maximilian.1926

Maximilian.1926

anyone know the difference between
https://tradingpost-live.ncplatform.net/ws/listings.json?id=##### and https://tradingpost-live.ncplatform.net/ws/me.json, encoding wise?
Im using python (urllisb2 and json) and I can read the me.json but I keep getting errors on the listings

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

me.json – gets your buy/sell/past buys/past sells transactions.
listings.json – gets the current buy and sell listings on an item.

me.json requires you to have the game client session key in your cookie when you communicate with the server. listing.json doesn’t need to and only requires the session key that you get by posting to “https://account.guildwars2.com/login?redirect_uri=http%3A%2F%2Ftradingpost-live.ncplatform.net%2Fauthenticate%3Fsource%3D%252F&game_code=gw2” with your login email and password. Therefore, listing.json does not require your guild wars 2 client to be running and logined while me.json does.

Guide to the Black Lion Trading Co API

in API Development

Posted by: Maximilian.1926

Maximilian.1926

ok, I know about me.json needing the session key from the client, and I have that working, but I was tiring to use the same key with listings.json, could that be my problem?
I need to get both keys separately? I would think the client session key one should cover it as I can view that data in the client

(edited by Maximilian.1926)

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

ok, I know about me.json needing the session key from the client, and I have that working, but I was tiring to use the same key with listings.json, could that be my problem?
I need to get both keys separately? I would think the client session key one should cover it as I can view that data in the client

You do not need both keys if you already have the game client session key from your guild wars 2 client. That game client session key seems to have a higher privilege in the sense that it has access to more features of the web service (e.g. me.json) than the session key obtained from logging in to a web site. Therefore, if you have access to the game client session key, that is enough.

However, you have to keep your guild wars 2 client running in the background as the game client session key expires, if you log out, after a short while. The other session key lasts longer though and does not require your guild wars 2 client to be running.

Guide to the Black Lion Trading Co API

in API Development

Posted by: Maximilian.1926

Maximilian.1926

ya that was my assumption,
I don’t know why im not able to decode the listing.json… I do get a response in my python program but then it fails at decoding it, while it works fine for me.json, (I have matched the hosts and header info for both requests according to what I get in fiddler from an in client action)

NVM
figured it out, I set accept-encoding to “gzip,q=0”, and now it seems to read it fine… although im now getting “gzip,deflate” from fideller…

(edited by Maximilian.1926)

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

ya that was my assumption,
I don’t know why im not able to decode the listing.json… I do get a response in my python program but then it fails at decoding it, while it works fine for me.json, (I have matched the hosts and header info for both requests according to what I get in fiddler from an in client action)

NVM
figured it out, I set accept-encoding to “gzip,q=0”, and now it seems to read it fine… although im now getting “gzip,deflate” from fideller…

Setting gzip compression is usually a good idea. Although I have not written any python code before for that, I am sure you can easily search for how to uncompress the data in python.

It has been easy enough for me to handle gzip compression on my C# client.

(edited by DarkSpirit.7046)

Guide to the Black Lion Trading Co API

in API Development

Posted by: Ryan.9387

Ryan.9387

All you have to do is ask the API not to compress it in your headers. Read my posted code and note the gzip header. I get the json returned with that code.

Ranger | Elementalist

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

All you have to do is ask the API not to compress it in your headers. Read my posted code and note the gzip header. I get the json returned with that code.

Then you are wasting bandwidth. Gzip reduces the time it takes for the website to transfer the data to your client. If you are not using it, then you are not being efficient.

If your client supports it, you should enable it, especially when it is so easy to uncompress the data.

http://love-python.blogspot.com/2008/07/accept-encoding-gzip-to-make-your.html

(edited by DarkSpirit.7046)

Guide to the Black Lion Trading Co API

in API Development

Posted by: Ryan.9387

Ryan.9387

That works too. I have no bandwidth issues though. Thank my uni internet for that. I may change my code later, but it remains fully functional at the moment.

Ranger | Elementalist

Guide to the Black Lion Trading Co API

in API Development

Posted by: Fossilized Amber.1352

Fossilized Amber.1352

Question that I haven’t found to see in this thread I was directed to. How can you log into the TP and make api calls? I’ve used Fiddler and grabbed my session ID. I’m getting an access control origin error when I try to GET from the above-mentioned urls (to grab item data).

I am trying to keep this simple in JS/HTML, is this possible or do I need a server?

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

You need to be authenticated against their server in order to access the TP data. This will not allow you to access your own account as that would require a session key from the client itself.

Check this out:

https://account.guildwars2.com/login?redirect_uri=http%3A%2F%2Ftradingpost-live.ncplatform.net%2Fauthenticate%3Fsource%3D%252F&game_code=gw2

Guide to the Black Lion Trading Co API

in API Development

Posted by: Fossilized Amber.1352

Fossilized Amber.1352

DarkSpirit, thanks for answering me, although my question isn’t exactly that. I have the session id and don’t know how to make api calls. I can re-direct to the page you linked to, but how can I make the api calls that I want to?

Threads? Server? I’m lost at this point.

I get access cross origin errors, because I am running a server (IIS from a c# project) – if that helps anybit

*Edit, I fixed my issue.

(edited by Fossilized Amber.1352)

Guide to the Black Lion Trading Co API

in API Development

Posted by: StevenL.3761

StevenL.3761

If this is a C# project, then the usual way of dealing with this is to do all of the authentication and stuff on the server side in an ASP.NET Web API project. Your JS script should never need to call the TP service directly. Instead, it should call your own API controller. Your API controller should then take care of network handshakes and all that, then return the requested data from the TP service.

Guide to the Black Lion Trading Co API

in API Development

Posted by: DarkSpirit.7046

DarkSpirit.7046

There 2 levels of session ids.

1. Level 1, you can get by sending your account information to https://account.guildwars2.com.
2. Level 2, gives you level 1 access + more privileges like accessing your own account. You can read it of process memory from your guild wars 2 client itself.

Check up the OP on accessing the TP

Guide to the Black Lion Trading Co API

in API Development

Posted by: Fossilized Amber.1352

Fossilized Amber.1352

Yes, thank you for clarifying what I wanted to say. How does an API controller work when talking to the TP? I can login but I am stuck on how to get my GET requests from the TP to my code. I am loading up the TP in an iframe and heard you can send messages to get around cross origin problems. Currently I can access the TP, change the URL and get my data; how can I program code to change the URL and get data?

Is there code I can see?

Guide to the Black Lion Trading Co API

in API Development

Posted by: StevenL.3761

StevenL.3761

Your JS script calls the API controller on your own server: http://yourserver/tradingpost/listings. This when your C# code takes over. Your API controller first ensures that your server has a valid session, then gets the requested data from the TP service. Returning the data to your script can be as simple as calling ‘Response.Write(json)’. This is when your JS script takes over again. It’s not particularly hard, and I think you’re overthinking this.

tl;dr: your API controller acts as a proxy that hides the complexity of maintaining a session

(edited by StevenL.3761)

Guide to the Black Lion Trading Co API

in API Development

Posted by: Dryalkiel.1385

Dryalkiel.1385

I’m getting the problems with listings.json as well. My Service had been running for months with no problems. Now listings.json doesn’t seem to work anymore. I tried it in my browser and it still throws an Access Denied response. search.json still works though.

Anyone aware of this issue?