coinmarketcap_api v2.0.1 CoinmarketcapApi

Link to this section Summary

Functions

Perform a DELETE request

Perform a DELETE request

Returns the global data found at the top of coinmarketcap.com

Returns all active cryptocurrency listings. Use fetch_ticker to query more information for a specific cryptocurrency

Returns cryptocurrency ticker data ordered by marketcap rank. The maximum number of results per call is 100. Pagination is possible by using the start and limit parameters

Returns ticker data for a specific cryptocurrency. Use the “id” field from the Listings endpoint in the URL. Example response

Perform a GET request

Perform a GET request

Perform a HEAD request

Perform a HEAD request

Perform a OPTIONS request

Perform a OPTIONS request

Perform a PATCH request

Perform a PATCH request

Perform a POST request

Perform a POST request

Perform a PUT request

Perform a PUT request

Perform request and raise in case of error

Perform a TRACE request

Perform a TRACE request

Link to this section Types

Link to this type option()
option() ::
  {:method, Tesla.Env.method()}
  | {:url, Tesla.Env.url()}
  | {:query, Tesla.Env.query()}
  | {:headers, Tesla.Env.headers()}
  | {:body, Tesla.Env.body()}
  | {:opts, Tesla.Env.opts()}

Link to this section Functions

Link to this function delete(client, url, opts)

Perform a DELETE request.

See request/1 or request/2 for options definition.

delete("/users")
delete("/users", query: [scope: "admin"])
delete(client, "/users")
delete(client, "/users", query: [scope: "admin"])
Link to this function delete!(client, url, opts)

Perform a DELETE request.

See request!/1 or request!/2 for options definition.

delete!("/users")
delete!("/users", query: [scope: "admin"])
delete!(client, "/users")
delete!(client, "/users", query: [scope: "admin"])
Link to this function fetch_global_data()
Link to this function fetch_global_data(map)

Returns the global data found at the top of coinmarketcap.com

Example response:

{
  "data": {
      "active_cryptocurrencies": 1594,
      "active_markets": 10526,
      "bitcoin_percentage_of_market_cap": 37.65,
      "quotes": {
          "USD": {
              "total_market_cap": 407690157494.0,
              "total_volume_24h": 30969801118.0
          }
      },
      "last_updated": 1525137271
  },
  "metadata": {
      "timestamp": 1525237332,
      "error": null
  }
}
Link to this function fetch_listings()

Returns all active cryptocurrency listings. Use fetch_ticker to query more information for a specific cryptocurrency.

Example response:

{
  "data": [
      {
          "id": 1,
          "name": "Bitcoin",
          "symbol": "BTC",
          "website_slug": "bitcoin"
      },
      {
          "id": 2,
          "name": "Litecoin",
          "symbol": "LTC",
          "website_slug": "litecoin"
      },
      ...
  },
  "metadata": {
      "timestamp": 1525137187,
      "num_cryptocurrencies": 1602,
      "error": null
  }
]

Returns cryptocurrency ticker data ordered by marketcap rank. The maximum number of results per call is 100. Pagination is possible by using the start and limit parameters.

Example response:

{
  "data": {
      "1": {
          "id": 1,
          "name": "Bitcoin",
          "symbol": "BTC",
          "website_slug": "bitcoin",
          "rank": 1,
          "circulating_supply": 17008162.0,
          "total_supply": 17008162.0,
          "max_supply": 21000000.0,
          "quotes": {
              "USD": {
                  "price": 9024.09,
                  "volume_24h": 8765400000.0,
                  "market_cap": 153483184623.0,
                  "percent_change_1h": -2.31,
                  "percent_change_24h": -4.18,
                  "percent_change_7d": -0.47
              }
          },
          "last_updated": 1525137271
      },
      "1027": {
          "id": 1027,
          "name": "Ethereum",
          "symbol": "ETH",
          "website_slug": "ethereum",
          "rank": 2,
          "circulating_supply": 99151888.0,
          "total_supply": 99151888.0,
          "max_supply": null,
          "quotes": {
              "USD": {
                  "price": 642.399,
                  "volume_24h": 2871290000.0,
                  "market_cap": 63695073558.0,
                  "percent_change_1h": -3.75,
                  "percent_change_24h": -7.01,
                  "percent_change_7d": -2.32
              }
          },
          "last_updated": 1525137260
      }
      ...
  },
  "metadata": {
      "timestamp": 1525137187,
      "num_cryptocurrencies": 1602,
      "error": null
  }
]
Link to this function fetch_ticker(query)
Link to this function fetch_ticker(id, query \\ [])

Returns ticker data for a specific cryptocurrency. Use the “id” field from the Listings endpoint in the URL. Example response:

{
  "data": {
      "id": 1,
      "name": "Bitcoin",
      "symbol": "BTC",
      "website_slug": "bitcoin",
      "rank": 1,
      "circulating_supply": 17008162.0,
      "total_supply": 17008162.0,
      "max_supply": 21000000.0,
      "quotes": {
          "USD": {
              "price": 9024.09,
              "volume_24h": 8765400000.0,
              "market_cap": 153483184623.0,
              "percent_change_1h": -2.31,
              "percent_change_24h": -4.18,
              "percent_change_7d": -0.47
          }
      },
      "last_updated": 1525137271
  },
  "metadata": {
      "timestamp": 1525237332,
      "error": null
  }

}

