Narcoleptic's Patch Mangler

    alphavantage-wrapper-ts
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.0 • Public • Published

    Alphavantage Wrapper TS

    Coverage Status CI GitHub license issues forks stars npm npm downloads

    Alpha Vantage API wrapper in TypeScript.

    Table of Contents

    Contributing

    This library is in development, and all contributions are welcome, refer to CONTRIBUTING.md for more details.

    License

    This is an open source project under the MIT license, see LICENSE.md for additional information.

    Getting started

    import AlphaVantage, {
      Interval,
      DataType,
      StockTimeSeries,
    } from 'alphavantage-wrapper-ts';
    
    const av = new AlphaVantage({ apikey: 'your API key' });
    
    av.stockTimeSeries
      .intraday({ symbol: 'IBM', interval: Interval.SIXTY_MIN })
      .then((data) => console.log(data));
    
    // OR
    
    async function intraday(): Promise<StockTimeSeries.IntradayResponse> {
      const response = await av.stockTimeSeries.intraday({
        symbol: 'IBM',
        interval: Interval.SIXTY_MIN,
      });
      return response;
    }

    Stock Time Series

    Intraday

    av.stockTimeSeries
      .intraday({ symbol: 'IBM', interval: Interval.SIXTY_MIN })
      .then((data) => console.log(data));

    Parameters

    1. symbol: The name of the equity of your choice. For example: symbol=IBM
    2. interval: Time interval between two consecutive data points in the time series. The following values are supported: 1min, 5min, 15min, 30min, 60min.
    3. adjusted: (optional) By default, adjusted=true and the output time series is adjusted by historical split and dividend events. Set adjusted=false to query raw (as-traded) intraday values.
    4. outputsize: (optional) By default, outputsize=compact. Strings compact and full are accepted with the following specifications: compact returns only the latest 100 data points in the intraday time series; full returns the full-length intraday time series. The "compact" option is recommended if you would like to reduce the data size of each API call.
    5. datatype: (optional) By default, datatype=json. Strings json and csv are accepted with the following specifications: json returns the intraday time series in JSON format; csv returns the time series as a CSV (comma separated value) file.

    Response

    {
      metadata: {
        information: string;
        digitalCurrencyCode: string;
        digitalCurrencyName: string;
        marketCode: string;
        marketName: string;
        lastRefreshed: string;
        interval: string;
        outputSize: string;
        timeZone: string;
      }
      timeSeries: {
          '<datetime>': {
            open: string;
            high: string;
            low: string;
            close: string;
            volume: string;
          },
          '<datetime>': {
            open: string;
            high: string;
            low: string;
            close: string;
            volume: string;
          },
          ...
        }
    }

    Search

    av.stockTimeSeries
      .search({
        keywords: 'microsoft',
        datatype: DataType.JSON,
      })
      .then((data) => console.log(data))
      .catch((err) => console.log(err));

    Parameters

    1. keywords: A text string of your choice. For example: microsoft
    2. datatype: (optional) By default, datatype=json. Strings json and csv are accepted with the following specifications: json returns the intraday time series in JSON format; csv returns the time series as a CSV (comma separated value) file.

    Response

    [
      {
        symbol: 'MSFT',
        name: 'Microsoft Corporation',
        type: 'Equity',
        region: 'United States',
        marketOpen: '09:30',
        marketClose: '16:00',
        timezone: 'UTC-04',
        currency: 'USD',
        matchScore: '0.6154',
      },
      {
        symbol: 'MSF.DEX',
        name: 'Microsoft Corporation',
        type: 'Equity',
        region: 'XETRA',
        marketOpen: '08:00',
        marketClose: '20:00',
        timezone: 'UTC+02',
        currency: 'EUR',
        matchScore: '0.6000',
      },
      ...
    ];

    Daily Adjusted

    av.stockTimeSeries
      .dailyAdjusted({ symbol: 'IBM' })
      .then((data) => console.log(data));

    Parameters

    1. symbol: The name of the equity of your choice. For example: symbol=IBM
    2. outputsize: (optional) By default, outputsize=compact. Strings compact and full are accepted with the following specifications: compact returns only the latest 100 data points in the intraday time series; full returns the full-length intraday time series. The "compact" option is recommended if you would like to reduce the data size of each API call.
    3. datatype: (optional) By default, datatype=json. Strings json and csv are accepted with the following specifications: json returns the intraday time series in JSON format; csv returns the time series as a CSV (comma separated value) file.

    Response

    {
      metadata: {
        information: string;
        symbol: string;
        lastRefreshed: string;
        outputSize: string;
        timeZone: string;
      }
      timeSeries: {
          '<date>': {
            open: string;
            high: string;
            low: string;
            close: string;
            volume: string;
            adjustedClose: string;
            dividendAmount: string;
            splitCoefficient: string;
          },
          '<date>': {
            open: string;
            high: string;
            low: string;
            close: string;
            volume: string;
            adjustedClose: string;
            dividendAmount: string;
            splitCoefficient: string;
          },
          ...
        }
    }

    Weekly Adjusted

    av.stockTimeSeries
      .weeklyAdjusted({ symbol: 'IBM' })
      .then((data) => console.log(data));

    Parameters

    1. symbol: The name of the equity of your choice. For example: symbol=IBM
    2. datatype: (optional) By default, datatype=json. Strings json and csv are accepted with the following specifications: json returns the intraday time series in JSON format; csv returns the time series as a CSV (comma separated value) file.

    Response

    {
      metadata: {
        information: string;
        symbol: string;
        lastRefreshed: string;
        timeZone: string;
      }
      timeSeries: {
          '<date>': {
            open: string;
            high: string;
            low: string;
            close: string;
            adjustedClose: string;
            volume: string;
            dividendAmount: string;
          },
          '<date>': {
            open: string;
            high: string;
            low: string;
            close: string;
            adjustedClose: string;
            volume: string;
            dividendAmount: string;
          },
          ...
        }
    }

    Monthly Adjusted

    av.stockTimeSeries
      .monthlyAdjusted({ symbol: 'IBM' })
      .then((data) => console.log(data));

    Parameters

    1. symbol: The name of the equity of your choice. For example: symbol=IBM
    2. datatype: (optional) By default, datatype=json. Strings json and csv are accepted with the following specifications: json returns the intraday time series in JSON format; csv returns the time series as a CSV (comma separated value) file.

    Response

    {
      metadata: {
        information: string;
        symbol: string;
        lastRefreshed: string;
        timeZone: string;
      }
      timeSeries: {
          '<date>': {
            open: string;
            high: string;
            low: string;
            close: string;
            adjustedClose: string;
            volume: string;
            dividendAmount: string;
          },
          '<date>': {
            open: string;
            high: string;
            low: string;
            close: string;
            adjustedClose: string;
            volume: string;
            dividendAmount: string;
          },
          ...
        }
    }

    Fundamental data

    Company Overview

    av.fundamentalData
      .companyOverview({ symbol: 'IBM' })
      .then((data) => console.log(data));

    Parameters

    1. symbol: The name of the equity of your choice. For example: symbol=IBM

    Response

    {
      symbol: string;
      assetType: string;
      name: string;
      description: string;
      CIK: string;
      exchange: string;
      currency: string;
      country: string;
      sector: string;
      industry: string;
      address: string;
      fiscalYearEnd: string;
      latestQuarter: string;
      marketCapitalization: string;
      EBITDA: string;
      PERatio: string;
      PEGRatio: string;
      bookValue: string;
      dividendPerShare: string;
      dividendYield: string;
      EPS: string;
      revenuePerShareTTM: string;
      profitMargin: string;
      operatingMarginTTM: string;
      returnOnAssetsTTM: string;
      returnOnEquityTTM: string;
      revenueTTM: string;
      grossProfitTTM: string;
      dilutedEPSTTM: string;
      quarterlyEarningsGrowthYOY: string;
      quarterlyRevenueGrowthYOY: string;
      analystTargetPrice: string;
      trailingPE: string;
      forwardPE: string;
      priceToSalesRatioTTM: string;
      priceToBookRatio: string;
      EVToRevenue: string;
      EVToEBITDA: string;
      beta: string;
      fiftyTwoWeekHigh: string;
      fiftyTwoWeekLow: string;
      fiftyDayMovingAverage: string;
      twoHundredDayMovingAverage: string;
      sharesOutstanding: string;
      sharesFloat: string;
      sharesShort: string;
      sharesShortPriorMonth: string;
      shortRatio: string;
      shortPercentOutstanding: string;
      shortPercentFloat: string;
      percentInsiders: string;
      percentInstitutions: string;
      forwardAnnualDividendRate: string;
      forwardAnnualDividendYield: string;
      payoutRatio: string;
      dividendDate: string;
      exDividendDate: string;
      lastSplitFactor: string;
      lastSplitDate: string;
    }

    Cryptocurrencies

    Intraday

    av.cryptocurrency
      .intraday({ symbol: 'ETH', market: 'USD', interval: Interval.SIXTY_MIN })
      .then((data) => console.log(data));

    Parameters

    1. symbol: The name of the equity of your choice. For example: symbol=IBM
    2. interval: Time interval between two consecutive data points in the time series. The following values are supported: 1min, 5min, 15min, 30min, 60min.
    3. market: The exchange market of your choice. It can be any of the market in the market list. For example: market=USD.
    4. outputsize: (optional) By default, outputsize=compact. Strings compact and full are accepted with the following specifications: compact returns only the latest 100 data points in the intraday time series; full returns the full-length intraday time series. The "compact" option is recommended if you would like to reduce the data size of each API call.
    5. datatype: (optional) By default, datatype=json. Strings json and csv are accepted with the following specifications: json returns the intraday time series in JSON format; csv returns the time series as a CSV (comma separated value) file.

    Response

    {
      metadata: {
        information: string;
        symbol: string;
        lastRefreshed: string;
        interval: string;
        outputSize: string;
        timeZone: string;
      }
      timeSeries: {
          '<datetime>': {
            open: string;
            high: string;
            low: string;
            close: string;
            volume: string;
          },
          '<datetime>': {
            open: string;
            high: string;
            low: string;
            close: string;
            volume: string;
          },
          ...
        }
    }

    Monthly

    av.cryptocurrency
      .monthly({ symbol: 'ETH', market: 'CNY' })
      .then((data) => console.log(data));

    Parameters

    1. symbol: The name of the equity of your choice. For example: symbol=IBM
    2. market: The exchange market of your choice. It can be any of the market in the market list. For example: market=USD.
    3. datatype: (optional) By default, datatype=json. Strings json and csv are accepted with the following specifications: json returns the intraday time series in JSON format; csv returns the time series as a CSV (comma separated value) file.

    Response

    {
      metadata: {
        information: string;
        digitalCurrencyCode: string;
        digitalCurrencyName: string;
        marketCode: string;
        marketName: string;
        lastRefreshed: string;
        timeZone: string;
      }
      timeSeries: {
          '<datetime>': {
              openMarket: string;
              openUSD: string;
              highMarket: string;
              highUSD: string;
              lowMarket: string;
              lowUSD: string;
              closeMarket: string;
              closeUSD: string;
              volume: string;
              marketCap: string;
          },
          '<datetime>': {
              openMarket: string;
              openUSD: string;
              highMarket: string;
              highUSD: string;
              lowMarket: string;
              lowUSD: string;
              closeMarket: string;
              closeUSD: string;
              volume: string;
              marketCap: string;
          },
          ...
        }
    }

    Weekly

    av.cryptocurrency
      .weekly({ symbol: 'ETH', market: 'CNY' })
      .then((data) => console.log(data));

    Parameters

    1. symbol: The name of the equity of your choice. For example: symbol=IBM
    2. market: The exchange market of your choice. It can be any of the market in the market list. For example: market=USD.
    3. datatype: (optional) By default, datatype=json. Strings json and csv are accepted with the following specifications: json returns the intraday time series in JSON format; csv returns the time series as a CSV (comma separated value) file.

    Response

    {
      metadata: {
        information: string;
        digitalCurrencyCode: string;
        digitalCurrencyName: string;
        marketCode: string;
        marketName: string;
        lastRefreshed: string;
        timeZone: string;
      }
      timeSeries: {
          '<datetime>': {
              openMarket: string;
              openUSD: string;
              highMarket: string;
              highUSD: string;
              lowMarket: string;
              lowUSD: string;
              closeMarket: string;
              closeUSD: string;
              volume: string;
              marketCap: string;
          },
          '<datetime>': {
              openMarket: string;
              openUSD: string;
              highMarket: string;
              highUSD: string;
              lowMarket: string;
              lowUSD: string;
              closeMarket: string;
              closeUSD: string;
              volume: string;
              marketCap: string;
          },
          ...
        }
    }

    Daily

    av.cryptocurrency
      .daily({ symbol: 'ETH', market: 'CNY' })
      .then((data) => console.log(data));

    Parameters

    1. symbol: The name of the equity of your choice. For example: symbol=IBM
    2. market: The exchange market of your choice. It can be any of the market in the market list. For example: market=USD.
    3. datatype: (optional) By default, datatype=json. Strings json and csv are accepted with the following specifications: json returns the intraday time series in JSON format; csv returns the time series as a CSV (comma separated value) file.

    Response

    {
      metadata: {
        information: string;
        digitalCurrencyCode: string;
        digitalCurrencyName: string;
        marketCode: string;
        marketName: string;
        lastRefreshed: string;
        timeZone: string;
      }
      timeSeries: {
          '<datetime>': {
              openMarket: string;
              openUSD: string;
              highMarket: string;
              highUSD: string;
              lowMarket: string;
              lowUSD: string;
              closeMarket: string;
              closeUSD: string;
              volume: string;
              marketCap: string;
          },
          '<datetime>': {
              openMarket: string;
              openUSD: string;
              highMarket: string;
              highUSD: string;
              lowMarket: string;
              lowUSD: string;
              closeMarket: string;
              closeUSD: string;
              volume: string;
              marketCap: string;
          },
          ...
        }
    }

    Enums

    enum DataType {
      JSON = 'json',
      CSV = 'csv',
    }
    enum Interval {
      ONE_MIN = '1min',
      FIVE_MIN = '5min',
      FIFTEEN_MIN = '15min',
      THIRTY_MIN = '30min',
      SIXTY_MIN = '60min',
    }
    enum OutputSize {
      COMPACT = 'compact',
      FULL = 'full',
    }

    Install

    npm i alphavantage-wrapper-ts

    DownloadsWeekly Downloads

    3

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    134 kB

    Total Files

    171

    Last publish

    Collaborators

    • ricardo93borges