I'm trying to retrieve redemption codes (e.g., coupon codes or discounts) from the eBay API using Node.js with axios.
So far, I successfully obtain an OAuth access token using the Client Credentials grant type:
import axios from 'axios';
import qs from 'qs';
const CLIENT_ID = 'your-client-id';
const CLIENT_SECRET = 'your-client-secret';
async function getEbayAccessToken() {
const tokenUrl = '';
const headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': `Basic ${Buffer.from(`${CLIENT_ID}:${CLIENT_SECRET}`).toString('base64')}`
};
const body = qs.stringify({
grant_type: 'client_credentials',
scope: ''
});
try {
const response = await axios.post(tokenUrl, body, { headers });
return response.data.access_token;
} catch (error) {
console.error('Error fetching token:', error.response?.data || error);
return null;
}
}
Then, I make a request to eBay’s Browse API to fetch product listings:
async function getEbayCoupons() {
const accessToken = await getEbayAccessToken();
if (!accessToken) {
throw new Error("Failed to retrieve access token");
}
const url = '';
const headers = {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'X-EBAY-C-MARKETPLACE-ID': 'EBAY_US'
};
const params = { q: 'phone', limit: 10 };
try {
const response = await axios.get(url, { headers, params });
return response.data.itemSummaries || [];
} catch (error) {
console.error('Error fetching items:', error.response?.data || error);
return [];
}
}
I want to retrieve redemption codes (e.g., promotional discounts, coupons) from eBay. I couldn't find any documentation on how to get them via the API. There is lot of documentation but there is too much for me and i asked AI to help without results...
Is there a specific eBay API endpoint for redemption codes? Like all the sites that propose coupon code Can they be retrieved via the Browse API or another service? Any guidance would be appreciated. Thank you very much