coinglecko/search
Search and trending endpoints.
Types
A coin result from the search endpoint.
pub type SearchCoin {
SearchCoin(
id: String,
name: String,
symbol: String,
market_cap_rank: option.Option(Int),
thumb: String,
)
}
Constructors
-
SearchCoin( id: String, name: String, symbol: String, market_cap_rank: option.Option(Int), thumb: String, )
An exchange result from the search endpoint.
pub type SearchExchange {
SearchExchange(id: String, name: String, thumb: String)
}
Constructors
-
SearchExchange(id: String, name: String, thumb: String)
Combined search results.
pub type SearchResult {
SearchResult(
coins: List(SearchCoin),
exchanges: List(SearchExchange),
)
}
Constructors
-
SearchResult( coins: List(SearchCoin), exchanges: List(SearchExchange), )
A trending coin item.
pub type TrendingCoinItem {
TrendingCoinItem(
id: String,
name: String,
symbol: String,
market_cap_rank: option.Option(Int),
thumb: String,
score: Int,
)
}
Constructors
-
TrendingCoinItem( id: String, name: String, symbol: String, market_cap_rank: option.Option(Int), thumb: String, score: Int, )
Trending coins response.
pub type TrendingResponse {
TrendingResponse(coins: List(TrendingCoinItem))
}
Constructors
-
TrendingResponse(coins: List(TrendingCoinItem))
Values
pub fn decode_search_result(
json_string: String,
) -> Result(SearchResult, error.CoinGeckoError)
Decode a search result from a JSON string.
pub fn decode_trending(
json_string: String,
) -> Result(TrendingResponse, error.CoinGeckoError)
Decode a trending response from a JSON string.
pub fn query(
client: client.Client,
query query_text: String,
send sender: fn(request.Request(String)) -> Result(
response.Response(String),
String,
),
) -> Result(SearchResult, error.CoinGeckoError)
Search for coins, categories, and exchanges.
Example
let assert Ok(results) = search.query(client, query: "bitcoin", send: sender)
pub fn query_request(
client: client.Client,
query query_text: String,
) -> Result(request.Request(String), error.CoinGeckoError)
Build a request to search for coins, categories, and exchanges.
pub fn trending(
client: client.Client,
send sender: fn(request.Request(String)) -> Result(
response.Response(String),
String,
),
) -> Result(TrendingResponse, error.CoinGeckoError)
Get trending coins.
Example
let assert Ok(trending) = search.trending(client, send: sender)
pub fn trending_request(
client: client.Client,
) -> Result(request.Request(String), error.CoinGeckoError)
Build a request to get trending coins.