A Node.js wrapper for the CoinCodex API with no dependencies.
Latest version: 2.0.0
npm install coincodex-api-v2
For complete API documentation, up-to-date parameters, responses and errors, please refer to https://coincodex.com/page/api.
//1. Import coincodex-api
const CoinCodex = require('coincodex-api');
//2. Initiate the CoinCodex API Client
const CoinCodexClient = new CoinCodex();
//3. Make calls
var func = async() => {
let data = await CoinCodexClient.coins.fetch('btc');
};
All calls using the CoinCodexClient are asynchronous.
All calls are returned in the following format:
{
success: Boolean,
message: String,
code: Number,
data: Object
}
The CoinCodexClient splits up the currently available calls outline in the official CoinCodex API documentation into two parts. (Including firstPageHistory()
)
Namespace | Usage | Description |
---|---|---|
coins |
CoinCodexClient.coins[...] |
Calls related to coins |
Returns historic data for coins needed to draw the graph on the frontpage.
Check API server status.
Params:
params
:Object
- Parameters to pass through to the requestparams.days
:String|Number
- (Required) The number of days we need the history forparams.coins_limit
:String|Number
- (Required) The number of top coins (by market cap) must be returnedparams.samples
String|Number
[default:1
] - How many price values between the start_date and end_date to be included in the results.
Usage Example:
let data = await CoinCodexClient.firstPageHistory();
Calls related to coins.
Returns all coins on the platform with properties that are needed to display them on the frontpage.
Usage Example:
let data = await CoinCodexClient.coins.all();
Returns all properties for the coin needed to display the coin details page.
Params:
coinId
:String
- (Required) The unique internal id for the coin
Usage Example:
let data = await CoinCodexClient.coins.fetch('btc');
Returns historical price data for a single coin.
Params:
coinId
:String
- (Required) The unique internal id for the coinparams
:Object
- Parameters to pass through to the requestparams.start_date
:String
- (Required) The start date of the historical data snapshot in YYYY-MM-DD e.g.2018-01-01
params.end_date
:String
- (Required) The start date of the historical data snapshot in YYYY-MM-DD e.g.2018-01-31
params.samples
:String|Number
[default:1
] - How many price values between thestart_date
andend_date
to be included in the results. (e.g. ifstart_date
:2018-01-01
,end_date
:2018-01-31
,samples
:1
. Only1
value will be returned. Ifsamples
:30
,30
values will be returned)
Usage Example:
let data = await CoinCodexClient.coins.fetchHistory('btc', {
start_date: '2018-01-01',
end_date: '2018-01-31',
samples: 30,
});
Returns exchanges and markets for a coin.
Params:
coinId
:String
- (Required) The unique internal id for the coin
Usage Example:
let data = await CoinCodexClient.coins.markets('btc');
Returns min and max ranges of given coinId(s) for 1 hour, 1 day, 7 day, 30 day, 90 day, 180 day, year to date, last 365 days and all time.
Params:
coinIds
:String|Array
- (Required) A comma separated string or array of the unique internal id(s) for coin(s)
Usage Example:
//Single
let data = await CoinCodexClient.coins.ranges('btc');
//Multiple
let data = await CoinCodexClient.coins.ranges(['btc', 'eth']);
//Multiple alternative
let data = await CoinCodexClient.coins.ranges('btc,eth');
Find me on Gab: @markmiscavage.
Tweet at me: @markmiscavage.
MIT License
Copyright (c) 2019 Mark Miscavage
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.