You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Coinbase API获取以太坊价格数据?仅找到比特币相关方法

Fetching Ethereum Price Data via Coinbase API

Hey there! Great question—you absolutely can pull Ethereum (ETH) price data using the Coinbase API, even if the initial examples you found focused on Bitcoin. The core endpoints work the same way; you just need to adjust the currency pair parameter.

Using the Spot Price Endpoint

The simplest way to get the current ETH spot price is with the public /v2/prices/{currency_pair}/spot endpoint. No API keys are required for this public data.

Example with curl:

curl https://api.coinbase.com/v2/prices/ETH-USD/spot

Example with Python (using requests):

import requests

response = requests.get("https://api.coinbase.com/v2/prices/ETH-USD/spot")
if response.status_code == 200:
    eth_price = response.json()["data"]["amount"]
    print(f"Current ETH-USD price: ${eth_price}")
else:
    print(f"Error fetching data: {response.status_code}")

You can swap out USD for other fiat currencies too (like EUR, GBP, etc.) by changing the currency pair to ETH-EUR, ETH-GBP, etc.

Fetching Historical Price Data

If you need historical ETH prices, use the /v2/prices/{currency_pair}/historic endpoint. You can add query parameters to specify a date range:

Example curl for a 7-day date range:

curl "https://api.coinbase.com/v2/prices/ETH-USD/historic?start=2024-05-01T00:00:00Z&end=2024-05-07T23:59:59Z"

The response will include a list of timestamped price points you can parse for trends or analysis.

Quick Note

The Coinbase API docs do cover this, but sometimes examples are Bitcoin-focused. Just remember that any endpoint using a currency_pair parameter works with Ethereum (and most other supported assets) by replacing BTC with ETH in the pair string.

内容的提问来源于stack exchange,提问作者Siddharth Saxena

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:29:51