rubensayshi / gw2spidy

GW2Spidy - Guild Wars 2 Tradingpost Graphs
http://www.gw2spidy.com
231 stars 86 forks source link

Get data of multiple items in a single request #152

Closed georg94 closed 10 years ago

georg94 commented 10 years ago

It would be nice, if I could request the data of multiple items in one request. At the Moment I can only get one item per request. For exaple if I want the current prices for "Pile of Crystalline Dust", "Destroyer Core" and "Bottle of Elonian Wine" I have to make three requests to the API:

curl http://www.gw2spidy.com/api/v0.9/json/item/24277
curl http://www.gw2spidy.com/api/v0.9/json/item/24324
curl http://www.gw2spidy.com/api/v0.9/json/item/19663

It would be less effort for the API if you could make a request like this:

curl http://www.gw2spidy.com/api/v0.9/json/items/24277,24324,19663

or

curl -X POST http://www.gw2spidy.com/api/v0.9/json/items -d '{ [24277, 24324, 19663] }'

And get a result like this:

{
  "results":[
    {
      "data_id": 24277,
      "img": "https://render.guildwars2.com/file/080D00670558CD9E580D5662030394B2206E92A6/434537.png",
      "max_offer_unit_price": 2128,
      "min_sale_unit_price": 2200,
      "name": "Pile of Crystalline Dust",
      "offer_availability": 79207,
      "offer_price_change_last_hour": 0,
      "price_last_changed": "2014-08-05 13:14:50 UTC",
      "rarity": 2,
      "restriction_level": 0,
      "sale_availability": 64281,
      "sale_price_change_last_hour": 0,
      "sub_type_id": 0,
      "type_id": 5
    },
    {
      "data_id": 24324,
      "img": "https://render.guildwars2.com/file/D59CDF80A1C9C061ED729C78BAA5980DAC75BE4C/66975.png",
      "max_offer_unit_price": 328,
      "min_sale_unit_price": 406,
      "name": "Destroyer Core",
      "offer_availability": 8388,
      "offer_price_change_last_hour": 0,
      "price_last_changed": "2014-08-05 13:14:54 UTC",
      "rarity": 4,
      "restriction_level": 0,
      "sale_availability": 36710,
      "sale_price_change_last_hour": 0,
      "sub_type_id": 0,
      "type_id": 5
    },
    {
      "data_id": 19663,
      "img": "https://render.guildwars2.com/file/CC720B5A5810A84FD97AB00FA43F1679C48074DE/455843.png",
      "max_offer_unit_price": 2420,
      "min_sale_unit_price": 3143,
      "name": "Bottle of Elonian Wine",
      "offer_availability": 796,
      "offer_price_change_last_hour": 0,
      "price_last_changed": "2014-08-05 13:11:08 UTC",
      "rarity": 7,
      "restriction_level": 0,
      "sale_availability": 939,
      "sale_price_change_last_hour": 0,
      "sub_type_id": 2,
      "type_id": 16
    }
  ]
}
shrykull commented 10 years ago

in case anyone else stumbles upon this issue: RTFM and try

    /api/v0.9/json/items/*all*?filter_ids=24277,24324 

this feature is actually already supported! ;)

rubensayshi commented 10 years ago

hehe, thanks for answering that yourself ;-)

it's abit of a hidden featuer because with large lists of IDs it's kinda painful for the server ( > 100 IDs with high frequency of requesting it )