API teste validade

<!DOCTYPE html>

<html lang="pt-BR">


<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Dados da Uniswap</title>

    <style>

        body {

            font-family: Arial, sans-serif;

            margin: 20px;

        }


        table {

            width: 100%;

            border-collapse: collapse;

            margin-top: 20px;

        }


        th,

        td {

            border: 1px solid #ddd;

            padding: 8px;

            text-align: center;

        }


        th {

            background-color: #f2f2f2;

        }


        .loading {

            font-style: italic;

            color: gray;

        }


        .error {

            color: red;

        }

    </style>

</head>


<body>

    <h1>Dados da Uniswap</h1>

    <table id="uniswap-table">

        <thead>

            <tr>

                <th>Preço (USD)</th>

                <th>Preço (BRL)</th>

                <th>Capitalização de Mercado (USD)</th>

                <th>Volume em 24h (USD)</th>

                <th>Última Atualização</th>

            </tr>

        </thead>

        <tbody>

            <tr>

                <td colspan="5" class="loading">Carregando dados da Uniswap...</td>

            </tr>

        </tbody>

    </table>


    <h2>Correlação entre UNI e Outras Moedas</h2>

    <table id="correlation-table">

        <thead>

            <tr>

                <th>Moeda</th>

                <th>Correlação com UNI</th>

            </tr>

        </thead>

        <tbody>

            <tr>

                <td colspan="2" class="loading">Carregando dados de correlação...</td>

            </tr>

        </tbody>

    </table>


    <script>

        const apiKey = 'CG-hhr5a3fgUuSDLBxSwMRxZKkC';  // Sua chave da API CoinMarketCap


        async function fetchUniswapData() {

            try {

                const url = `https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=UNI&convert=USD,BRL`;

                const response = await fetch(url, {

                    headers: {

                        'X-CMC_PRO_API_KEY': apiKey

                    }

                });

                if (!response.ok) throw new Error('Erro ao carregar dados da Uniswap: ' + response.status + ' ' + response.statusText);

                

                const data = await response.json();

                console.log("Uniswap data received:", data);

                const uniswapData = data.data.UNI;


                const tableBody = document.querySelector('#uniswap-table tbody');

                tableBody.innerHTML = `

                    <tr>

                        <td>${uniswapData.quote.USD.price}</td>

                        <td>${uniswapData.quote.BRL.price}</td>

                        <td>${uniswapData.quote.USD.market_cap}</td>

                        <td>${uniswapData.quote.USD.volume_24h}</td>

                        <td>${new Date(uniswapData.last_updated).toLocaleString('pt-BR')}</td>

                    </tr>

                `;

            } catch (error) {

                console.error("Error fetching Uniswap data:", error);

                const tableBody = document.querySelector('#uniswap-table tbody');

                tableBody.innerHTML = `

                    <tr>

                        <td colspan="5" class="error">${error.message}</td>

                    </tr>

                `;

            }

        }


        async function fetchHistoricalData() {

            // Implementação similar à anterior, usando outra API ou dados mockados

        }


        function calculateCorrelation(prices1, prices2) {

            const n = Math.min(prices1.length, prices2.length);

            if (n < 2) return 0; // Garantir que haja dados suficientes


            const mean1 = prices1.reduce((a, b) => a + b) / n;

            const mean2 = prices2.reduce((a, b) => a + b) / n;


            let numerator = 0;

            let denominator1 = 0;

            let denominator2 = 0;


            for (let i = 0; i < n; i++) {

                const diff1 = prices1[i] - mean1;

                const diff2 = prices2[i] - mean2;

                numerator += diff1 * diff2;

                denominator1 += diff1 ** 2;

                denominator2 += diff2 ** 2;

            }


            return denominator1 && denominator2 ? (numerator / Math.sqrt(denominator1 * denominator2)) : 0;

        }


        async function updateCorrelationTable() {

            // Implementação similar à anterior, usando outra API ou dados mockados

        }


        // Chamar as funções para buscar os dados

        fetchUniswapData().then(updateCorrelationTable);

    </script>

</body>


</html>


<!DOCTYPE html>

<html lang="pt-BR">


<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Dados da Uniswap</title>

    <style>

        body {

            font-family: Arial, sans-serif;

            margin: 20px;

        }


        table {

            width: 100%;

            border-collapse: collapse;

            margin-top: 20px;

        }


        th,

        td {

            border: 1px solid #ddd;

            padding: 8px;

            text-align: center;

        }


        th {

            background-color: #f2f2f2;

        }


        .loading {

            font-style: italic;

            color: gray;

        }


        .error {

            color: red;

        }

    </style>

</head>


<body>

    <h1>Dados da Uniswap</h1>

    <table id="uniswap-table">

        <thead>

            <tr>

                <th>Preço (USD)</th>

                <th>Preço (BRL)</th>

                <th>Capitalização de Mercado (USD)</th>

                <th>Volume em 24h (USD)</th>

                <th>Última Atualização</th>

            </tr>

        </thead>

        <tbody>

            <tr>

                <td colspan="5" class="loading">Carregando dados da Uniswap...</td>

            </tr>

        </tbody>

    </table>


    <h2>Correlação entre UNI e Outras Moedas</h2>

    <table id="correlation-table">

        <thead>

            <tr>

                <th>Moeda</th>

                <th>Correlação com UNI</th>

            </tr>

        </thead>

        <tbody>

            <tr>

                <td colspan="2" class="loading">Carregando dados de correlação...</td>

            </tr>

        </tbody>

    </table>


    <script>

        const apiKey = 'CG-hhr5a3fgUuSDLBxSwMRxZKkC';  // Sua chave da API CoinMarketCap


        async function fetchUniswapData() {

            try {

                const url = `https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=UNI&convert=USD,BRL`;

                const response = await fetch(url, {

                    headers: {

                        'X-CMC_PRO_API_KEY': apiKey

                    }

                });

                if (!response.ok) throw new Error('Erro ao carregar dados da Uniswap: ' + response.status + ' ' + response.statusText);

                

                const data = await response.json();

                console.log("Uniswap data received:", data);

                const uniswapData = data.data.UNI;


                const tableBody = document.querySelector('#uniswap-table tbody');

                tableBody.innerHTML = `

                    <tr>

                        <td>${uniswapData.quote.USD.price}</td>

                        <td>${uniswapData.quote.BRL.price}</td>

                        <td>${uniswapData.quote.USD.market_cap}</td>

                        <td>${uniswapData.quote.USD.volume_24h}</td>

                        <td>${new Date(uniswapData.last_updated).toLocaleString('pt-BR')}</td>

                    </tr>

                `;

            } catch (error) {

                console.error("Error fetching Uniswap data:", error);

                const tableBody = document.querySelector('#uniswap-table tbody');

                tableBody.innerHTML = `

                    <tr>

                        <td colspan="5" class="error">${error.message}</td>

                    </tr>

                `;

            }

        }


        async function fetchHistoricalData() {

            // Implementação similar à anterior, usando outra API ou dados mockados

        }


        function calculateCorrelation(prices1, prices2) {

            const n = Math.min(prices1.length, prices2.length);

            if (n < 2) return 0; // Garantir que haja dados suficientes


            const mean1 = prices1.reduce((a, b) => a + b) / n;

            const mean2 = prices2.reduce((a, b) => a + b) / n;


            let numerator = 0;

            let denominator1 = 0;

            let denominator2 = 0;


            for (let i = 0; i < n; i++) {

                const diff1 = prices1[i] - mean1;

                const diff2 = prices2[i] - mean2;

                numerator += diff1 * diff2;

                denominator1 += diff1 ** 2;

                denominator2 += diff2 ** 2;

            }


            return denominator1 && denominator2 ? (numerator / Math.sqrt(denominator1 * denominator2)) : 0;

        }


        async function updateCorrelationTable() {

            // Implementação similar à anterior, usando outra API ou dados mockados

        }


        // Chamar as funções para buscar os dados

        fetchUniswapData().then(updateCorrelationTable);

    </script>

</body>


</html>


Minhas chaves de API

+ Adicionar nova chave

Rótulo: peixe do mar

Chave API: CG-hhr5a3fgUuSDLBxSwMRxZKkC

Data de criação: 2024-12-22

Ações

Editar

Estatísticas

Exibir chaves de API excluídas