SDK Installation

Get the JustTCG JavaScript/TypeScript SDK up and running in your project.

Installation

Install the SDK using npm or your preferred package manager:

npm install justtcg-js

Or with yarn:

yarn add justtcg-js

Or with pnpm:

pnpm add justtcg-js
Zero Dependencies: The SDK has no production dependencies, making it lightweight and secure.

Basic Import

Import the SDK in your TypeScript or JavaScript file:

import { JustTCG } from 'justtcg-js';

For CommonJS environments:

const { JustTCG } = require('justtcg-js');

Environment Setup

The SDK automatically looks for the JUSTTCG_API_KEY environment variable. This is the recommended approach for production environments.

Setting Environment Variables

Node.js (.env file)

# .env JUSTTCG_API_KEY=your_api_key_here

Command Line

export JUSTTCG_API_KEY="your_api_key_here"

Windows (PowerShell)

$env:JUSTTCG_API_KEY="your_api_key_here"
Security Best Practice: Never commit API keys to version control. Use environment variables or secure secret management systems in production.

TypeScript Setup

The SDK is written in TypeScript and provides full type definitions out of the box. No additional setup is required for TypeScript projects.

Type Safety Example

import { JustTCG } from 'justtcg-js';

const client = new JustTCG();

// TypeScript will provide autocomplete and type checking
const response = await client.v1.cards.get({
  game: 'Pokemon', // ✅ TypeScript knows this is a string
  limit: 10,       // ✅ TypeScript knows this is a number
  orderBy: 'price' // ✅ TypeScript knows valid values
});

// response.data is fully typed
response.data.forEach(card => {
  console.log(card.name); // ✅ TypeScript knows card has a name property
  console.log(card.variants); // ✅ TypeScript knows card has variants array
});

Next Steps