Skip to content

Conversation

@BitTim
Copy link

@BitTim BitTim commented Sep 24, 2025

Also updated related data and tests

What is this PR about?

This PR solves #1266 since it was something I need for my personal project as well.
In general, all I did was add a new field to PokemonDexNumber, that references a specific Pokemon as well, since there are Pokedexes (Basically every one from Gen 7 up until now) that have regional variants of Pokemon, which were not differentiated in the API up until now (There is also the Blueberry Dex from Gen 9 that has regional variants from regions that differ from the games region). The Pokemon themselves return also now contain a 'pokedex_numbers' array field, to be consistent with Pokemon Species.

How to test

Spin up a local instance of the API with the most recent migrations and request any pokedex (I recommend id 33) and observe the pokemon_entries field. Each item should now contain a fourth 'pokemon' field that references a Pokemon. Example (Omitted some fields and values for clarity):

https://<base_url>/api/v2/pokedex/33

{
  "id": 33,
  "name": "blueberry",
  "pokemon_entries": [
    {
      "entry_number": 3,
      "pokemon_species": {
        "name": "exeggcute",
        "url": "http://localhost:8000/api/v2/pokemon-species/102/"
      },
      "pokemon": {
        "name": "exeggcute",
        "url": "http://localhost:8000/api/v2/pokemon/102/"
      }
    },
    {
      "entry_number": 4,
      "pokemon_species": {
        "name": "exeggutor",
        "url": "http://localhost:8000/api/v2/pokemon-species/103/"
      },
      "pokemon": {
        "name": "exeggutor-alola",
        "url": "http://localhost:8000/api/v2/pokemon/10114/"
      }
    }
  ]
}

Pokemon now also contain the 'pokedex_numbers' field, one can request any Pokemon and observe the contents of that field as well. Example (Omitted some fields and values for clarity):

https://<base_url>/api/v2/pokemon/194

{
  "id": 194,
  "name": "wooper",
  "pokedex_numbers": [
    {
      "entry_number": 58,
      "pokedex": {
        "name": "isle-of-armor",
        "url": "http://localhost:8000/api/v2/pokedex/28/"
      }
    },
    {
      "entry_number": 5,
      "pokedex": {
        "name": "kitakami",
        "url": "http://localhost:8000/api/v2/pokedex/32/"
      }
    }
  ]
}

What about compatibility?

Since I only added the new fields while keeping the existing ones, there should be no issues with compatibility with already existing clients.

Where did the data come from?

The data I updated the CSV with was input by hand and came from a combination of PokeWiki and the already present PokeApi.

@Naramsim
Copy link
Member

Hi! Thanks for the contribution! I'm checking it out locally in the next days. In the meantime, could you remove from the PR all the files that have been just formatted? So that's going to be easier for me to review all the changes

- I used black to format the entire project while I was fighting with the CI/CD pipeline
@BitTim
Copy link
Author

BitTim commented Sep 27, 2025

Hi! Thank you for taking your time reviewing my PR! I just pushed the commit where I reverted the files that I had reformatted while fighting with the CI Pipeline that are not relevant to this PR

@Naramsim
Copy link
Member

Naramsim commented Oct 1, 2025

Hi! We merged a PR that brought in a schema change and now your branch fails. Could you take a look?

- Swapped migrations 0019 and 0020 to keep them in order of merges on master
@BitTim
Copy link
Author

BitTim commented Oct 1, 2025

Already on it, I was testing locally before I pushed the fix, should be working again

@BitTim
Copy link
Author

BitTim commented Oct 8, 2025

Hey, just wanted to check if there are any updates? Just curious, not trying to rush

@Naramsim
Copy link
Member

Hi Sorry I'm extremely busy at the moment!

@BitTim
Copy link
Author

BitTim commented Oct 10, 2025

No worries! Like I said, I was just curious

@Naramsim
Copy link
Member

Hi! Is it possible that two pokemon belonging to the same species are part of a pokedex? If so hot to handle this case?

@BitTim
Copy link
Author

BitTim commented Oct 15, 2025

Hi, Fair point!
As far as I am aware no pokedex contains multiple varieties of the same species up until now.

I would assume that if a newer pokemon game would get a pokedex where multiple varieties of the same species would be present, then each variety would get an own entry number. If this is the case, there would be no conflict and the API would simply return something among these lines (Omitted fields for clarity and used mock data):

