recipes API [request]
Is it possible to have the Recipes actual name returned?
You get the name with API:2/items and “output_item_id”.
In your case:
https://api.guildwars2.com/v2/items/46742 that returns “Lump of Mithrillium”.
Is it possible to have the Recipes actual name returned?
You get the name with API:2/items and “output_item_id”.
In your case:
https://api.guildwars2.com/v2/items/46742 that returns “Lump of Mithrillium”.
I know this.
Also this is the name of the end result of using the recipe. (not the recipe item name)
Also I know its not much of a problem, I could add the word "Recipe: " to it.
But it was a Request, not an issue.
I wanted to keep the number of send/receive to a minimum.
As it is, to get what I want (Create a list of Recipe’s I Have) I would have to:
1. Get ID’s of recipes I have. (v2/account/recipes)
2. Create a coma separated string of ID’s and get the Recipe info. (v2/recipes?ids=string of ids) that didn’t work so:
for next loop for each ID (v2/recipes/id)
a lot of send/receive
3. Now to create a list of recipes I have by name.
Wait for the above to complete(2), another for next loop finding the output of each, then adding "Recipe: " to all results, the number of send/receive is adding up.
If the name was added to the recipe info I would be able to make my list without step 3.
Better still if the end point from: v2/account/recipes was id & name.
Then a list could be created and the recipe info would only be request on selection in the list. Saving the need to make a for next loop to download the info for all recopies at one time.
Could I change the request
I know that not all info are stored in API:2/recipes, I also explained something here https://forum-en.gw2archive.eu/forum/community/api/bad-skin-s-id. So, for example, adding the name of a recipe doens’t avoid you from loading item from API:2/items if you want to show the rarity color too, but that increase the amount of data from API:2/recipes (ok a bit ;D) and you get it again from API:2/items.
As you have said you can add "Recipe: " to the output item name, but your example is not a recipe learned from item, so the name of auto learned recipes is exactly the output item name. What can I say now is that actually for recipes learned from item the recipe item id is missing in API:2/recipes; for auto learned recipes the recipe item does not exist.
In my opinion you don’t have to add "Recipe: " and the output item name is enough.
Anyway you don’t have to make a loop for each id, that is ok sometimes with only few ids, but for a lot of them you have to use “v2/recipes?ids=string of ids” where “string of ids” is a comma separated string of maximum 200 ids. It is very important that your string does not go over 200 ids because it will return an error.
What you have to do is a loop that create a new string of maximum 200 ids, then get those maximum 200 recipes from API:2/recipes. (It is like ?page=number of page?size=200 where 200 is maximum size of items you can get from api in a single request). After that you get all output_item_id from your list and do a similar loop with API:2/items.
Even if API:2/recipes could be optimized adding all the necessary infos directly there, using “?ids=” you get all data needed in few seconds.
I think that if you fix your loop at point 2. you’ll get a substantial boost.
what I would like to see returned from the recipes api is the data_id of the recipe sheet that you learn that recipe from.
for example: https://api.guildwars2.com/v2/recipes/3327
this recipe makes “Pot of Artichoke Soup”
you learn this recipe by consuming “Recipe: Pot of Artichoke Soup”, data_id 9798
so you’d add to /recipes/3327 this text:
"learned_from_id":9798
OR
an alternative would be to add to the item’s api the recipe_id the item unlocks. so you’d add to /items/9798 the text:
"teaches_recipe_id":3327
edit: nevermind! it’s already there!
https://api.guildwars2.com/v2/items/9772
"details":{"type":"Unlock","unlock_type":"CraftingRecipe","recipe_id":3301}
Mystic’s Gold Profiting Guide
Forge & more JSON recipes
(edited by Mystic.5934)
Anyway you don’t have to make a loop for each id, that is ok sometimes with only few ids, but for a lot of them you have to use “v2/recipes?ids=string of ids” where “string of ids” is a comma separated string of maximum 200 ids. It is very important that your string does not go over 200 ids because it will return an error.
What you have to do is a loop that create a new string of maximum 200 ids, then get those maximum 200 recipes from API:2/recipes. (It is like ?page=number of page?size=200 where 200 is maximum size of items you can get from api in a single request). After that you get all output_item_id from your list and do a similar loop with API:2/items.
Even if API:2/recipes could be optimized adding all the necessary infos directly there, using “?ids=” you get all data needed in few seconds.
I think that if you fix your loop at point 2. you’ll get a substantial boost.
Oh, thanks for the info, I did not know about the 200 limit, I suspected there might be a limit, but was not sure.
I still think it’s name should be included though
Practically everything else that has a name, has the name returned.