You can retrieve a one or more footprinted transactions using the Transaction and Transactions endpoints. Let’s start by fetching a single transaction.
Note: make sure you use an actual transaction id, which you can get by footprinting a product.
// Define the API endpoint and headers
const transactionId = "e03304b0-ba04-4a28-b66e-dcfbc1a62c22"; // Replace with your own transaction ID
const apiUrl = `https://api.cooler.dev/v1/transactions/${transactionId}`;
const headers = {
"Cooler-Api-Key": "cooler_test_acaf38b8-5d04-4aa4-87fe-91a67fc13a05",
};
// Make the GET request using fetch
fetch(apiUrl, {
method: "GET",
headers: headers,
})
.then((response) => response.json()) // Parse the JSON response
.then((data) => console.log(data)) // Log the response data
.catch((error) => console.error("Error:", error)); // Log any errors
the number of transactions to skip before returning transactions
limit
number
the maximum number of transactions to return
env
string
dev environment; either “sandbox” or “production”
Response
Code Examples
// Define the API endpoint and headers
const apiUrl = "https://api.cooler.dev/v1/transactions";
const headers = {
"Cooler-Api-Key": "cooler_test_acaf38b8-5d04-4aa4-87fe-91a67fc13a05",
};
// Define query parameters
const queryParams = new URLSearchParams({
skip: 0, // Number of records to skip (pagination)
limit: 10, // Number of records to return
env: "sandbox", // Environment filter (optional)
}).toString();
// Make the GET request using fetch
fetch(`${apiUrl}?${queryParams}`, {
method: "GET",
headers: headers,
})
.then((response) => response.json()) // Parse the JSON response
.then((data) => console.log("Transactions:", data)) // Log the response data
.catch((error) => console.error("Error:", error)); // Log any errors
Let’s try that in curl:
curl -X GET "https://api.cooler.dev/v1/transactions?skip=0&limit=10&env=sandbox" \
-H "Cooler-Api-Key: cooler_test_acaf38b8-5d04-4aa4-87fe-91a67fc13a05"