LartTyler / MHWDB-Docs

API documentation for the Monster Hunter World API (https://mhw-db.com)
Other
62 stars 6 forks source link

Resource slug problem #38

Closed kuroham closed 5 years ago

kuroham commented 5 years ago

The armor and item can't seem to be parsed through the slug but only the id. I'm really new to programming and I'm trying to write a small program for my cousin to check on the items as well as practice my coding skills. Any advice on how to solve this problem? (Great work by the way! The weapon and decoration parts are working as smooth as butter)

LartTyler commented 5 years ago

I think that's a case of the docs being a bit out of date. I've been phasing out the slug field on most objects, which would be why it works for weapons but not for armor or items. Do you need to use the slug, or will the ID work for your project? The API's next update will remove slug completely, since very few people are actually using it.

kuroham commented 5 years ago

It would be better for me to use the slugs since the way my project works is to prompt the user to enter the name of a certain item(weapons, armor, charms etc), so using the slug is more convenient since I can just concatenate the string to https://mhw-db.com and get the information I need without much hassle.

LartTyler commented 5 years ago

As far as pulling up an item by it's name, you should check out the Searching the API section of the docs.

For example, to retrieve any armor piece named "Leather Gloves", you could send a GET request to https://mhw-db.com/armor?q={"name":"Leather+Gloves"}. It'll return an array, but since the name is unique, you can just grab the first item in the array and go from there.

kuroham commented 5 years ago

OH, the problem has been solved! Thank you for responding to my problem.

LartTyler commented 5 years ago

No problem! Feel free to reach out if you have any other questions.