Skip to content

Item prices#1431

Open
anhthang wants to merge 10 commits intoPokeAPI:masterfrom
anhthang:item-prices
Open

Item prices#1431
anhthang wants to merge 10 commits intoPokeAPI:masterfrom
anhthang:item-prices

Conversation

@anhthang
Copy link
Contributor

@anhthang anhthang commented Mar 7, 2026

Add ItemPrice model and exposes per-version item pricing data

  • Populate item prices from a new CSV source: ‎data/v2/csv/item_prices.csv
  • Remove the old ‎Item.cost field in favor of the new structured pricing model.

Closes #1406 and #1397, #1398

Example REST API response

GET /api/v2/item/305/
{
    "id": 305,
    "name": "some-item-name",
    "fling_power": null,
    "fling_effect": null,
    "category": {
        "name": "held-items"
    },
    "prices": [
        {
            "is_purchasable": true,
            "purchase_price": 3000,
            "sell_price": 1500,
            "version_group": {
                "name": "red-blue",
                "url": "https://pokeapi.co/api/v2/version-group/1/"
            }
        },
        {
            "is_purchasable": false,
            "purchase_price": null,
            "sell_price": 1500,
            "version_group": {
                "name": "ruby-sapphire",
                "url": "https://pokeapi.co/api/v2/version-group/3/"
            }
        }
    ]
}

Example GraphQL queries

v1beta: item with prices

query ItemWithPrices {
  pokemon_v2_item_by_pk(id: 305) {
    id
    name
    pokemon_v2_itemprices {
      is_purchasable
      purchase_price
      sell_price
      pokemon_v2_versiongroup {
        id
        name
      }
    }
  }
}

v1beta2: item with itemprice relation

query ItemWithItemprice {
  pokemon_v2_item_by_pk(id: 305) {
    id
    name
    itemprices {
      is_purchasable
      purchase_price
      sell_price
      versiongroup {
        id
        name
      }
    }
  }
}
{
    "data": {
        "item": [
            {
                "id": 305,
                "name": "tm01",
                "cost": null,
                "itemnames": [
                    {
                        "name": "TM01"
                    }
                ],
                "itemprices": [
                    {
                        "is_purchasable": true,
                        "purchase_price": 3000,
                        "sell_price": 1500,
                        "versiongroup": {
                            "id": 1,
                            "name": "red-blue",
                        }
                    },
                    {
                        "is_purchasable": false,
                        "purchase_price": null,
                        "sell_price": 1500,
                        "versiongroup": {
                            "id": 5,
                            "name": "ruby-sapphire",
                        }
                    }
                ]
            }
        ]
    }
}

@anhthang anhthang marked this pull request as draft March 7, 2026 16:21
@anhthang
Copy link
Contributor Author

anhthang commented Mar 8, 2026

Hi @Naramsim! Could you share your thoughts on the new ItemPrice model and the prices API shape? I'd like to confirm this is the right direction.

@anhthang anhthang force-pushed the item-prices branch 3 times, most recently from 0d594ce to 4423e08 Compare March 9, 2026 07:09
@anhthang anhthang marked this pull request as ready for review March 9, 2026 10:23
@anhthang anhthang marked this pull request as draft March 9, 2026 14:21
@anhthang anhthang marked this pull request as ready for review March 10, 2026 14:47
@Naramsim
Copy link
Member

Hi! Thanks for the implementation. Would it be fine to remove the is_purchasable property?

By looking at the value of purchase_price we can understand whether we can buy it or not? If it's null we cannot, if it's an integer we can. What do you think?

@Naramsim
Copy link
Member

In regard to this issue #1404, RamType0 could you review this PR?

),
),
("name", models.CharField(max_length=100)),
("cost", models.IntegerField(null=True, blank=True)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't touch old migration files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the cost field in a new migration since it's no longer used?

@anhthang
Copy link
Contributor Author

anhthang commented Mar 10, 2026

Hi! Thanks for the implementation. Would it be fine to remove the is_purchasable property?

By looking at the value of purchase_price we can understand whether we can buy it or not? If it's null we cannot, if it's an integer we can. What do you think?

I think it's fine to remove is_purchasable and rely on purchase_price instead.

I'm also wondering how we should handle items that can be obtained via other “currencies” instead of Poké Dollars, like candies or similar resources (for example, TM001). Do you have any ideas on how we could represent that in the pricing model?

I'm also unsure. We would first need a list of all available methods and then discuss the best solution.

@anhthang
Copy link
Contributor Author

Add script to scrape Poké Ball prices from Bulbapedia. If this works well, I'll handle other item categories in separate PRs

@anhthang anhthang requested a review from Naramsim March 12, 2026 14:22
@Naramsim
Copy link
Member

Hi! I posted a reply but it doesn't show up. Maybe I lost my connection while I submitted it. Anyways, regarding all the possible way for obtaining items in the game and all possible currencies that can be used, I'd say: let's understand all possible ways for obtaining items. There are surely many ways, for TM100 I see Spheres, League Points, Berry points, Candies... So it's a mess.

We could either have the cost property expose a list of prices, and in the price we define the unit as well. Now the price is an integer, we could tranform it in a string, so that we can do things like:

{
    "id": 305,
    "name": "some-item-name",
    "fling_power": null,
    "fling_effect": null,
    "category": {
        "name": "held-items"
    },
    "prices": [
        {
            "purchase_price": "$3000",
            "sell_price": "$1500",
            "version_group": {
                "name": "red-blue",
                "url": "https://pokeapi.co/api/v2/version-group/1/"
            }
        },
        {
            "purchase_price": "5 Spheres",
            "sell_price": "3 candies",
            "version_group": {
                "name": "red-blue",
                "url": "https://pokeapi.co/api/v2/version-group/1/"
            }
        },
        ...
    ]
}

or

{
    "id": 305,
    "name": "some-item-name",
    "fling_power": null,
    "fling_effect": null,
    "category": {
        "name": "held-items"
    },
    "prices": [
        {
            "purchase_price": ["$3000","2 Battle exp point"],
            "sell_price": ["$1500","3 Candies"],
            "version_group": {
                "name": "red-blue",
                "url": "https://pokeapi.co/api/v2/version-group/1/"
            }
        },
        ...
    ]
}

This way doesn't account for conditions though. More over the price maybe changes based on the location where it's purchased. I'm not that knowledgable.

@anhthang
Copy link
Contributor Author

"purchase_price": ["$3000","2 Battle exp point"],
"sell_price": ["$1500","3 Candies"]

This might be difficult for users to parse and work with.

Could we add a new currencies.csv model for this? I think it would be easier to extend in the future.

id,identifier,name
1,poke-dollar,Poké Dollar
2,battle-point,Battle Point
3,sphere,Sphere
4,candy,Candy
5,berry-point,Berry Point
{
  "purchase_price": 3000,
  "sell_price": 1500,
  "currency_id": 1,
  "version_group": {
    "name": "red-blue",
    "url": "https://pokeapi.co/api/v2/version-group/1/"
  }
}

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.

Item.cost actually varies between versions

2 participants