Tutorials

Your First Call: Integrating JustTCG Pricing Data in Minutes

So, you’ve learned about JustTCG and explored the powerful features our dedicated TCG Pricing API offers. Now it’s time to get hands-on and see just how easy it is to integrate real-time, condition-specific pricing data into your project!

JustTCG Editor
April 4, 2025
5 minute read
0 views

Share this article

Your First Call: Integrating JustTCG Pricing Data in Minutes

This guide will walk you through the essential steps, from getting your API key to making your very first successful request. Our goal? To have you retrieving TCG pricing data in minutes.

Let’s dive in!

Step 1: Grab Your API Key

Before you can make any calls, you need to authenticate. JustTCG uses simple API key authentication.

  1. Head over to JustTCG.com: If you haven’t already, sign up for an account. We offer a generous free tier, perfect for getting started and testing.
  2. Find Your API Key: Once registered and logged in, navigate to your account dashboard or settings page. You’ll find your unique API key listed there.
  3. Keep it Secret, Keep it Safe: Treat your API key like a password! Don’t expose it in client-side code or public repositories.

Got your key? Excellent! Let’s use it.

Step 2: Authenticating Your Requests

All requests to the JustTCG API need to include your API key in the x-api-key HTTP header. This tells our server that the request is coming from you and allows us to track usage against your plan limits.

It looks like this:

x-api-key: tcg_your_unique_api_key_here

You’ll add this header to every API call you make.

Step 3: Making Your First API Call (GET /cards)

Let’s retrieve the price for a single card. The simplest way is using the GET /cards endpoint. You just need the tcgplayerId for the card you’re interested in. You can optionally add condition and printing parameters for more specific results.

For this example, let’s look up a popular card. Let’s say its tcgplayerId is 162145.

Here’s how you can make the request using different common tools/languages:

Using curl (Command Line):

curl -X GET "https://api.justtcg.com/functions/v1/cards?tcgplayerId=162145" \
-H "x-api-key: your_unique_api_key_here"

Using JavaScript (fetch):

const apiKey = 'your_unique_api_key_here';
const tcgPlayerId = '162145';
const url = https://api.justtcg.com/functions/v1/cards?tcgplayerId=${tcgPlayerId};

fetch(url, {
method: 'GET',
headers: {
'x-api-key': apiKey
}
})
.then(response => {
if (!response.ok) {
throw new Error(HTTP error! status: ${response.status});
}
return response.json();
})
.then(data => {
console.log('Card Price Data:', data);
})
.catch(error => {
console.error('Error fetching price:', error);
});

Using Python (requests):

import requests
import json

api_key = 'your_unique_api_key_here'
tcg_player_id = '162145'
url = f"https://api.justtcg.com/functions/v1/cards?tcgplayerId={tcg_player_id}"

headers = {
'x-api-key': api_key
}

try:
response = requests.get(url, headers=headers)
response.raise_for_status() # Raises an HTTPError for bad responses (4XX or 5XX)

price_data = response.json()  
print("Card Price Data:")  
print(json.dumps(price_data, indent=2))  

except requests.exceptions.RequestException as e:
print(f"Error fetching price: {e}")
if response is not None:
print(f"Status Code: {response.status_code}")
try:
print(f"Response Body: {response.json()}") # Try to print error details from API
except json.JSONDecodeError:
print(f"Response Body: {response.text}") # Print as text if not JSON

Run one of these examples, and you should get back some pricing data!

Step 4: Understanding the Response

If your request was successful, JustTCG will return a JSON object containing the pricing information for the card you requested. It will look something like this:

{
"id": "magic-dominaria-rona,-disciple-of-gix", // JustTCG internal ID
"tcgplayerId": "162145", // The ID you requested
"name": "Rona, Disciple of Gix", // Card Name
"game": "Magic: The Gathering", // Game
"set": "Dominaria", // Card Set
"variants":[
{
"condition": "Near Mint",
"printing": "Normal",
"price": 0.99,
"lastUpdated": 1712855000
},
// ... other variants
]
}

(Note: If you specify condition and printing in your request, those values will be reflected here. If the card isn’t found, you’ll receive a 404 error — see our _Docs for error formats_.)

Congratulations! You’ve successfully retrieved TCG pricing data using the JustTCG API.

Bonus: Looking Up Multiple Cards (POST /cards

Need prices for a whole deck, inventory list, or buy-list? Making individual GET requests can be inefficient. That’s where the POST /cards endpoint comes in handy!

You can send a list of cards (with their tcgplayerId, and optional condition and printing) in the request body, and get back an array of results in a single call. Check out the API Documentation for POST /cards for details and examples.

Bonus: Can I Use JustTCG in Google Sheets?

We saw this question pop up! While JustTCG is primarily designed as a REST API for developers building applications, you can potentially integrate it into Google Sheets using Google Apps Script.

Apps Script allows you to write JavaScript that can fetch data from external URLs (like our API, using UrlFetchApp) and populate cells in your sheet. You would need to write a custom script function to:

  1. Take inputs (like tcgplayerId) from cells.
  2. Make the authenticated API call to GET /cards.
  3. Parse the JSON response.
  4. Write the desired price back into another cell.

We don’t provide an official Sheets Add-on currently, but the possibility is there for those comfortable with Apps Script!

What’s Next?

You’ve made your first call — the possibilities are now wide open!

  • Explore Further: Dive deeper into the JustTCG API Documentation to discover all endpoints and parameters.
  • Start Building: Integrate JustTCG into your TCG storefront, collection tracker, inventory tool, or that cool side project you’ve been thinking about.
  • Need Help? If you run into issues or have questions, don’t hesitate to reach out to our Support.

We’re excited to have you on board and can’t wait to see what you build with JustTCG!

J
Published by

JustTCG Editor

April 4, 2025

Share this article