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

financialmodelingprep-node

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

financialmodelingprep-node

A Node.js client for the FinancialModelingPrep API

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

FinancialModelingPrep.com Node.js Wrapper

A Node.js client for interacting with the FinancialModelingPrep API, providing a wide range of financial data, including market, company, and economic data. This library is designed to make it easy to fetch financial information with simple method calls.

Disclaimer

This project is an independent initiative and has no affiliation with FinancialModelingPrep or its web API development. It is provided as a convenient way to interact with the API at financialmodelingprep.com. The library is provided "as is," without warranty of any kind, express or implied. Use this library at your own risk. The author assumes no responsibility for any issues or damages that may arise from using this library.

Features

  • Access a variety of financial data endpoints (e.g., market data, company profiles, financial statements).
  • Flexible configuration for API rate limits.
  • Easy-to-use API methods for quick integration.
  • Support for environment variables for sensitive data (API keys).
  • Comprehensive test coverage for robust functionality.
  • Easily extensible to support new API endpoints.
  • Quickstart examples for easy integration.

Table of Contents

Installation

You can install this package using npm:

npm install financialmodelingprep-node

Or using yarn:

yarn add financialmodelingprep-node

Configuration

This client uses the FinancialModelingPrep API key for accessing data. You can provide the API key directly or use an environment variable.

Using Environment Variables

  1. Create a .env file in the root of your project:

    touch .env
    
  2. Add your FinancialModelingPrep API key to the .env file:

    FMP_API_KEY=your_api_key_here
    

Direct Configuration

Alternatively, you can directly set the API key when creating an instance of the client:

const FinancialModelingPrepClient = require('financialmodelingprep-node');
const fmpClient = new FinancialModelingPrepClient('your_api_key_here');

Usage

Importing the Client

import FinancialModelingPrepClient from 'financialmodelingprep-node';

// Using environment variables for API key
const fmpClient = new FinancialModelingPrepClient(process.env.FMP_API_KEY);

Example Usage

Fetch the company profile for the given symbol.

// Fetch the company profile for a given symbol
fmpClient.companyProfile({ symbol: 'TICKER' })

    // Success!
    .then(data => {

        // Use the data as needed
        console.log(data);
    })

    // Failure!
    .catch(error => {

        // Handle any errors
        console.error(error);
    });

Using the any Method for Dynamic Endpoints

The any method allows you to call any endpoint by specifying the version and path. This is especially useful if new endpoints are added to the API, or if this library is not updated frequently to include those new endpoints.

// Use the `any` method to dynamically call any endpoint
fmpClient.any('v4', 'treasury', { from: '2024-09-13', to: '2024-09-13' })

    // Success!
    .then(data => {

        // Use the data as needed
        console.log('Treasury Data (via any method):', data);
    })

    // Failure!
    .catch(error => {

        // Handle any errors
        console.error('Error:', error);
    });

API Request Timeout

Specify a timeout (in milliseconds) for API requests. By default, the timeout is set to 3000 milliseconds (3 seconds).

const fmpClient = new FinancialModelingPrepClient(process.env.FMP_API_KEY, { timeout: 3000 });

API Endpoints

This client supports a wide range of endpoints, categorized as follows:

  • Market Data: quote, quotes, stockMarketGainers, etc.
  • Company Data: companyProfile, stockPeers, companyOutlook, etc.
  • Financial Statements: incomeStatement, balanceSheetStatement, etc.
  • Economic Data: treasury, economicCalendar, etc.
  • News and Press Releases: stockNews, pressReleases, etc.
  • Search: search, searchTicker, searchIsin, etc.

For detailed information on all available endpoints, refer to the official FinancialModelingPrep API Documentation.

If a new endpoint is introduced, you can use the flexible any method to call it without waiting for an update to this library. Alternatively, you can modify or add to the config files in the src/config directory to include new endpoints.

Note: The methods in this client generally follow the naming style of the FinancialModelingPrep API with camelCase conventions. Check the examples directory for the full list of available endpoints and their parameters.

List of All Available Endpoints

To get a complete list of all available methods (i.e., API Endpoints), you can use the getAllEndpoints function.

This function returns an array of all the method names supported by this client:


// Get all the API Endpoints
const endpoints = fmpClient.getAllEndpoints();

// Display the list
console.log(endpoints);

Examples

Here are some quick examples of how to use the client. For more examples, explore the full list.

Get Treasury Data

fmpClient.treasury({ from: '2024-01-01', to: '2024-12-31' })
    .then(data => console.log(data))
    .catch(error => console.error(error));

Search for a Stock

fmpClient.search({ query: 'text' })
    .then(data => console.log(data))
    .catch(error => console.error(error));

Get Stock Market Gainers

fmpClient.stockMarketGainers()
    .then(data => console.log(data))
    .catch(error => console.error(error));

Build Process

The source code in this package is written in ES modules (ESM) and is compiled into both ESM and CommonJS (CJS) formats for distribution. The compiled files are located in the dist directory. To build the package, run:

npm run build

Note: The dist directory is included in the npm package but excluded from the GitHub repository.

Testing

This project includes a comprehensive test suite. To run the tests, use:

npm test

Contributing

Contributions are welcome! Please fork this repository and open a pull request to propose changes.

  1. Fork the repository
  2. Create a new branch (git checkout -b feature-branch)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature-branch)
  5. Open a pull request

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Keywords

FAQs

Package last updated on 17 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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