Pokeapi: Add a property which lists the Pok茅mon that can learn a move (separated by leveling up, TM/HM, breeding, etc.)

Created on 14 Jan 2021  路  17Comments  路  Source: PokeAPI/pokeapi

Maybe I'm not searching hard enough but I don't know how to find the Pok茅mon that can learn a move, so assuming such a feature doesn't exist, what about adding a property listing the Pok茅mon that can learn a move, further separated by method of acquiring like TM/HM, leveling up, breeding, etc (Including overlaps like x type being able to learn a x type move through leveling up as well as learn it from a TM/HM). I know this will mean a bigger API, but maybe you can do the ?limit=x modifier for such things? Sorry this is my third issue on this repo, the docs are really hard to read for me, and I can't usually find what I want.

Most helpful comment

Yeah, I prefer @Naramsim's idea of just providing a list of pokemon that can learn the move.

All 17 comments

I know that you can get a list of moves a pokemon can learn and how it learns them with the pokemon route like so https://pokeapi.co/api/v2/pokemon/charmander in the moves key. Is that what you're looking for?

I know that you can get a list of moves a pokemon can learn and how it learns them with the pokemon route like so https://pokeapi.co/api/v2/pokemon/charmander in the moves key. Is that what you're looking for?

Yes I do know that, however this is much slower in finding out which Pok茅mon knows x move, because I believe it requires looping through every Pok茅mon.

So say I have move x, how do I know which pokemon can learn x move? Moreover, seperate them by how they can be acquired, for example shadow ball can be learned by leveling up and TM/HM by Gengar.

json //Shadow Ball { "name":"shadow-ball", "learnable":{ "leveling-up":[ "...", "gengar", "..." ], "tm-hm":[ "...", "gengar", "..." ], "breeding":[ //I believe no one can learn shadow ball through breeding though I may have to fact check it ] } }

Yes, that could be a nice feature.

We need a volunteer to start developing it :)

I would be glad to, but I have no experience developing API's, sorry.

I assume this would be on the /move/id endpoint. Some pokemon moves differ from version to version, so if that's included the structure could get pretty complicated. There's 20 different version groups and 10 different move learn methods. Maybe something like this?:

//Shadow Ball
{
  "name": "shadow-ball",
  "learnable": {
    "version_group_details": [
      "0": { //First Version Group
        "move_learn_method": [
          "0": { //First Learn Method
            "name": "level-up",
            "url": "https://pokeapi.co/api/v2/move-learn-method/1/",
            "pokemon": [{"name": "gengar", "url": "..."}, {...}]
          },
          "1": { //Second Learn Method
            "name": "egg",
            "url": "...",
            "pokemon": [{"name": "...", "url": "..."}, {...}]
          }
          ...
        ],
        "version_group": {
          "name": "red-blue", 
          "url": "..."
        }
      },
      "1": { //Second Version Group
        ...
      },
      ...
    ]
  },
  ...
}

hmm what about this instead?

{
    "name":"shadow-ball",
    "learnable": [
            {
                "name": "gengar",
                "url": "...",
                "versions": [
                    {
                        "name":"red-blue",
                        "url":"...",
                        "learn-methods":[
                            "breeding", "leveling-up","tm-hm"
                        ]
                    }
                ]
            }
    ]
}

Actually replace the array of strings learn-methods with an array of objects, such that each learn method can show its URL and stuff.

OK I actually realized what version groups are, so I think this might work:

{
    "name": "shadow-ball",
    "url": "https://pokeapi.co/api/v2/move/247/",
    "learnable": [
        {
            "pokemon": {
                "name": "gengar",
                "url": "https://pokeapi.co/api/v2/pokemon/94/"
            },
            "version_group_details": [//just copied this from gengar's site and searching for shadow-ball
                {
                    "level_learned_at": 0,
                    "move_learn_method": {
                        "name": "machine",
                        "url": "https://pokeapi.co/api/v2/move-learn-method/4/"
                    },
                    "version_group": {
                        "name": "gold-silver",
                        "url": "https://pokeapi.co/api/v2/version-group/3/"
                    }
                },
                {
                    "level_learned_at": 0,
                    "move_learn_method": {
                        "name": "machine",
                        "url": "https://pokeapi.co/api/v2/move-learn-method/4/"
                    },
                    "version_group": {
                        "name": "crystal",
                        "url": "https://pokeapi.co/api/v2/version-group/4/"
                    }
                },
                {
                    "level_learned_at": 0,
                    "move_learn_method": {
                        "name": "machine",
                        "url": "https://pokeapi.co/api/v2/move-learn-method/4/"
                    },
                    "version_group": {
                        "name": "ruby-sapphire",
                        "url": "https://pokeapi.co/api/v2/version-group/5/"
                    }
                },
                {
                    "level_learned_at": 0,
                    "move_learn_method": {
                        "name": "machine",
                        "url": "https://pokeapi.co/api/v2/move-learn-method/4/"
                    },
                    "version_group": {
                        "name": "emerald",
                        "url": "https://pokeapi.co/api/v2/version-group/6/"
                    }
                },
                {
                    "level_learned_at": 45,
                    "move_learn_method": {
                        "name": "level-up",
                        "url": "https://pokeapi.co/api/v2/move-learn-method/1/"
                    },
                    "version_group": {
                        "name": "firered-leafgreen",
                        "url": "https://pokeapi.co/api/v2/version-group/7/"
                    }
                },
                {
                    "level_learned_at": 0,
                    "move_learn_method": {
                        "name": "machine",
                        "url": "https://pokeapi.co/api/v2/move-learn-method/4/"
                    },
                    "version_group": {
                        "name": "firered-leafgreen",
                        "url": "https://pokeapi.co/api/v2/version-group/7/"
                    }
                }
                //.....
            ]
        }
    ]
}

I just

Either we do as @C-Garza suggested or we could even be rougher and don't mention version groups.

For each move we provide a list of Pokemon that can learn that move. Having provided the link to the pokemon to the requester allows the requester to query the pokemon and discover in which version it can learn the move and at which conditions (level-up, ...)

Yeah, I prefer @Naramsim's idea of just providing a list of pokemon that can learn the move.

So, we can link to the pokemon and using that link find out which versions they learn the move and how they learn the move? Sounds great to me!

I made a C++ script to approximate what the JSON of the moves would be (no idea of the python way of creating the API, let alone how REST APIs work, and since I had a lot of time), I got a maximum of ~82KB on substitute, with 941 Pok茅mon (including forms unfortunately/fortunately), as well as a total size of 13-14MB for all the moves. Maybe add a ?pokemon_limit and maybe a ?show_forms boolean (do booleans modifiers exist?).

@ChrisMGeo I opened a PR with the change. Returning a simple list of Pok茅mon with a link. The resulting JSON for substitute is ~100KB

substitute.json.zip

Had to compress it since Github doesn't allow me to upload JSON.

Perhaps the size difference is due to using '\/' instead of '/' but it might also be something else. This is what I got:

164.zip

The size difference is because I was getting a cached response of the first version of the endpoint I did. Here's the actual result, 88,7聽KiB (90.783 bytes). It could be because your JSON has pokeapi.co for the URL while mine uses localhost:

substitute.json.zip

Ah, thanks for the clarification, I hope the request gets merged.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

renatoi picture renatoi  路  7Comments

sourcedexter picture sourcedexter  路  4Comments

fleeting picture fleeting  路  5Comments

victorwss picture victorwss  路  5Comments

neverendingqs picture neverendingqs  路  5Comments