New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

robinhood-typescript

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

robinhood-typescript - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

lib/models/positions.d.ts

2

lib/index.d.ts
import { AccountsLoaded } from './models/account';
import { FundamentalsLoaded } from './models/fundamentals';
import { Userloaded } from './models/user';
import { PositionsLoaded } from './models/positions';
declare class RobinhoodAPI {

@@ -13,3 +14,4 @@ private _authToken;

fundamentals(ticker: string): Promise<FundamentalsLoaded>;
positions(): Promise<PositionsLoaded>;
}
export default RobinhoodAPI;

@@ -80,3 +80,15 @@ "use strict";

}
async positions() {
const config = {
headers: { Authorization: `Bearer ${this._authToken}` },
};
try {
const response = await axios_1.default.get(`${defaults_1.apiUrl}${defaults_1.endpoints.positions}`, config);
return response.data;
}
catch (error) {
return error;
}
}
}
exports.default = RobinhoodAPI;

2

package.json
{
"name": "robinhood-typescript",
"version": "1.3.0",
"version": "1.4.0",
"description": "NodeJS Framework to make trades with the private Robinhood API. Using this API is not encouraged, since it's not officially available and it has been reverse engineered. See @Sanko's Unofficial Documentation for more information.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -211,1 +211,31 @@ import RobinhoodAPI from '../index';

});
describe('Positions', () => {
test('successful retrieve positions infromation', async () => {
const api = new RobinhoodAPI('token');
const data = {
url: 'https://api.robinhood.com/positions/598754190/edf89445-db53-4f97-9de9-a599a293c63f/',
instrument: 'https://api.robinhood.com/instruments/edf89445-db53-4f97-9de9-a599a293c63f/',
account: 'https://api.robinhood.com/accounts/598754190/',
account_number: '598754190',
average_buy_price: '0.0000',
};
mockedAxios.get.mockResolvedValue({ data });
const positionsInfo = await api.positions();
expect(positionsInfo).toEqual(data);
});
test('failure retrieve positions infromation', async () => {
const api = new RobinhoodAPI('token');
const errorMessage = 'this a bad token';
mockedAxios.get.mockRejectedValue({ errorMessage });
const positionsInfo = await api.positions();
expect(positionsInfo).toEqual({ errorMessage });
});
});
import { apiUrl, endpoints } from './models/defaults';
import { AccountsLoaded } from './models/account';
import { FundamentalsLoaded } from './models/fundamentals';
import { Userloaded } from './models/user';
import { PositionsLoaded } from './models/positions';
// Dependencies
import axios, { AxiosResponse } from 'axios';
import { FundamentalsLoaded } from './models/fundamentals';
import { Userloaded } from './models/user';

@@ -94,4 +95,17 @@ class RobinhoodAPI {

}
async positions(): Promise<PositionsLoaded> {
const config = {
headers: { Authorization: `Bearer ${this._authToken}` },
};
try {
const response: AxiosResponse<PositionsLoaded> = await axios.get(`${apiUrl}${endpoints.positions}`, config);
return response.data;
} catch (error) {
return error;
}
}
}
export default RobinhoodAPI;

Sorry, the diff of this file is too big to display

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