RedGlow.2715:

Hello,
maybe I’m just missing something, but it seems to me it is not possible right now to obtain which item(s) can be consumed in order to obtain a specific recipe.

To make it more clear:

The data is there, because if I look at a recipe item (e.g.: https://api.guildwars2.com/v2/items/9615 ), I can get on the “details” field that it is a recipe unlock, and which recipe it unlocks. What I would need is a reverse search on that field (analogous to the endpoint /recipes/search, which is a reverse search on the recipes).

Am I missing something or is this feature currently not implemented?

smiley.1438:

Hmm, thats weird because usually there’s a “details” object in the item response, containing “unlock_type” and “recipe_id” like in here https://api.guildwars2.com/v2/items/48452. In the last days i noticed that some items were missing the “details” for whatever reason – and so does the one you picked: https://api.guildwars2.com/v2/items/9615.

However, in order to do a reverse lookup, you’d best have a database of the items and recipes endpoint so you could just do:

-- get the id of the recipe-unlock for an item
SELECT * FROM `gw2_items` where `unlock_type` = 'CraftingRecipe' AND `unlock_id` = (SELECT `recipe_id` FROM `gw2_recipes` WHERE `output_id` = 48106)

RedGlow.2715:

Well, both items you linked (yours, and mine) contain the details field, actually. But that’s not my problem: I need to get the ids of these items, and not informations about them, starting from the recipe id.

So, to pick a practical example: starting from the item id 19621 (gift of metal), I can obtain its recipe id through https://api.guildwars2.com/v2/recipes/search?output=19621 (recipe: gift of metal) and get 6074, from there get recipe through https://api.guildwars2.com/v2/recipes/6074 , and get that it has the flag LearnedFromItem… but then the APIs can’t help me any longer, because I don’t know which item(s) unlock the recipes 6074.

Sadly, in the project where I need this functionality, I have no support database in the backend that can scratch the whole items database continuously, and can only rely to direct calls to the APIs. So, right now, I’ll have to hardcode the recipe ids for the items I need.

smiley.1438:

Well, both items you linked (yours, and mine) contain the details field, actually.

Now it gets super weird, because i could swear it wasn’t there. Caching issue, devs?

Well, if you haven’t access to a database, why not just save a .json (or whatever type suits you best) containing the recipe- and output-ids from recipes.json – that’d be enough to backlink.

RedGlow.2715:

Caching, pain and delight!

But, yeah, I’ve relied to a similar solution. Now I’ll look if I can propose this kind of reverse-API access.

Thanks for the confirmations!