Skip to content

Conversation

@PaoloAJ
Copy link
Contributor

@PaoloAJ PaoloAJ commented Oct 3, 2025

What I Changed

Added a new affecting_items field to the StatDetailSerializer that returns items (vitamins and battle items) that affect each stat. This enhancement brings the stat endpoint in line with the existing affecting_moves and affecting_natures fields, providing a complete picture of all factors that can modify a Pokémon's stats.

Files Modified:

  • pokemon_v2/serializers.py - Added get_items_that_affect() method and affecting_items field to StatDetailSerializer
  • Makefile - Added auto-detection for Python/pip commands (minor improvement)

Highlights

  • New get_items_that_affect() method (pokemon_v2/serializers.py:1594): Returns a list of items that affect a given stat
  • Two categories of items tracked:
    • Vitamins (permanent stat boosters): HP Up, Protein, Iron, Calcium, Zinc, Carbos
    • X-Items (temporary battle boosters): X Attack, X Defense, X Sp. Atk, X Sp. Def, X Speed, X Accuracy, X Evasion
  • OpenAPI schema documentation included with proper typing and examples
  • Graceful error handling: Silently skips items that don't exist in the database
  • Consistent with existing patterns: Follows the same structure as affecting_moves and affecting_natures

How to Use

API Endpoint: GET /api/v2/stat/{id}/

Example Request:
curl https://pokeapi.co/api/v2/stat/2/

Example Response (for Attack stat):
{
"id": 2,
"name": "attack",
"affecting_items": [
{
"name": "protein",
"url": "https://pokeapi.co/api/v2/item/46/"
},
{
"name": "x-attack",
"url": "https://pokeapi.co/api/v2/item/47/"
}
],
"affecting_moves": { ... },
"affecting_natures": { ... },
...
}

Significance

This change completes the stat detail endpoint by providing comprehensive information about all game mechanics that affect stats. Previously, the API only exposed moves and natures that affect stats, but items are equally important in the Pokémon games for:

  1. Team building and EV training - Vitamins are essential for stat optimization
  2. Battle strategy - X-items provide temporary boosts during battles
  3. Game completeness - Aligns with how the games present stat-modifying mechanics

This makes the PokéAPI more useful for:

  • Pokémon training calculators and team builders
  • Battle simulators that need to account for item effects
  • Educational tools teaching game mechanics
  • Complete data extraction for Pokémon-related applications

The implementation maintains backward compatibility (purely additive) and follows the existing API design patterns, making it intuitive for current API consumers to adopt.

@PaoloAJ
Copy link
Contributor Author

PaoloAJ commented Oct 3, 2025

Resubmitted PR with rebased master branch.

@Naramsim
Copy link
Member

Hi! Thanks for the PR! It looks like a very useful addition!

@Naramsim Naramsim merged commit 4d2f4e5 into PokeAPI:master Oct 15, 2025
9 checks passed
@pokeapi-machine-user
Copy link

A PokeAPI/api-data refresh has started. In ~45 minutes the staging branch of PokeAPI/api-data will be pushed with the new generated data.

The staging branch will be deployed in our staging environment and the entire API will be ready to review.

A Pull Request (master<-staging) will be also created at PokeAPI/api-data and assigned to the PokeAPI Core team to be reviewed. If approved and merged new data will soon be available worldwide at pokeapi.co.

pokeapi-machine-user added a commit to PokeAPI/api-data that referenced this pull request Oct 15, 2025
@pokeapi-machine-user
Copy link

The updater script has finished its job and has now opened a Pull Request towards PokeAPI/api-data with the updated data.

The Pull Request can be seen deployed in our staging environment when CircleCI deploy will be finished (check the start time of the last build).

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