To access the MarketCheck API, you need to generate API credentials. Follow these steps:
MarketCheck API supports two primary authentication methods: API Key and OAuth 2.0. Both methods ensure secure access to the API endpoints, you can choose the one that best fits your use case.
api_key
in all the API requests. Value is the API key generated in the previous step.import axios from 'axios';
const options = {
method: 'GET',
url: 'https://api.marketcheck.com/v2/listing/car/3FTTW8M34RRA21879-b4178158-1a02',
params: {api_key: 'YOUR_API_KEY'},
headers: {Accept: 'application/json'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
Exchange your API credentials - API key and client secret for a time-limited access token using the client credentials flow.
First generate new access token using the API key and client secret. This token is then used to authenticate API requests.
import axios from 'axios';
const options = {
method: 'POST',
url: 'https://api.marketcheck.com/oauth2/token',
headers: {Accept: 'application/json', 'Content-Type': 'application/json'},
data: {
grant_type: 'client_credentials',
client_id: 'YOUR_API_KEY',
client_secret: 'YOUR_CLIENT_SECRET'
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
Use the access token in the Authorization
header for subsequent API requests.
import axios from 'axios';
const options = {
method: 'GET',
url: 'https://api.marketcheck.com/oauth/v2/listing/car/3FTTW8M34RRA21879-b4178158-1a02',
headers: {Accept: 'application/json', Authorization: 'Bearer YOUR_ACCESS_TOKEN'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
/oauth/v2/
instead of /v2/
. For brevity, this documentation shows /v2/
in examples, but OAuth users should replace it with /oauth/v2/
MarketCheck provides endpoints to manage your OAuth2 tokens, allowing you to list active tokens and revoke them when needed. This is useful for security management and cleaning up unused tokens.
Retrieve a list of active OAuth2 tokens for your credentials.
Query Parameters:
Parameter | Required | Description |
---|---|---|
api_key | Yes | Your OAuth2 client ID |
next | No | Offset token for pagination |
import axios from 'axios';
const options = {
method: 'GET',
url: 'https://api.marketcheck.com/oauth2/tokens',
params: {api_key: 'YOUR_API_KEY'}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}
Revoke one or more OAuth2 tokens to immediately invalidate them.
Request Body:
Field | Required | Description |
---|---|---|
client_id | Yes | Your OAuth2 client ID (API key) |
client_secret | Yes | Your OAuth2 client secret |
access_tokens | Yes | Array of access tokens to revoke (maximum 15 tokens per request, must be non-empty, each token must be unique) |
client_id
and client_secret
provided in the revocation request. Tokens from different credentials will be ignored.import axios from 'axios';
const options = {
method: 'POST',
url: 'https://api.marketcheck.com/oauth2/tokens/revoke',
headers: {Accept: 'application/json', 'Content-Type': 'application/json'},
data: {
client_id: 'YOUR_API_KEY',
client_secret: 'YOUR_CLIENT_SECRET',
access_tokens: ['token1', 'token2']
}
};
try {
const { data } = await axios.request(options);
console.log(data);
} catch (error) {
console.error(error);
}