@joemccann/robinhood-api
Advanced tools
Comparing version 1.3.1 to 1.4.0
{ | ||
"name": "@joemccann/robinhood-api", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "📈 Unofficial node.js package for the Robinhood.com API.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -81,7 +81,7 @@ const fetch = require('node-fetch') | ||
const popularity = async ({ token = '', symbol = '' }) => { | ||
const popularity = async ({ token = '', instrument = '' }) => { | ||
if (!token) throw new Error('Missing required parameter "token"') | ||
if (!symbol) throw new Error('Missing required parameter "symbol"') | ||
if (!instrument) throw new Error('Missing required parameter "instrument"') | ||
const URL = `https://api.robinhood.com/instruments/${symbol}/popularity` | ||
const URL = `https://api.robinhood.com/instruments/${instrument}/popularity` | ||
@@ -112,7 +112,6 @@ let resp = null | ||
data = await resp.text() | ||
data = await resp.json() | ||
} catch (e) { | ||
if (resp.status === 404) return { statusCode: 404 } | ||
console.error(e.message) | ||
throw e | ||
console.error(e) | ||
return { data: e.message, statusCode: resp.status } | ||
} | ||
@@ -119,0 +118,0 @@ return { data, statusCode: resp.status } |
@@ -58,2 +58,21 @@ require('dotenv').config() | ||
test('PASS: popularity', async t => { | ||
const params = { | ||
token, | ||
instrument: instrumentUUID | ||
} | ||
try { | ||
const { data, statusCode } = await popularity(params) | ||
t.ok(data) | ||
const { instrument = '', num_open_positions: num = 0 } = data | ||
t.same(instrument, 'https://api.robinhood.com/instruments/450dfc6d-5510-4d40-abfb-f633b7d9be3e/') | ||
t.true(num > 0) | ||
t.equals(statusCode, 200) | ||
} catch (e) { | ||
console.error(e) | ||
} | ||
t.end() | ||
}) | ||
/* | ||
test('FAIL: quote', async t => { | ||
@@ -60,0 +79,0 @@ const sym = 'CTST' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
574738
566