Eethy.6421:

I’m working on a sort of item database app.

My notion is to get the item IDs from https://api.guildwars2.com/v1/items.json and then request each item individually to refresh my data.

I’m trying to cache all the item data in order to implement some searching and sorting.

Is that alright?

Do that, say, every five minutes would that be ok?

Thanks

smiley.1438:

Cliff answered this more than once before and stated that there’s no specific limit but it would be good when we’d cache the results when possible.

See: https://forum-en.guildwars2.com/forum/community/api/How-often-is-the-event-data-updated/first#post2063497
and
https://forum-en.guildwars2.com/forum/community/api/names-json-static/first#post2064473

AcidicVision.5498:

I was recently working on something like this myself. An issue will will come up against is that getting the entire item array and then iterating through it to get each item is a loooong operation and a ton of objects (especially if you are doing this for a mobile app). Consider there are nearly 30k ids and you could be doing an individual connection for every item.

A practical solution I came up with is to create an SQL database and write a PHPscript to populate it. Each entry in my case contains the item ID, name, type, rarity and level.

In the UI the user selects a type filter and level/rarity if they desire, then the app queries the database for all matching, puts their names into a dynamic list and holds on to only the item_id. When one is picked is connects to the API to get the rest of the details and displays them all pretty like.

You’ll be keeping API calls minimal and low resource usage on the user side.

You can also schedule the script to run once a week or so to query the GW2 build number, and update the database if its changed (which in all liklihood will be every kitten time with all the updates) but its still better than your app making 30k api calls on each use.

smiley.1438:

Each entry in my case contains the item ID, name, type, rarity and level.

In the UI the user selects a type filter and level/rarity if they desire, then the app queries the database for all matching, puts their names into a dynamic list and holds on to only the item_id.

What about storing the JSON in your database too, so you don’t need to request the api to get the data (and keep in mind that you need to request the api 4 times for an item if you need all languages…)
have a look at this:

http://gw2wbot.darthmaim.de/itemlist.php
http://gw2wbot.darthmaim.de/smiley/gw2itemsearch.html

Eethy.6421:

I like that website. Really nice.

I’m planning to cache the data in a DB (PostgreSQL) and search against that.

I need to figure out a strategy to keep the data current.

In this post referring to event names, Cliff Spradlin says you only need to update your data after a patch.

I’m not sure whether that’s also true of items.

smiley.1438:

Items are added as soon they are discovered and like other APIs, items.json is updated in realtime, so you may want to check this frequently. However, renaming of items (especially translations) or other changes to them only happen during patches. A list of changed items during an update has been requested more than once, hope this is going to happen soon