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

3.0.9 • Public • Published

Alphavantage Wrapper TS

Coverage Status CI GitHub license issues forks stars npm npm downloads Commitizen friendly

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

av.stockTimeSeries.daily({ 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;
      },
      '<date>': {
        open: string;
        high: string;
        low: string;
        close: string;
        volume: string;
      },
      ...
    }
}

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

av.stockTimeSeries.weekly({ 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;
        volume: string;
      },
      '<date>': {
        open: string;
        high: string;
        low: string;
        close: string;
        volume: 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

av.stockTimeSeries.monthly({ 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;
        volume: string;
      },
      '<date>': {
        open: string;
        high: string;
        low: string;
        close: string;
        volume: 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;
      },
      ...
    }
}

Quote Endpoint

av.stockTimeSeries.quote({ 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 quote data in JSON format; csv returns the quote data as a CSV (comma separated value) file.

Response

{
  symbol: string
  open: string
  high: string
  low: string
  price: string
  volume: string
  latestTradingDay: string
  previousClose: string
  change: string
  changePercent: 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
}

Earnings

av.fundamentalData.earnings({ 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;
  annualEarnings: [
    {
      fiscalDateEnding:string;
      reportedEPS:string;
    },
    {
      fiscalDateEnding:string;
      reportedEPS:string;
    }
  ],
  quarterlyEarnings: [
    {
      fiscalDateEnding:string;
      reportedDate:string;
      reportedEPS:string;
      estimatedEPS:string;
      surprise:string;
      surprisePercentage:string;
    },
    {
      fiscalDateEnding:string;
      reportedDate:string;
      reportedEPS:string;
      estimatedEPS:string;
      surprise:string;
      surprisePercentage:string;
    }
  ]
}

Listing status

av.fundamentalData
  .listingStatus({ state: ListingStatus.ACTIVE, date: '2014-07-10' })
  .then((data) => console.log(data))

Parameters

  1. state: (Optional) By default, state=active and the API will return a list of actively traded stocks and ETFs. Set state=delisted to query a list of delisted assets.
  2. date: (Optional) If no date is set, the API endpoint will return a list of active or delisted symbols as of the latest trading day. If a date is set, the API endpoint will "travel back" in time and return a list of active or delisted symbols on that particular date in history. Any YYYY-MM-DD date later than 2010-01-01 is supported

Response

CSV

symbol,name,exchange,assetType,ipoDate,delistingDate,status
A,Agilent Technologies Inc,NYSE,Stock,1999-11-18,null,Active
...

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'
}

If found this useful somehow

Buy Me A Coffee

Package Sidebar

Install

npm i alphavantage-wrapper-ts

Weekly Downloads

19

Version

3.0.9

License

MIT

Unpacked Size

159 kB

Total Files

255

Last publish

Collaborators

  • ricardo93borges