Giter VIP home page Giter VIP logo

investing-com-api's Introduction

Investing.com Unofficial APIs

Coverage Status Maintainability npm Donate

NPM

Unofficial APIs for Investing.com website.

Install

npm i investing-com-api

Example

const { investing } = require('investing-com-api');

async function main() {
  try {
    const response1 = await investing('currencies/eur-usd'); // Providing a valid mapping.js key
    const response2 = await investing('currencies/eur-usd', 'P1M', 'P1D'); // With optional params
    const response3 = await investing('1'); // Providing the pairId directly, even if not present in mapping.js
  } catch (err) {
    console.error(err);
  }
}

Response

[
  {
    date: 1659398400000,
    value: 1.0264,
    price_open: 1.0264,
    price_high: 1.0294,
    price_low: 1.0155,
    price_close: 1.0157
  },
  {
    date: 1659484800000,
    value: 1.0158,
    price_open: 1.0158,
    price_high: 1.0209,
    price_low: 1.0126,
    price_close: 1.0136
  },
  ...
]

Inputs

Only input is required, other params are optional.

  • input String: input string, see mapping.js keys, or provide a valid investing.com pairId. (Required)
  • period String: Period of time, window size. Default P1M (1 month). Valid values: P1D, P1W, P1M, P3M, P6M, P1Y, P5Y, MAX.
  • interval Number: Interval between results. Default P1D (1 day). Valid values: PT1M, PT5M, PT15M, PT30M, PT1H, PT5H, P1D, P1W, P1M.
  • pointscount Number: number of total results. Valid values seems to be 60, 70 or 120.
  • pptrLaunchOptions Any: Puppeteer launch options, see official website.

Run tests

npm test

Run lint

npm run lint

Contribute

PRs are welcome to add more elements to the mapping.js file.

Author

investing-com-api's People

Contributors

davideviolante avatar dependabot-preview[bot] avatar dependabot[bot] avatar deputyuniverse avatar dipsx avatar gustavomfc avatar playmast3r avatar rodpin avatar veritech avatar vishalguptax avatar xyzlast 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

investing-com-api's Issues

Add some missing indices

The response is undefined

Hi, I write a demo from the README file

const { investing } = require("investing-com-api");

async function main() {
  console.log("begin");
  const response = await investing("currencies/eur-usd");
  console.log(`response is ${response}`);
  // response = [ { date: Timestamp, value: Number }, {...}, ... ]
}

main();

and I get the result from the terminal. I don't know what's wrong. Thank you!

node ./main.js 
begin
No response.data.candles found
response is undefined

Add 2 more parameters about the volumes

item[5] and item[6] probably (help wanted) represents the volume, add them into the APIs.

Eg for dow jones:

        [
            1645660800000,
            32830.33,
            33269.34,
            32272.64,
            33223.83,
            593186432, // volume?
            0 // volume?
        ],

Please make an API guide doc

Hi Davide, thanks for your code. Actually I think the investing.com API package is a creative solution. But seems that the API guide doc is not ready yet. Or can I find it somewhere? I hope you could give me a hint. Thanks!

Max memory and restart windows server

Hello I am currently having some major problems using it

After starting the system for about 1 hour - 2 hours, RAM usage suddenly increases to 90% and restarts the server
Currently, I have used PM2 and rebooted every hour but the RAM is still at 90%.

My device configuration:
Windows server 2016
RAM: 16GB
CPU: 8 cores
400GB SSD

my source:

async investing(body = {
        type: 'klines/realtime',
        name: '', //https://github.com/DavideViolante/investing-com-api/blob/master/mapping.js
        period: 'P1D, P1W, P1M, P3M, P6M, P1Y, P5Y, MAX',
        interval: 'PT1M, PT5M, PT15M, PT30M, PT1H, PT5H, P1D, P1W, P1M',
        pointcount: '60, 70, 120',
        pptrLaunchOptions: undefined,
    }) {
        let response = await investing(body.name, body.period, body.interval, Number(body.pointcount), body.pptrLaunchOptions);
        return ....
    },

Looking forward to receiving comments.

Need a solution to bypass args for launch pupperteer

Current;y, I need run my system as root user, so I need made hardcode add "--no-sandbox" in index.js for puppeteer, Could we have solution let user easy add the parameters when launch time.

Example code:
const browser = await puppeteer.launch({args: ["--no-sandbox"]});

Request failed with status code 403

OS: Windows 10 Pro 21H1
Node.js: node-v14.20.0-win-x64

==================================================================
Welcome to Node.js v14.20.0.
Type ".help" for more information.

.load ../test.js

const { investing } = require('investing-com-api');

async function main() {
try {
const response1 = await investing('currencies/eur-usd');
const response2 = await investing('currencies/eur-usd', 'P1M', 'P1D'); // With optional params
} catch (err) {
console.error(err);
}
}

main();

Promise {
,
[Symbol(async_id_symbol)]: 95,
[Symbol(trigger_async_id_symbol)]: 5,
[Symbol(destroyed)]: { destroyed: false }
}
> Request failed with status code 403
Request failed with status code 403

Fix tests on v4

Since v4 uses Puppeteer, mocha tests fails. Fix them somehow.

APIs changes

APIs used from investing.com website changed. This lib needs an update.

Example:
https://www.investing.com/currencies/gbp-usd

2 is id
P3M is period
P1D is interval
120 is candle count

curl 'https://api.investing.com/api/financialdata/2/historical/chart/?period=P3M&interval=P1D&pointscount=120' \
  -H 'authority: api.investing.com' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'domain-id: www' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "Linux"' \
  -H 'origin: https://www.investing.com' \
  -H 'sec-fetch-site: same-site' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-dest: empty' \
  -H 'referer: https://www.investing.com/' \
  --compressed

I am unable to get results

Hallo, I appreciate your work and I really would like to be able to use for retieving data, but unfortunately in my case I can't.
What I did so far:
npm i investing-com-api
(warn on finishing about puppeteer version deprecated...)
Created a myfile.js file with content as for your example.
Launched myfile.js with:
node myfile.js
The script runs with no errors, but nothing appears as result on the terminal.
Am I missing something?
Thank you.

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.