🚀 Quick Start Guide
Get started with Card Market API in minutes
Quick Start Guide
Get up and running with Card Market API in just a few minutes. This guide will walk you through everything you need to make your first API call.
Prerequisites
Before you begin, make sure you have:
- A Card Market developer account
- Your preferred programming language installed
- A tool to make HTTP requests (curl, Postman, or your IDE)
Step 1: Get Your API Credentials
-
Sign up for a developer account at developers.cardmarket.com
-
Navigate to the API Keys section in your developer dashboard
-
Generate a new API key and copy it to a secure location
Keep your API key secure! Never expose it in client-side code or public repositories.
Step 2: Make Your First API Call
Let's start with a simple request to get user information:
cURL
curl -X GET "https://api.market.decenctype.com/user" \
-H "X-API-KEY: your-api-key-here" \
-H "Content-Type: application/json"JavaScript
const response = await fetch('https://api.market.decenctype.com/user', {
method: 'GET',
headers: {
'X-API-KEY': 'your-api-key-here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);Python
import requests
url = "https://api.market.decenctype.com/user"
headers = {
"X-API-KEY": "your-api-key-here",
"Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
data = response.json()
print(data)Node.js
const axios = require('axios');
const config = {
method: 'get',
url: 'https://api.market.decenctype.com/user',
headers: {
'X-API-KEY': 'your-api-key-here',
'Content-Type': 'application/json'
}
};
axios(config)
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});Step 3: Handle the Response
A successful response will look like this:
{
"success": true,
"data": {
"userId": "12345",
"email": "developer@example.com",
"username": "developer",
"createdAt": "2024-01-01T00:00:00Z",
"status": "active"
},
"message": "User retrieved successfully"
}Common Use Cases
Now that you've made your first API call, here are some common next steps:
User Authentication
If you're building a user-facing application, you'll want to implement user authentication:
// Register a new user
const registerResponse = await fetch('https://api.market.decenctype.com/auth/register', {
method: 'POST',
headers: {
'X-API-KEY': 'your-api-key-here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'user@example.com',
password: 'securePassword123',
username: 'newuser',
code: '123456' // Email verification code
})
});
// Login user
const loginResponse = await fetch('https://api.market.decenctype.com/auth/login', {
method: 'POST',
headers: {
'X-API-KEY': 'your-api-key-here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'user@example.com',
password: 'securePassword123'
})
});
const loginData = await loginResponse.json();
const userToken = loginData.data.token;Working with Cards
Access card marketplace features:
// Get available cards
const cardsResponse = await fetch('https://api.market.decenctype.com/cards', {
method: 'GET',
headers: {
'Authorization': `Bearer ${userToken}`,
'Content-Type': 'application/json'
}
});
// Create a new order
const orderResponse = await fetch('https://api.market.decenctype.com/orders', {
method: 'POST',
headers: {
'Authorization': `Bearer ${userToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
cardId: 'card-123',
quantity: 1,
price: 99.99
})
});Wallet Operations
Manage digital wallets and transactions:
// Get wallet address
const walletResponse = await fetch('https://api.market.decenctype.com/wallet/address?type=user&chainType=USDT', {
method: 'GET',
headers: {
'Authorization': `Bearer ${userToken}`,
'Content-Type': 'application/json'
}
});
// Get transaction history
const transactionsResponse = await fetch('https://api.market.decenctype.com/transactions', {
method: 'GET',
headers: {
'Authorization': `Bearer ${userToken}`,
'Content-Type': 'application/json'
}
});Error Handling
Always implement proper error handling for your API calls:
async function makeApiCall(url, options) {
try {
const response = await fetch(url, options);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
if (!data.success) {
throw new Error(data.error?.message || 'API request failed');
}
return data.data;
} catch (error) {
console.error('API call failed:', error);
throw error;
}
}Rate Limiting
Be mindful of rate limits to ensure smooth operation:
class ApiClient {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = 'https://api.market.decenctype.com';
this.requestQueue = [];
this.isProcessing = false;
}
async request(endpoint, options = {}) {
return new Promise((resolve, reject) => {
this.requestQueue.push({ endpoint, options, resolve, reject });
this.processQueue();
});
}
async processQueue() {
if (this.isProcessing || this.requestQueue.length === 0) return;
this.isProcessing = true;
while (this.requestQueue.length > 0) {
const { endpoint, options, resolve, reject } = this.requestQueue.shift();
try {
const response = await fetch(`${this.baseUrl}${endpoint}`, {
...options,
headers: {
'X-API-KEY': this.apiKey,
'Content-Type': 'application/json',
...options.headers
}
});
const data = await response.json();
resolve(data);
} catch (error) {
reject(error);
}
// Add delay to respect rate limits
await new Promise(resolve => setTimeout(resolve, 100));
}
this.isProcessing = false;
}
}Next Steps
Congratulations! You've made your first API call. Here's what to explore next:
API Reference
Explore all available endpoints and their parameters
Authentication Guide
Learn about different authentication methods
SDKs & Libraries
Use our official SDKs for faster development
Examples & Tutorials
Real-world examples and step-by-step tutorials
Need Help?
If you run into any issues:
- Check our FAQ for common questions
- Join our Discord community for real-time help
- Contact support at developers@cardmarket.com
Pro Tip: Use our interactive API explorer in each endpoint's documentation to test requests directly in your browser!