From e1239e03a79bb5549cfa9928166558f3f2bc79a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tokin=20=E2=AC=A2=20Cypher?= Date: Wed, 27 Aug 2025 20:19:14 -0700 Subject: [PATCH] Added API endpoint for CoinGecko SUpply--1hour pull .github/workflows/update-supply.yml file, js/updateSupply.js, and supply.json --- .github/workflows/update-supply.yml | 33 +++++++++++++++++++++++++++++ assets/js/updatesupply.js | 30 ++++++++++++++++++++++++++ supply.json | 5 +++++ 3 files changed, 68 insertions(+) create mode 100644 .github/workflows/update-supply.yml create mode 100644 assets/js/updatesupply.js create mode 100644 supply.json diff --git a/.github/workflows/update-supply.yml b/.github/workflows/update-supply.yml new file mode 100644 index 00000000..6f6ac918 --- /dev/null +++ b/.github/workflows/update-supply.yml @@ -0,0 +1,33 @@ +name: Update Supply Data + +on: + schedule: + - cron: '0 * * * *' # Runs every hour + workflow_dispatch: + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install dependencies + run: npm install + + - name: Run supply update script + run: node js/updateSupply.js + + - name: Commit updated supply.json + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + git add supply.json + git commit -m "Auto-update supply data" + git push \ No newline at end of file diff --git a/assets/js/updatesupply.js b/assets/js/updatesupply.js new file mode 100644 index 00000000..e1bf3ed3 --- /dev/null +++ b/assets/js/updatesupply.js @@ -0,0 +1,30 @@ +const fs = require('fs'); +const https = require('https'); + +const url = 'https://api.coingecko.com/api/v3/coins/solana/contract/GsKuLQsKCEnfQxuk4icTEQjc11Av8WiqW31CxZqZpump'; + +https.get(url, (res) => { + let data = ''; + + res.on('data', chunk => data += chunk); + res.on('end', () => { + try { + const json = JSON.parse(data); + const market = json.market_data; + + const supplyData = { + circulating_supply: market.circulating_supply || 0, + total_supply: market.total_supply || 0, + max_supply: market.max_supply || 0, + last_updated: new Date().toISOString() + }; + + fs.writeFileSync('supply.json', JSON.stringify(supplyData, null, 2)); + console.log('✅ supply.json updated'); + } catch (err) { + console.error('❌ Error parsing CoinGecko response:', err); + } + }); +}).on('error', err => { + console.error('❌ Request failed:', err); +}); \ No newline at end of file diff --git a/supply.json b/supply.json new file mode 100644 index 00000000..20af25b1 --- /dev/null +++ b/supply.json @@ -0,0 +1,5 @@ +{ + "circulating_supply": 605320738, + "total_supply": 999473006, + "max_supply": 1000000000 +} \ No newline at end of file