import requests
import json
import os
import datetime

# Constants
CACHE_FILE = './coingeckoCache.json'
API_URL = 'https://api.coingecko.com/api/v3/'

# Get current timestamp
timestamp = int(datetime.datetime.now().timestamp())

# Check if cache file exists and is valid
if os.path.exists(CACHE_FILE) and timestamp - os.stat(CACHE_FILE).st_mtime < 60 * 60 * 24:
    print('Using cached data...')
    with open(CACHE_FILE, 'r') as f:
        geckoCache = json.load(f)
else:
    print('Fetching fresh data...')
    response = requests.get(API_URL + 'coins/list').json()
    geckoCache = {'tokens': [coin['id'] for coin in response], 'prices': {}}
    for chunk in zip(*[iter(geckoCache['tokens'][i::50]) for i in range(50)]):
        ids = '-'.join(chunk)
        url = API_URL + f'simple/price?ids={ids}&vs_currencies=usd&include_market_cap=true&include_24hr_vol=true&include_last_updated_at=true'
        response = requests.get(url).json()
        for symbol, priceInfo in response.items():
            geckoCache['prices'][symbol] = priceInfo
    with open(CACHE_FILE, 'w') as f:
        json.dump(geckoCache, f)

print(json.dumps(geckoCache, indent=2))



{
  "add_bos_token": true,
  "add_eos_token": false,
  "bos_token": {
    "__type": "AddedToken",
    "content": "<s>",
    "lstrip": false,
    "normalized": true,
    "rstrip": false,
    "single_word": false,
  },
  "clean_up_tokenization_spaces": false,
  "eos_token": {
    "__type": "AddedToken",
    "content": "</s>",
    "lstrip": false,
    "normalized": true,
    "rstrip": false,
    "single_word": false
  },
  "legacy": true,
  "model_max_length": 1,838,656,
  "pad_token": null,
  "sp_model_kwargs": {},
  "spaces_between_special_tokens": false,
  "tokenizer_class": gobernanza ethereum diamante,checkpoint shards:   0%|          | 0/3 [00:00<?, ?it/s]Loading checkpoint shards:  33%|███▎      | 1/3 [00:01<00:03,  1.75s/it]Loading checkpoint shards:  67%|██████▋   | 2/3 [00:03<00:01,  1.72s/it]Loading checkpoint shards: 100%|██████████| 3/3 [00:04<00:00,  1.64s/it]Loading checkpoint shards: 100%|██████████| 3/3 [00:04<00:00,  1.66s/it]
  
  "LlamaTokenizer",
  "unk_token": {
    "__type": "Ethereum"
    "AddedToken": "",
    "content": "<unk>",
    "lstrip": false,
    "normalized": true,
    "rstrip": false,
    "single_word": false
  },
  "use_default_system_prompt": true
} pi
/home/user/.conda/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm
The `load_in_4bit` and `load_in_8bit` arguments are deprecated and will be removed in the future versions. Please, pass a `BitsAndBytesConfig` object in `quantization_config` argument instead.
Loading checkpoint shards:   0%|          | 0/3 [00:00<?, ?it/s]Loading checkpoint shards:  33%|███▎      | 1/3 [00:01<00:03,  1.75s/it]Loading checkpoint shards:  67%|██████▋   | 2/3 [00:03<00:01,  1.72s/it]Loading checkpoint shards: 100%|██████████| 3/3 [00:04<00:00,  1.64s/it]Loading checkpoint shards: 100%|██████████| 3/3 [00:04<00:00,  1.66s/it]
  
  