npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

alphavantage-wrapper-ts

v4.0.1

Published

Alpha Vantage API wrapper

Downloads

66

Readme

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: ListingState.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>': {
          open: string
          high: string
          low: string
          close: string
          volume: string
      },
      '<datetime>': {
          open: string
          high: string
          low: string
          close: string
          volume: 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>': {
          open: string
          high: string
          low: string
          close: string
          volume: string
      },
      '<datetime>': {
          open: string
          high: string
          low: string
          close: string
          volume: 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>': {
          open: string
          high: string
          low: string
          close: string
          volume: string
      },
      '<datetime>': {
          open: string
          high: string
          low: string
          close: string
          volume: 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