Tutorials

How to Find the Most Valuable Pokémon Cards in Any Set with JustTCG & Python

Ever wonder if that booster box you’re eyeing is worth it? Or what the top chase cards are in the latest Pokémon TCG set? Whether you’re a collector, a player, or a developer building the next great TCG app, knowing a set’s most valuable cards is powerful information.

JustTCG Editor
July 25, 2025
6 minute read
0 views

Share this article

How to Find the Most Valuable Pokémon Cards in Any Set with JustTCG & Python

Today, we’re going to build a simple but powerful Python script that acts like a treasure map. Using the JustTCG API, we’ll connect to our real-time pricing data and, in just a few lines of code, uncover the top 10 most valuable cards from any Pokémon TCG set.

Ready to start the hunt? Let’s dive in.

Prerequisites

Before we begin, make sure you have the following:

  1. **Python 3** installed on your machine.
  2. A free JustTCG API Key. If you don’t have one, you can sign up for a free account to get started. Your free plan includes 1,000 API calls per month!
  3. Your API key set as an environment variable. We recommend this for security. You can set it in your terminal like this:
export JUSTTCG_API_KEY='YOUR_API_KEY_HERE'

Step 1: Setting Up Our Python Script

First, let’s create a new file called market_scanner.py.

Inside this file, we’ll import the necessary libraries (requests to talk to the API and os to get our API key) and set up our basic variables.

# market_scanner.py  
import os  
import requests  
  
# Your JustTCG API Key  
# Best practice is to store this as an environment variable  
API_KEY = os.getenv("JUSTTCG_API_KEY")  
BASE_URL = "https://api.justtcg.com/v1"  
HEADERS = {"x-api-key": API_KEY}  
  
def main():  
    """Main function to run our market scanner."""  
    print("Starting the JustTCG Market Scanner...")  
if __name__ == "__main__":  
    main()

This simple structure gives us a great starting point.

Step 2: Finding the ID for Our Target Set

To search for cards within a specific set, we first need that set’s unique identifier (setId). The JustTCG API provides a /sets endpoint to find this. Since we're looking for Pokémon sets, our gameId will be Pokemon.

Let’s write a function to find the setId for "SV04: Paradox Rift".

def get_set_id(set_name: str, game_name: str) -> str | None:  
    """Fetches the set ID for a given set name."""  
    print(f"Querying for all {game_name} sets...")  
    url = f"{BASE_URL}/sets"  
  
    params = {"game": game_name}  
  
    try:  
        response = requests.get(url, headers=HEADERS, params=params)  
        response.raise_for_status() # Raises an exception for bad status codes (4xx or 5xx)  
          
        sets = response.json()["data"]  
          
        print(f"Found {len(sets)} sets. Searching for {set_name}...")  
  
        for s in sets:  
            if s["name"].lower() == set_name.lower():  
                print(f"Found set '{s['name']}' with ID: {s['id']}")  
                return s['id']  
          
        print("Set not found.")  
        return None  
    except requests.exceptions.RequestException as e:  
        print(f"An error occurred: {e}")  
        return None  
  
# Add this to our main function  
def main():  
    """Main function to run our market scanner."""  
    print("Starting the JustTCG Market Scanner...")  
    target_set_name = "SV04: Paradox Rift"  
    target_game = "Pokemon"  
    set_id = get_set_id(target_set_name, target_game)  
      
    if not set_id:  
        print("Could not find set ID. Exiting.")  
        return

Now, when we run our script, it will connect to the API, find the ID for “SV04: Paradox Rift,” and store it for the next step.

Step 3: Searching for the Top 10 Most Valuable Cards

This is where the magic happens. We’ll use the /cards endpoint, which is built for discovery. We'll pass it the setId we just found and use a few key parameters to get exactly what we need:

  • orderBy=price: This tells the API to sort the results by their market price.
  • order=desc: This sorts them in descending order, from most to least expensive.
  • limit=10: This ensures we only get the top 10 results.

Let’s create our search function.

def find_top_cards(set_id: str, limit: int = 10):  
    """Finds the most valuable cards in a given set."""  
    print(f"\nSearching for the top {limit} most valuable cards...")  
    url = f"{BASE_URL}/cards"  
      
    params = {  
        "set": set_id,  
        "orderBy": "price",  
        "order": "desc",  
        "limit": limit,  
    }  
      
    try:  
        response = requests.get(url, headers=HEADERS, params=params)  
        response.raise_for_status()  
          
        cards = response.json()["data"]  
          
        print("\n--- Top 10 Most Valuable Cards ---")  
        for i, card in enumerate(cards, 1):  
            card_name = card['name']  
            highest_priced_variant = max(  
                (variant for variant in card["variants"]), key=lambda x: x["price"]  
            )  
            market_price = highest_priced_variant["price"]  
            variant_printing = highest_priced_variant["printing"]  
            variant_condition = highest_priced_variant["condition"]  
            print(  
                f"{i}. {card_name} ({variant_printing}) - {variant_condition} - ${market_price}"  
            )  
    except requests.exceptions.RequestException as e:  
        print(f"An error occurred: {e}")  
