Skip to content

MAT Token Price API (CoinMarketCap)

This document explains how to query the live MAT token price in USD using the CoinMarketCap API with a JavaScript example.

🌐 API Provider

  • Base URL: https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest
  • Data Source: CoinMarketCap Pro API

🔹 Request Details

Endpoint

GET /v1/cryptocurrency/quotes/latest

Query Parameters

NameDescription
symbolToken symbol, e.g., MAT
convertFiat currency, e.g., USD

Headers

Header NameValue
Acceptsapplication/json
X-CMC_PRO_API_KEYYour CoinMarketCap API Key

📃 Full JavaScript Example

Prerequisite

Install axios if not already:

bash
npm install axios

Code:

js
const axios = require("axios");

const url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest';
const parameters = {
  symbol: 'MAT',
  convert: 'USD'
};
const headers = {
  'Accepts': 'application/json',
  'X-CMC_PRO_API_KEY': 'Your CoinMarketCap API Key' // Replace with your actual key
};

async function fetchMATPrice() {
  try {
    const response = await axios.get(url, { headers, params: parameters });
    const price = response.data.data.MAT.quote.USD.price;
    console.log(`💲 Current MAT Price: $${price.toFixed(2)}`);
    return price;
  } catch (error) {
    console.error("❌ Error fetching MAT price:", error.message);
    return null;
  }
}

// 👀 Run the function
fetchMATPrice();

📊 Sample Output

💲 Current MAT Price: $20.83

❓ Notes

  • You must have a valid CoinMarketCap API Key to use this endpoint.
  • Do not expose your API key in a public frontend app. Use it in a backend environment.
  • The MAT token must be listed on CoinMarketCap with the correct symbol.

🚀 Ready to Use

Once integrated, this API can be used for:

  • Portfolio tracking
  • Live dashboard pricing
  • Alerts / notifications
  • Yield calculations based on token value