GithubHelp home page GithubHelp logo

janlukasschroeder / tipranks-api-v2 Goto Github PK

View Code? Open in Web Editor NEW
73.0 6.0 27.0 12 KB

tipranks.com API to access price targets, news sentiments and trending stocks.

JavaScript 100.00%
api tipranks news-sentiment price-targets stock-market stock-prediction stock-prices news-sentiment-analyser trending finance-api

tipranks-api-v2's Introduction

Tipranks.com API

For any company (e.g. Tesla) the API returns

  • price targets calculated from analyst estimates: mean, median, highest, lowest, number of estimates
  • news sentiment data (bullish vs bearish) based on published articles in the last week

It also returns trending stocks.

Examples

Tesla Price Targets

{
  "symbol": "TSLA",
  "priceTargets": {
    "mean": 297.3333333333333,
    "median": 300,
    "highest": 500,
    "lowest": 54,
    "numberOfEstimates": 21
  }
}

Tesla News Sentiment

{
  "symbol": "TSLA",
  "sentiment": {
    "bullishPercent": 0.4062,
    "bearishPercent": 0.5938
  },
  "buzz": {
    "articlesInLastWeek": 143,
    "weeklyAverage": 147.25,
    "buzz": 0.9711
  },
  "sectorAverageBullishPercent": 0.6204,
  "sectorAverageNewsScore": 0.52,
  "companyNewsScore": 0.3969
}

Trending Stocks

[
  {
    "ticker": "HAL",
    "popularity": 10,
    "sentiment": 10,
    "consensusScore": 1,
    "operations": null,
    "sector": "BASIC MATERIALS",
    "sectorID": 17343,
    "marketCap": 18394572000,
    "buy": 10,
    "sell": 0,
    "hold": 0,
    "priceTarget": 32.42,
    "rating": 5,
    "companyName": "Halliburton",
    "quarterlyTrend": 5,
    "lastRatingDate": "2019-07-24T00:00:00"
  },
  {
    "ticker": "XLNX",
    "popularity": 9,
    "sentiment": 6,
    "consensusScore": 1.6666666666666667,
    "operations": null,
    "sector": "CONSUMER GOODS",
    "sectorID": 18731,
    "marketCap": 27832018900,
    "buy": 6,
    "sell": 0,
    "hold": 3,
    "priceTarget": 131.6,
    "rating": 4,
    "companyName": "Xilinx Inc",
    "quarterlyTrend": 4,
    "lastRatingDate": "2019-07-26T00:00:00"
  }
]

Setup

  • Install Node.js (which includes npm) if you haven't already. On Mac in the command line type brew install node. More information here: nodejs.org
  • Set up a new Node.js project. In the command line type
    • mkdir my-new-project && cd my-new-project to create a new folder
    • npm init to scaffold the Node.js project
    • touch index.js to create the file index.js
    • npm install tipranks-api-v2 to install the library to access the API
    • Copy/paste the example code below inside the index.js file
const tipranksApi = require('tipranks-api-v2');
tipranksApi.getPriceTargets('MU').then(result => console.log(result));
tipranksApi.getNewsSentimentData('MU').then(result => console.log(result));
tipranksApi.getTrendingStocks().then(trending => console.log(trending));
  • node index.js to run the code inside the index.js file
  • Done! Now you should see the price targets and the news sentiment for the ticker MU

Documentation

The API supports the following commands:

  • .getPriceTargets(ticker)
    • ticker is a string representing the company ticker, e.g. TSLA.
    • This method returns the mean price target, median target, highest target, lowest target, and the number of analyst estimates. See below for an example.

Note: The price calculator (e.g. mean price) only considers analyst price estimates given in the last 3 months. The API intentionally excludes estimates given more than three months ago as analysts seem to review/update their estimates in a quarterly interval. The result: under "Analyst ratings" on the website the "average price" for MU was 46.5 and the script displayed 46.77 for "mean" price.

  • .getNewsSentimentData(ticker)

    • ticker is a string representing the company ticker, e.g. TSLA.
    • This method returns the bullish and bearish sentiment in percent, the number of articles published last week, sector average bullish percent, sector average news score, and the company's news score. See example below.
  • .getTrendingStocks()

Examples

Get Price Targets: getPriceTargets

index.js File

  • Copy the code below into the index.js file
  • node index.js to run the code
const tipranksApi = require('tipranks-api-v2');

tipranksApi.getPriceTargets('TSLA').then(result => console.log(result));

Output

{
  "symbol": "TSLA",
  "priceTargets": {
    "mean": 297.3333333333333,
    "median": 300,
    "highest": 500,
    "lowest": 54,
    "numberOfEstimates": 21
  }
}

Get News Sentiment: getNewsSentimentData

index.js File

  • Copy the code below into the index.js file
  • node index.js to run the code
const tipranksApi = require('tipranks-api-v2');

tipranksApi.getNewsSentimentData('TSLA').then(result => console.log(result));

Output

{
  "symbol": "TSLA",
  "sentiment": {
    "bullishPercent": 0.4062,
    "bearishPercent": 0.5938
  },
  "buzz": {
    "articlesInLastWeek": 143,
    "weeklyAverage": 147.25,
    "buzz": 0.9711
  },
  "sectorAverageBullishPercent": 0.6204,
  "sectorAverageNewsScore": 0.52,
  "companyNewsScore": 0.3969
}

tipranks-api-v2's People

Contributors

janlukasschroeder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tipranks-api-v2's Issues

Rate limiting

Do you have any knowledge on the rate limiting for this tool? When I pull more than around 5 data points at a time, the whole thing times out and throws promise rejections. This seems odd, as the getTrendingStocks method pulls many data points at once.

How do we run your API

Hi Jan,
Do we use PHP, Python or how do I run your API?
Or Is it accessible though Postman?
Thanks

Issue running simple example

My index.js const tipranksApi = require('tipranks-api-v2'); tipranksApi.getPriceTargets('MU').then(result => console.log(result)); tipranksApi.getNewsSentimentData('MU').then(result => console.log(result)); tipranksApi.getTrendingStocks().then(trending => console.log(trending));

Output:
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] {
code: 'ERR_UNHANDLED_REJECTION'
}`

Output returns several stocks instead of just MU specified in index.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.