# And finally, update main to call our new function  
def main():  
    """Main function to run our market scanner."""  
    print("Starting the JustTCG Market Scanner...")  
    target_set_name = "SV04: Paradox Rift"  
    target_game = "Pokemon"  
    set_id = get_set_id(target_set_name, target_game)  
      
    if not set_id:  
        print("Could not find set ID. Exiting.")  
        return  
          
    find_top_cards(set_id)

Putting It All Together

Here is the complete, final script. You can save this as market_scanner.py and run it directly from your terminal (python market_scanner.py) to see the results instantly.

# market_scanner.py  
import os  
import requests  
  
# Your JustTCG API Key  
# Best practice is to store this as an environment variable  
API_KEY = os.getenv("JUSTTCG_API_KEY")  
BASE_URL = "https://api.justtcg.com/v1"  
HEADERS = {"x-api-key": API_KEY}  
  
  
def get_set_id(set_name: str, game_name: str) -> str | None:  
    """Fetches the set ID for a given set name."""  
    print(f"Querying for all {game_name} sets...")  
    url = f"{BASE_URL}/sets"  
  
    params = {"game": game_name}  
  
    try:  
        response = requests.get(url, headers=HEADERS, params=params)  
        response.raise_for_status()  # Raises an exception for bad status codes (4xx or 5xx)  
  
        sets = response.json()["data"]  
  
        print(f"Found {len(sets)} sets. Searching for {set_name}...")  
  
        for s in sets:  
            if s["name"].lower() == set_name.lower():  
                print(f"Found set '{s['name']}' with ID: {s['id']}")  
                return s["id"]  
  
        print("Set not found.")  
        return None  
    except requests.exceptions.RequestException as e:  
        print(f"An error occurred: {e}")  
        return None  
  
  
def find_top_cards(set_id: str, limit: int = 10):  
    """Finds the most valuable cards in a given set."""  
    print(f"\nSearching for the top {limit} most valuable cards...")  
    url = f"{BASE_URL}/cards"  
  
    params = {  
        "set": set_id,  
        "orderBy": "price",  
        "order": "desc",  
        "limit": limit,  
    }  
  
    try:  
        response = requests.get(url, headers=HEADERS, params=params)  
        response.raise_for_status()  
  
        cards = response.json()["data"]  
  
        print(f"\n--- Top {limit} Most Valuable Cards in {set_id}---")  
        for i, card in enumerate(cards, 1):  
            card_name = card["name"]  
            highest_priced_variant = max(  
                (variant for variant in card["variants"]), key=lambda x: x["price"]  
            )  
            market_price = highest_priced_variant["price"]  
            variant_printing = highest_priced_variant["printing"]  
            variant_condition = highest_priced_variant["condition"]  
            print(  
                f"{i}. {card_name} ({variant_printing}) - {variant_condition} - ${market_price}"  
            )  
    except requests.exceptions.RequestException as e:  
        print(f"An error occurred: {e}")  
  
  
def main():  
    """Main function to run our market scanner."""  
    if not API_KEY:  
        print("Error: JUSTTCG_API_KEY environment variable not set.")  
        return  
    print("Starting the JustTCG Market Scanner...")  
    target_set_name = "SV04: Paradox Rift"  
    target_game = "Pokemon"  
    set_id = get_set_id(target_set_name, target_game)  
  
    if not set_id:  
        print("Could not find set ID. Exiting.")  
        return  
  
    find_top_cards(set_id)  
  
  
if __name__ == "__main__":  
    main()

Next Steps

And there you have it! You’ve successfully built a tool that provides real-time market insights.

From here, the possibilities are endless:

  • Try another set: Change the target_set_name variable to "Crown Zenith" or "SV03: Obsidian Flames".
  • Order by price change: Change the orderBy parameter value to 24h or7d (e.g. orderBy=7d)
  • Look for foils: Add the printing=Holofoil parameter to your find_top_cards function.
  • Build a simple web app: Use a framework like Flask or FastAPI to create a simple web interface for your scanner.
  • Track prices over time: Store the results in a database or a CSV file and run the script daily to see how prices fluctuate.

We’re excited to see what you build. For more advanced features and endpoint details, be sure to check out our full API Documentation. Happy coding!

J
Published by

JustTCG Editor

July 25, 2025

Share this article