ezd.6359:

Something like it:
… item_details.json?item_id=ID1,ID2[,IDX]

and receive something like it:
{ID1: { … }, ID2: { … }, ID3: { … }}

Or 1 request = 1 item details only?

If not, consider it as a suggestion.

Healix.5819:

When asked to do this for events, the response was to just request everything at once, since the server could handle it. I wish there was the option available though, since 1/2 of the 10 KB/s I use to track events is purely from headers.

For item details though, there is no option, but these requests are something you should have to do only once. The reason why they probably don’t have a request everything option is because of the amount of items that has to be processed per request. If cached however, there’s really no reason not to.

ezd.6359:

I plan to verify my DB after every update (new gw2 build). And i don’t think generation XXXX requests every time is a good idea. I see two ways:

1)
- Mark new/changed items somehow. Add version or timestamp to the “lister” API. So scripts will check for changes only.
- request ?id=1,2,3,4…

2)
- Provide us with FULL list details APIs. We can download full lists, compare it with current DB and make changes if neccessary.

I like the 2nd way. But 1st is ok too.

Same with all APIs like recipes, events, guilds etc.

smiley.1438:

You just need to store the data on your side and compare the APIs item list with your local one, then request the missing items – you don’t need a thousand requests for that.

I’m doing that in 2 steps – first step – update your local data (this is the lazy way of comparing whats missing)

$data = gw2_api_request('items.json');
if(is_array($data) && isset($data['items'])){
	foreach($data['items'] as $item){
		mysqli_query('INSERT IGNORE INTO `gw2_items` (`item_id`) VALUES ('.intval($item).') ');
	}
}

second step – request the missing data:

$count = mysqli_query('SELECT COUNT(*) FROM `gw2_items` WHERE `name_de` = \'\' OR `name_en` = \'\' OR `name_es` = \'\' OR `name_fr` = \'\' ');
if(intval($count[0]) > 0){
	$q = mysqli_query('SELECT `item_id` FROM `gw2_items` WHERE `name_de` = \'\' OR `name_en` = \'\' OR `name_es` = \'\' OR `name_fr` = \'\' ');
	while($row = mysqli_fetch_assoc($q)){
		$data = gw2_api_request('item_details.json?item_id='.$row['item_id'].'&lang=de');
		if(is_array($data) && !isset($data['error'])){
			// yada yada yada...
		}
	}
}

Since items don’t change that often, this ist still the best strategy. If you really need the latest data, you should rely on a direct request.

ezd.6359:

It works but with NEW items only. But if they change something like recipe components (fix exploits/bugs), change soulbind parameter etc, we need to compare additional info from item_details and similar API scripts.

smiley.1438:

I realized that when i hit the post button… ;D Anyway, what about a “just-in-time” refresh? Usually you don’t need the latest data for search features. So when you then call a specific item or reciepe, your app calls the API and refreshes the DB if the data is outdated.

ezd.6359:

Search by name, but not by item details/recipe components.

Healix.5819:

Only a handful of items will ever change and in most cases, it should happen within the first few months of an expansion or major release. The build changes too often to rely on it. You’d be re-caching everything every few days and 99% of the time, nothing will change.

If the system needs to be automated, re-cache items based on how old their cache is. For example, 30 days from the day you cached said item, update it. After say, 6 months, the item probably won’t be changed again, so either stop checking those, or increase the time between checks.

If you can rely on the user, add an option to flag the item to be updated, since eventually, the user will find the error.

Another method is to manually update items by reading patch notes or by parsing the patch notes for item names, though the notes usually miss a lot.

ezd.6359:

I want to track changes between versions/builds, it is not a problem. Also such information changes with new builds only. One request per update – should not be a problem for gw2 servers.