Perform a GET request.

See request/1 or request/2 for options definition.

get("/users")
get("/users", query: [scope: "admin"])
get(client, "/users")
get(client, "/users", query: [scope: "admin"])
Link to this function get!(client, url, opts)

Perform a GET request.

See request!/1 or request!/2 for options definition.

get!("/users")
get!("/users", query: [scope: "admin"])
get!(client, "/users")
get!(client, "/users", query: [scope: "admin"])

Perform a HEAD request.

See request/1 or request/2 for options definition.

head("/users")
head("/users", query: [scope: "admin"])
head(client, "/users")
head(client, "/users", query: [scope: "admin"])
Link to this function head!(client, url, opts)

Perform a HEAD request.

See request!/1 or request!/2 for options definition.

head!("/users")
head!("/users", query: [scope: "admin"])
head!(client, "/users")
head!(client, "/users", query: [scope: "admin"])
Link to this function options(client, url, opts)

Perform a OPTIONS request.

See request/1 or request/2 for options definition.

options("/users")
options("/users", query: [scope: "admin"])
options(client, "/users")
options(client, "/users", query: [scope: "admin"])
Link to this function options!(client, url, opts)

Perform a OPTIONS request.

See request!/1 or request!/2 for options definition.

options!("/users")
options!("/users", query: [scope: "admin"])
options!(client, "/users")
options!(client, "/users", query: [scope: "admin"])
Link to this function patch(client, url, body, opts)

Perform a PATCH request.

See request/1 or request/2 for options definition.

patch("/users", %{name: "Jon"})
patch("/users", %{name: "Jon"}, query: [scope: "admin"])
patch(client, "/users", %{name: "Jon"})
patch(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function patch!(client, url, body, opts)

Perform a PATCH request.

See request!/1 or request!/2 for options definition.

patch!("/users", %{name: "Jon"})
patch!("/users", %{name: "Jon"}, query: [scope: "admin"])
patch!(client, "/users", %{name: "Jon"})
patch!(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function post(client, url, body, opts)

Perform a POST request.

See request/1 or request/2 for options definition.

post("/users", %{name: "Jon"})
post("/users", %{name: "Jon"}, query: [scope: "admin"])
post(client, "/users", %{name: "Jon"})
post(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function post!(client, url, body, opts)

Perform a POST request.

See request!/1 or request!/2 for options definition.

post!("/users", %{name: "Jon"})
post!("/users", %{name: "Jon"}, query: [scope: "admin"])
post!(client, "/users", %{name: "Jon"})
post!(client, "/users", %{name: "Jon"}, query: [scope: "admin"])

Perform a PUT request.

See request/1 or request/2 for options definition.

put("/users", %{name: "Jon"})
put("/users", %{name: "Jon"}, query: [scope: "admin"])
put(client, "/users", %{name: "Jon"})
put(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function put!(client, url, body, opts)

Perform a PUT request.

See request!/1 or request!/2 for options definition.

put!("/users", %{name: "Jon"})
put!("/users", %{name: "Jon"}, query: [scope: "admin"])
put!(client, "/users", %{name: "Jon"})
put!(client, "/users", %{name: "Jon"}, query: [scope: "admin"])
Link to this function request(client \\ %Tesla.Client{}, options)

Perform a request

Options:

  • :method - the request method, one of [:head, :get, :delete, :trace, :options, :post, :put, :patch]
  • :url - either full url e.g. “http://example.com/some/path” or just “/some/path” if using Tesla.Middleware.BaseUrl
  • :query - a keyword list of query params, e.g. [page: 1, per_page: 100]
  • :headers - a keyworld list of headers, e.g. [{"content-type", "text/plain"}]
  • :body - depends on used middleware:

    • by default it can be a binary
    • if using e.g. JSON encoding middleware it can be a nested map
    • if adapter supports it it can be a Stream with any of the above
  • :opts - custom, per-request middleware or adapter options

Examples:

ExampleApi.request(method: :get, url: "/users/path")

You can also use shortcut methods like:

ExampleApi.get("/users/1")

or

ExampleApi.post(client, "/users", %{name: "Jon"})
Link to this function request!(client \\ %Tesla.Client{}, options)
request!(Tesla.Env.client(), [option()]) :: Tesla.Env.t() | no_return()

Perform request and raise in case of error.

This is similar to request/2 behaviour from Tesla 0.x

See request/2 for list of available options.

Link to this function trace(client, url, opts)

Perform a TRACE request.

See request/1 or request/2 for options definition.

trace("/users")
trace("/users", query: [scope: "admin"])
trace(client, "/users")
trace(client, "/users", query: [scope: "admin"])
Link to this function trace!(client, url, opts)

Perform a TRACE request.

See request!/1 or request!/2 for options definition.

trace!("/users")
trace!("/users", query: [scope: "admin"])
trace!(client, "/users")
trace!(client, "/users", query: [scope: "admin"])