Authentication
API key से TCG Price Lookup API requests authenticate करने का तरीका।
API Key Authentication
TCG Price Lookup API, API key-based authentication उपयोग करती है। हर request में API key शामिल करनी होती है।
Header Authentication (Recommended)
X-API-Key header में API key pass करें:
curl https://api.tcgpricelookup.com/v1/search?q=charizard \
-H "X-API-Key: your-api-key"
Query Parameter Authentication
Alternative के रूप में, query parameter के रूप में pass करें:
curl "https://api.tcgpricelookup.com/v1/search?q=charizard&api_key=your-api-key"
ध्यान दें: Header authentication ज्यादा secure है। Query parameter के रूप में pass करने से API key server logs में record हो सकती है।
SDKs से Authentication
SDKs सभी authentication automatically handle करते हैं:
// JavaScript
import { TCGLookup } from 'tcglookup';
const tcg = new TCGLookup({ apiKey: process.env.TCG_API_KEY });
# Python
from tcglookup import TCGLookup
tcg = TCGLookup(api_key=os.environ['TCG_API_KEY'])
API Key Security
- API key को version control में commit न करें
- Environment variables (
TCG_API_KEY) का उपयोग करें - Client-side code या frontend में API key expose न करें
- Key leak होने पर dashboard से तुरंत rotate करें
Error Response
Authentication errors 401 Unauthorized return करते हैं:
{
"error": {
"code": "unauthorized",
"message": "Invalid or missing API key"
}
}