Skip to content

Latest commit

 

History

History
60 lines (40 loc) · 1.68 KB

README.md

File metadata and controls

60 lines (40 loc) · 1.68 KB

dodo-open

go-coinmarketcap

license

特性

  • coinmarketcap OpenAPI
  • 看github现有的sdk太久没更新,自己封装了一套(2024/03/07)
  • 只封装了自己用到的api

起步

go get -u github.com/cpj555/go-coinmarketcap
apiKey := "your-api-key"

// 下面的第三个参数,设定了 resty 的请求超时为 3 秒:
//
//     client.WithTimeout(time.Second*3)
//
client, err := NewClient(client.WithApiKey(apiKey), client.WithTimeout(time.Second*3),
	client.WithRequestPerMinute(60),//限流器cmc接口配合购买的cmc等级使用,配置自己的业务并发调用
client.WithProxyUrl("http://localhost:1080") //本地调试得开代理设置下代理请求,生产环境部署到香港或者国外服务器
	)

// 获取map列表,可以使用下面的方法
list, err := client.CryptocurrencyV1.GetMap(context.Background(),&types.GetCryptocurrencyV1MapReq{Start: 1, Limit: 10})

API documentation

https://coinmarketcap.com/api/documentation

  • examples

  • 调试了下 币种相关的接口入参为slug时,返回的map还是id为键

  • /v1/cryptocurrency/map (Get the current price of any cryptocurrencies in any other supported currencies that you need)
    client.CryptocurrencyV1.GetMap(context.Background(),&types.GetCryptocurrencyMapReq{Start: 1, Limit: 10})