Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jprichardson committed Aug 1, 2016
0 parents commit a4620a4
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js
node_js:
- 'stable'
- '0.12'
- '0.10'
sudo: false
cache:
directories:
- node_modules
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# cryptocompare change log

All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
* engage
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# [MIT License](https://spdx.org/licenses/MIT)

Copyright (c) 2016 JP Richardson <[email protected]>

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.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cryptocompare
=============

[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]

[npm-image]: https://img.shields.io/npm/v/cryptocompare.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/cryptocompare
[travis-image]: https://img.shields.io/travis/jprichardson/cryptocompare.svg?style=flat-square
[travis-url]: https://travis-ci.org/jprichardson/cryptocompare
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard

CryptoCompare JavaScript API

Install
-------

npm install cryptocompare


Usage
-----

### Methods

#### coinList

Reference: https://www.cryptocompare.com/api/#-api-data-coinlist-

| ---: | :--- |
| Signature | `coinList()` |
| Parameters | (none) |
| Returns | A Promise function. |

```js
var cryptocompare = require('cryptocompare')
```


## License

[MIT](LICENSE.md)
22 changes: 22 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* global fetch */

var baseUrl = 'https://www.cryptocompare.com/api/data/'

function fetchJSON (url) {
return fetch(url)
.then(res => res.json())
.then(body => {
// 'response' is a CryptoCompare field
if (body.Response !== 'Success') throw new Error(body.Message)
return body.Data
})
}

function coinList () {
var url = baseUrl + 'coinlist/'
return fetchJSON(url)
}

module.exports = {
coinList
}
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "cryptocompare",
"description": "CryptoCompare JavaScript API",
"version": "0.0.0",
"author": "JP Richardson <[email protected]>",
"bugs": {
"url": "https://github.com/exodusmovement/cryptocompare/issues"
},
"devDependencies": {
"node-fetch": "^1.5.3",
"standard": "*",
"tap-spec": "^4.0.2",
"tape": "^4.0.0"
},
"homepage": "https://github.com/exodusmovement/cryptocompare",
"keywords": [
"api",
"bitcoin",
"cryptocurrency",
"ethereum",
"price"
],
"license": "MIT",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/exodusmovement/cryptocompare.git"
},
"scripts": {
"test": "standard && tape test/*.js | tap-spec"
}
}
12 changes: 12 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var test = require('tape')

// set to global
global.fetch = require('node-fetch')
var cc = require('../')

test('coinList()', function (t) {
t.plan(1)
cc.coinList().then(coinList => {
t.strictEqual(coinList.BTC.CoinName, 'Bitcoin')
}).catch(t.end)
})

0 comments on commit a4620a4

Please sign in to comment.