Socket
Socket
Sign inDemoInstall

cryptocompare

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cryptocompare - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

6

CHANGELOG.md

@@ -0,1 +1,7 @@

0.7.0 / 2018-11-26
------------------
- added: API key support via `setApiKey()` ([#32](https://github.com/exodusmovement/cryptocompare/pull/32))
- added: `newsList()` & `newsFeedsAndCategories()` methods ([#32](https://github.com/exodusmovement/cryptocompare/pull/32))
0.6.0 / 2018-11-06

@@ -2,0 +8,0 @@ ------------------

@@ -5,4 +5,17 @@ 'use strict'

const baseUrl = 'https://min-api.cryptocompare.com/data/'
let apiKey = ''
function setApiKey (userApiKey) {
apiKey = userApiKey
}
function fetchJSON (url) {
if (apiKey !== '') {
if (url.indexOf('?') > -1) {
url += '&api_key='
} else {
url += '?api_key='
}
url += apiKey
}
return fetch(url)

@@ -31,2 +44,19 @@ .then(res => {

function newsFeedsAndCategories () {
const url = `${baseUrl}data/news/feedsandcategories`
return fetchJSON(url).then(result => result.Data)
}
function newsList (lang, options) {
let url = `${baseUrl}data/v2/news/?lang=${lang}`
if (options.feeds) url += `&feeds=${options.feeds}`
if (options.categories) url += `&categories=${options.categories}`
if (options.excludeCategories) url += `&categories=${options.excludeCategories}`
if (options.lTs) {
options.lTs = dateToTimestamp(options.lTs)
url += `&lTs=${options.lTs}`
}
return fetchJSON(url).then(result => result.Data)
}
function price (fsym, tsyms, options) {

@@ -141,4 +171,7 @@ options = options || {}

module.exports = {
setApiKey,
coinList,
exchangeList,
newsFeedsAndCategories,
newsList,
price,

@@ -145,0 +178,0 @@ priceMulti,

2

package.json
{
"name": "cryptocompare",
"description": "CryptoCompare JavaScript API",
"version": "0.6.0",
"version": "0.7.0",
"author": "JP Richardson <jprichardson@gmail.com>",

@@ -6,0 +6,0 @@ "bugs": {

@@ -30,2 +30,3 @@ cryptocompare

- If you are using this in Node.js, you will need to use [`node-fetch`](https://www.npmjs.com/package/node-fetch).
- The package works without an API key but the IP limits will slowly be reduced over time, to create an API key just go to https://www.cryptocompare.com/cryptopian/api-keys and make sure you give it the "Read All Price Streaming and Polling Endpoints" permission

@@ -36,2 +37,3 @@ **Example:**

const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')
```

@@ -71,2 +73,3 @@

const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')

@@ -113,2 +116,3 @@ // Usage:

const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')

@@ -148,2 +152,3 @@ // Usage:

const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')

@@ -181,2 +186,3 @@ // Basic Usage:

const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')

@@ -215,2 +221,3 @@ // Basic Usage:

const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')

@@ -267,2 +274,3 @@ cc.priceFull(['BTC', 'ETH'], ['USD', 'EUR'])

const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')

@@ -291,2 +299,3 @@ // Basic Usage:

const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')

@@ -329,2 +338,3 @@ // Basic Usage:

const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')

@@ -360,2 +370,3 @@ cc.topPairs('BTC', 2)

const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')

@@ -489,4 +500,93 @@ cc.topExchanges('BTC', 'USD', 2)

### `newsList()`
Returns news articles from the providers that CryptoCompare has integrated with.
`newsList(lang[, options])`
- `lang` (String) Preferred language - English (EN) or Portuguese (PT)
- `options` (Object)
- `feeds` (Array of Strings | Array) Specific news feeds to retrieve news from, if empty, defaults to all of them. (You can get a list of news feeds with `newsFeedsAndCategories().Feeds`..)
- `categories` (Array of Strings | Array) Category of news articles to return, if empty, defaults to all of them. (You can get a list of news categories with `newsFeedsAndCategories().Categories`..)
- `excludeCategories` (Array of Strings | Array) News article categories to exclude from results, if empty, defaults to none. (You can get a list of news categories with `newsFeedsAndCategories().Categories`..)
- `lTs` (Date) Returns news before that timestamp
```js
const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')
// Basic Usage:
cc.newsList('EN')
.then(newsList => {
console.log(newsList)
//[
// {
// id: "708235"
// guid: "https://www.cryptoglobe.com/latest/2018/11/china-cryptocurrency-mining-machines-are-reportedly-being-sold-according-to-their-weight/"
// published_on: 1542886256
// imageurl: "https://images.cryptocompare.com/news/cryptoglobe/fwMg0080000.jpeg"
// title: "China: Cryptocurrency Mining Machines Reportedly Being Sold According to Their Weight"
// url: "https://www.cryptoglobe.com/latest/2018/11/china-cryptocurrency-mining-machines-are-reportedly-being-sold-according-to-their-weight/"
// source: "cryptoglobe"
// body: "Cryptocurrency mining machines are reportedly being sold in China according to their weight as miners who haven’t been able to make a profit are seemingly getting rid of their old models to get some of their investment back."
// tags: ""
// categories: "Mining|Asia|Business"
// upvotes: "0"
// downvotes: "0"
// lang: "EN"
// source_info: {
// name: "CryptoGlobe"
// lang: "EN"
// img: "https://images.cryptocompare.com/news/default/cryptoglobe.png"
// }
// }
// ....
//]
})
.catch(console.error)
```
### `newsFeedsAndCategories()`
Returns all the news feeds (providers) that CryptoCompare has integrated with and the full list of categories.
`newsFeedsAndCategories()`
- `No parameters`
- `Returns` (Object)
```js
const cc = require('cryptocompare')
cc.setApiKey('<your-api-key>')
// Usage:
cc.exchangeList()
.then(newsFeedsAndCategories => {
console.log(newsFeedsAndCategories)
// {
// "Categories":
// [
// {
// categoryName: "BTC"
// wordsAssociatedWithCategory: ["BTC","BITCOIN", "SATOSHI"]
// }
// ...
// ]
// "Feeds":
// [
// {
// key: "cryptocompare"
// name: "CryptoCompare"
// lang: "EN"
// img: "https://images.cryptocompare.com/news/default/cryptocompare.png"
// }
// ...
// ]
// }
})
.catch(console.error)
```
## License
[MIT](LICENSE.md)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc