Glanceway Glanceway
所有信息源

CoinGecko Crypto Markets

财经

Top cryptocurrencies by market cap from CoinGecko

@codytseng #crypto #finance #markets

安装与配置方法

  1. 先在 Mac 上安装并打开 Glanceway,再使用上方的安装链接。
  2. 点击“安装到 Glanceway”。如果浏览器无法唤起应用,下载 .gwsrc 文件并在信息源管理中导入。
  3. 填写下列必填字段并保存,设置刷新间隔,等待首次成功获取。

配置检查

  • CURRENCY — 可选. Display currency for prices
  • ORDER — 可选. How to sort the coin list

当前信息源最多获取 250 个市场资产,支持选择显示币种和排序,没有单独的币种 ID 选择器或 API 密钥字段。仍受上游访问规则及速率限制约束。

配置示例

CURRENCY: usd
ORDER: market_cap_desc

没有显示内容时如何排查

  • 对照当前版本配置表核对字段、列表项和凭据。下方示例不包含可用的真实凭据。
  • 检查网络与上游服务状态。认证失败或速率限制可能导致刷新失败,应根据上游限制调整间隔。
  • 空列表也可能表示没有符合条件的条目。内容和更新时间取决于数据提供方及信息源实现。

配置项

名称 键 类型 必填 默认值 描述
Currency CURRENCY select 否 usd Display currency for prices
usdeurgbpjpycny
Sort Order ORDER select 否 market_cap_desc How to sort the coin list
market_cap_descvolume_desc

源代码

id: codytseng/coingecko-crypto
version: 1.1.0
name: CoinGecko Crypto Markets
description: Top cryptocurrencies by market cap from CoinGecko
author: codytseng
author_url: https://github.com/codytseng
category: Finance
tags:
  - crypto
  - finance
  - markets

config:
  - key: CURRENCY
    name: Currency
    type: select
    required: false
    default: usd
    description: Display currency for prices
    options:
      - usd
      - eur
      - gbp
      - jpy
      - cny
  - key: ORDER
    name: Sort Order
    type: select
    required: false
    default: market_cap_desc
    description: How to sort the coin list
    options:
      - market_cap_desc
      - volume_desc
function currencySymbol(currency) {
  switch (currency) {
    case "usd":
      return "$";
    case "eur":
      return "\u20AC";
    case "gbp":
      return "\u00A3";
    case "jpy":
      return "\u00A5";
    case "cny":
      return "\u00A5";
    default:
      return "";
  }
}

module.exports = async (api) => {
  const currency = api.config.get("CURRENCY") || "usd";
  const order = api.config.get("ORDER") || "market_cap_desc";

  async function fetchData() {
    const url = `https://api.coingecko.com/api/v3/coins/markets?vs_currency=${currency}&order=${order}&per_page=250&sparkline=false`;

    const response = await api.fetch(url);

    if (!response.ok || !response.json) {
      throw new Error(`Failed to fetch CoinGecko market data (HTTP ${response.status})`);
    }

    const now = Date.now();
    const items = response.json.map((item, i) => {
      const change = item.price_change_percentage_24h;
      const changeStr =
        change != null
          ? ` ${change > 0 ? "+" : ""}${change.toFixed(2)}%`
          : "";

      return {
        id: item.id,
        title: `${item.name} (${item.symbol.toUpperCase()})`,
        subtitle: `${currencySymbol(currency)}${item.current_price.toLocaleString("en-US")}${changeStr}`,
        tickerText: `${item.symbol.toUpperCase()} ${currencySymbol(currency)}${item.current_price.toLocaleString("en-US")}${changeStr}`,
        url: `https://www.coingecko.com/en/coins/${item.id}`,
        timestamp: now - i,
      };
    });

    api.emit(items);
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};
id: codytseng/coingecko-crypto
version: 1.0.0
name: CoinGecko Crypto Markets
description: Top cryptocurrencies by market cap from CoinGecko
author: codytseng
author_url: https://github.com/codytseng
category: Finance
tags:
  - crypto
  - finance
  - markets

config:
  - key: CURRENCY
    name: Currency
    type: select
    required: false
    default: usd
    description: Display currency for prices
    options:
      - usd
      - eur
      - gbp
      - jpy
      - cny
  - key: ORDER
    name: Sort Order
    type: select
    required: false
    default: market_cap_desc
    description: How to sort the coin list
    options:
      - market_cap_desc
      - volume_desc
function currencySymbol(currency) {
  switch (currency) {
    case "usd":
      return "$";
    case "eur":
      return "\u20AC";
    case "gbp":
      return "\u00A3";
    case "jpy":
      return "\u00A5";
    case "cny":
      return "\u00A5";
    default:
      return "";
  }
}

module.exports = async (api) => {
  const currency = api.config.get("CURRENCY") || "usd";
  const order = api.config.get("ORDER") || "market_cap_desc";

  async function fetchData() {
    const url = `https://api.coingecko.com/api/v3/coins/markets?vs_currency=${currency}&order=${order}&per_page=250&sparkline=false`;

    const response = await api.fetch(url);

    if (!response.ok || !response.json) {
      throw new Error(`Failed to fetch CoinGecko market data (HTTP ${response.status})`);
    }

    const now = Date.now();
    const items = response.json.map((item, i) => {
      const change = item.price_change_percentage_24h;
      const changeStr =
        change != null
          ? ` ${change > 0 ? "+" : ""}${change.toFixed(2)}%`
          : "";

      return {
        id: item.id,
        title: `${item.name} (${item.symbol.toUpperCase()})`,
        subtitle: `${currencySymbol(currency)}${item.current_price.toLocaleString("en-US")}${changeStr}`,
        url: `https://www.coingecko.com/en/coins/${item.id}`,
        timestamp: now - i,
      };
    });

    api.emit(items);
  }

  await fetchData();

  return {
    refresh: fetchData,
  };
};

相关信息源