{
  "id": 34,
  "name": "future-pokedex",
  "pokemon_entries": [
    {
      "entry_number": 1,
      "pokemon_species": {
        "name": "example",
        "url": "<BASE_URL>/api/v2/pokemon-species/1/"
      },
      "pokemon": {
        "name": "example-variety1",
        "url": "<BASE_URL>/api/v2/pokemon/1/"
      }
    },
    {
      "entry_number": 2,
      "pokemon_species": {
        "name": "example",
        "url": "<BASE_URL>/api/v2/pokemon-species/1/"
      },
      "pokemon": {
        "name": "example-variety2",
        "url": "<BASE_URL>/api/v2/pokemon/10001/"
      }
    }
  ]
}

The only conflict I would see is with the implementation of the national pokedex, which is a collection of every species that exists. This case can be handled by fetching the provided species and getting the corresponding variant, which is the same as before my changes.

I hope this answers your question 😄

@EthanRDoesMC
Copy link

EthanRDoesMC commented Oct 17, 2025

Hey @BitTim, I can think of a few examples of multiple Pokémon forms for one species being available in a regional Pokédex:

  • Mega and G-Max Pokémon
  • Regional variants consisting of multiple forms (Galarian Tauros, Galarian Darmanitan)
  • Any Pokémon initially introduced with multiple forms (Toxtricity, Morpeko, and many other Gen 8 Pokémon; Aegislash, Deoxys, etc etc.)
  • Pokémon that are weird (Ash-Greninja, Pikachu with hats, Minior)

I think this information is worth providing, and it's good future-proofing, as we already know AZ's Floette is in Z-A, and we're about to add a host of new mega evolutions from the same. Might as well do the work now, while there are only 277 variants.

I suggest providing a list of the forms available in each Dex. Of course, since Generation 8, we now have to deal with forms no longer being available, so we can't just go off of the generation it was introduced in. For the long term: Perhaps we should start tracking what Pokemon are available in which games...?

@BitTim
Copy link
Author

BitTim commented Oct 17, 2025

Thank you for your response @EthanRDoesMC !

If I am not mistaken though, you don't need the examples provided to complete a pokedex. Even though they might have different entry texts than the "main" form of the pokemon (Like the two other forms of Paldean Tauros), they are part of the same entry in-game. Although I must say, I haven't played Sword / Shield yet and it seems like the default and regional variants of most pokemon are also both part of the Galar dex, but are treated as different forms of the same pokemon (Like the Paldean Tauros).

I agree that it would also be handy to be able to get all forms that are in a game as well, since currently each form must be checked explicitly if they contain the desired versionGroup reference, but I think greater changes than this would be more suited for v3, since there already is a desire to simplify the API structure in terms of forms/variants/species.

There is a field in the pokemon variants though, that references all versions (specific games), the variant is in, but that field only reaches up to gen 5 I believe, everything above that is not present unfortunately. There also might be an open issue for that.

@BitTim
Copy link
Author

BitTim commented Oct 18, 2025

Okay, quick update on my previous reply, it seems like I was wrong about some stuff.
I started playing the Indigo Disc DLC yesterday and noticed, that the Blueberry Pokedex (The one I mentioned as an example for my changes) contains multiple variants for the same entry.

To have a more concrete example I am gonna use the Exeggutor. In the data I provided with this PR it seems like only the Alolan form is available in this Dex, but after I found and caught a regular Exeggutor, the pokedex registered that as well under the same entry number as the Alolan Variant. After I also caught the Alolan variant, the pokedex entry just got updated. I also noticed that many entries in the Blueberry dex also have empty slots for different variants of the same species as seen in the images provided below. But what confuses me even more about this, is that Exeggcute does not have any alternative variant or form that I know of, but the slot in the Blueberry dex is still present.
What is even more confusing, is that Basculin is present in its red and blue striped variant in the Paldea Dex, but that does not count towards the Kitakami Dex, which instead has a completely different entry for the white striped Basculin, which also does not count towards the Paldea dex.

Regular and Alolan Exeggutor are part of the same entry
20251018191915-01K7W50EKXMWZ9SMV420DYP1E0

Exeggcute and other entries feature the faint Pokeball placeholder icon on the right side
20251018191901-01K7W50HYRAZ64B5KKQWH7AFMZ

So my conclusion is, I am confused, sometimes specific variants are required and kept separate from one another and sometimes they are thrown together into the same entry. Since the data provided with this PR is faulty as a result of that, I will close this PR without it being merged.

An idea to implement this better would be to provide not a singular variety alongside the species per entry number, but rather a list of references to the variants that all count towards the specific entry. Since I don't know where to get this more specific data from except from playing the games and seeing as the more data has been added for Legends ZA, I will hold of from re-implementing this for now, but may re-visit this later.

Thank you for taking your time and pointing out this issue to me and have a pleasant day!

@BitTim BitTim closed this Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants