Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

intrinio-client

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intrinio-client - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

examples/prices.js

138

index.js
var rest = require('restler');
var Promise = require("bluebird");
const EventEmitter = require('events');
const util = require('util');
function ResultEmitter() {
EventEmitter.call(this);
}
util.inherits(ResultEmitter, EventEmitter);
module.exports = function (username, password) {

@@ -10,36 +19,97 @@ 'use strict';

}, {
ticker: function(ticker) {
//
return this.get('https://www.intrinio.com/api/companies?ticker='+ticker);
},
prices: function(ticker) {
//
return this.get('https://www.intrinio.com/api/prices?ticker='+ticker);
},
historical_data: function(ticker) {
return this.get('https://www.intrinio.com/api/historical_data?ticker='+ticker);
},
companies: function(ticker) {
//
return this.get('https://www.intrinio.com/api/companies?ticker='+ticker);
},
securities: function(ticker) {
//
return this.get('https://www.intrinio.com/api/securities?ticker='+ticker);
},
indices: function(ticker) {
// Is returning an empty object.
return this.get('https://www.intrinio.com/api/indices?ticker='+ticker);
},
data_point: function(ticker, item) {
//
return this.get('https://www.intrinio.com/api/data_point?ticker='+ticker+"&item="+item);
},
historical_data: function(ticker, item) {
return this.get('https://www.intrinio.com/api/historical_data?ticker='+ticker+"&item="+item);
},
news: function(ticker) {
//
return this.get('https://www.intrinio.com/api/news?ticker='+ticker);
}
watch: {
prices: function(ticker, frequency, numRequests, callback){
var reqCounter = 0;
var numberOfRequests = numRequests ? numRequests : 1
var url = 'https://www.intrinio.com/api/prices?ticker='+ticker
if(callback){
const resEmitter = new ResultEmitter();
callback(resEmitter)
function getUpdate(){
var watcher = setTimeout(function(){
console.log("Watching ticker"+ ticker + " " +frequency+" "+reqCounter)
rest.get(url, {username:username, password:password})
.on('complete', function(data, response) {
if(response.statusCode==200){
resEmitter.emit('update', data, response);
}else{
resEmitter.emit('error', data, response);
}
})
if(reqCounter<numberOfRequests-1){
getUpdate();
reqCounter++
}
}, frequency)
}
getUpdate();
}else{
return new Promise(function(resolve, reject) {
//The object to be returned in the promise.
const resEmitter = new ResultEmitter();
rest.get(url, {username:username, password:password})
.on('complete', function(data, response) {
if(response.statusCode==200){
resolve(resEmitter)
resEmitter.emit('update', data, response);
}else{
resolve(resEmitter)
resEmitter.emit('error', data, response);
}
})
reqCounter++
function getUpdate(){
var watcher = setTimeout(function(){
console.log("Watching ticker"+ ticker + " " +frequency+" "+reqCounter)
rest.get(url, {username:username, password:password})
.on('complete', function(data, response) {
if(response.statusCode==200){
resEmitter.emit('update', data, response);
}else{
resEmitter.emit('error', data, response);
}
})
if(reqCounter<numberOfRequests){
getUpdate();
reqCounter++
}
}, frequency)
}
getUpdate();
})
}
}
},
ticker: function(ticker) {
return this.get('https://www.intrinio.com/api/companies?ticker='+ticker);
},
prices: function(ticker) {
return this.get('https://www.intrinio.com/api/prices?ticker='+ticker);
},
historical_data: function(ticker) {
return this.get('https://www.intrinio.com/api/historical_data?ticker='+ticker);
},
companies: function(ticker) {
return this.get('https://www.intrinio.com/api/companies?ticker='+ticker);
},
securities: function(ticker) {
return this.get('https://www.intrinio.com/api/securities?ticker='+ticker);
},
indices: function(ticker) {
// Is returning an empty object.
return this.get('https://www.intrinio.com/api/indices?ticker='+ticker);
},
data_point: function(ticker, item) {
return this.get('https://www.intrinio.com/api/data_point?ticker='+ticker+"&item="+item);
},
historical_data: function(ticker, item) {
return this.get('https://www.intrinio.com/api/historical_data?ticker='+ticker+"&item="+item);
},
news: function(ticker) {
return this.get('https://www.intrinio.com/api/news?ticker='+ticker);
}
});

@@ -46,0 +116,0 @@ if(!username || !password){

{
"name": "intrinio-client",
"version": "0.0.3",
"version": "0.0.4",
"description": "NodeJS client for the Intrinio API",

@@ -30,4 +30,5 @@ "main": "index.js",

"dependencies": {
"bluebird": "^3.1.1",
"restler": "^3.4.0"
}
}

@@ -44,2 +44,32 @@ [![Intrinio Logo](https://s3.amazonaws.com/intrinio-production/images/Intrinio+Logo/IntrinioLogo-Green-optimized.png)](http://www.intrinio.com)

```
Using "watch"
```js
var username = "" //Your Username
var password = "" //Your Password
var intrinio = require("../index.js")(username, password)
var updateFrequency = 5000 //Duration between each request
var numberOfRequests = 5 //Send this number of requests
//Traditional Callback Style
intrinio
.watch
.prices('AAPL', updateFrequency, numberOfRequests, function(watcher){
watcher
.on('update', function(data, response){
//Gets fired 5 times each one 5 seconds after the previous update.
console.log(data) //data is the response from the Intrinio API
console.log(response) //response is the http response
})
.on('error', function(data, response){
console.log(data) //data is the response from the Intrinio API
console.log(response) //response is the http response
})
})
//Be careful, 'watch' will easily use up your daily quota if a large number of requests are sent.
```
* [API Endpoints](http://community.intrinio.com/docs/api/)

@@ -46,0 +76,0 @@

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