Skip to main content

OpenStockAPI

OpenStockAPI Banner

English · Tiếng Việt · 日本語 · 简体中文 · 繁體中文

Free, open-source Python library to download historical stock data (OHLCV), real-time financial market quotes, orderbook, and news from Vietnam and global markets.

PyPI version Downloads Python Version License

Read the Docs »  ·  Report Bug  ·  Request Feature


📋 Table of Contents
  1. About The Project
  2. Features
  3. Quick Start
  4. Installation
  5. Usage & Documentation
  6. Supported Providers
  7. Data Modules
  8. Roadmap
  9. Contributing
  10. Changelog
  11. License

About The Project

OpenStockAPI is a free, open-source Python library designed to fetch, download, and standardize historical stock data (OHLCV), real-time financial market quotes, orderbook, ticks, news, and financials from Vietnam (HOSE, HNX, UPCOM), US, Japan, China, Hong Kong, and Australia stock markets, as well as global Crypto and Forex pairs.

It is designed to be the upstream data acquisition layer for financial applications, algorithmic trading systems, Excel add-ins, and Amibroker plugins — handling provider fallback, local caching, rate limiting, and tier-based access control — so your application logic never has to worry about data source reliability.

📘 A Vietnamese version of this README is available: README_VN.md

(back to top ↑)


Features

  • ** Multi-market & Multi-asset Support** — Covers Vietnamese (VN) equities, Cryptocurrencies (Crypto), and Forex & Commodities.
  • ** Automatic Multi-source Fallback** — Integrates providers (KBS, VCI, MSN, MAS, Maybank, Fmarket, Core Engine) with transparent automatic failover when any source is unavailable.
  • ** JWT Handshake & Freemium Tier Access Control** — Supports short-lived JWT session token verification and Free, Pro, and Premium tier rate limits via a client-side Token Bucket Limiter.
  • ** Async Support** — First-class async/await support via async_ohlcv() and async_crypto_ohlcv() for high-throughput data pipelines.

(back to top ↑)


Quick Start

import openstockapi as osapi

# Initialize with your API key (required for all tiers)
# Register for free at: https://openstockapi.com/register
osapi.init("free_YOUR_KEY")   # or "pro_YOUR_KEY" / "premium_YOUR_KEY"

# Historical OHLCV price data
df = osapi.ohlcv("VNM", resolution="1D", start="2025-01-01", end="2025-12-31")
print(df.head())

# Fetch Cryptocurrency data
btc_ohlcv = osapi.crypto_ohlcv("BTCUSDT", interval="1h", limit=5)
print(btc_ohlcv)

# Fetch Forex & Commodities data
rates = osapi.forex_rates(base="USD")
gold_price = osapi.commodities_prices(symbol="GOLD", range_val="5d", interval="1h")
print(f"USD/VND: {rates['rates']['VND']} | Gold: {gold_price['regularMarketPrice']} USD")

(back to top ↑)


Installation

Minimum install:

pip install openstockapi

With Pandas DataFrame & Excel export support:

pip install openstockapi[pandas]

Requirements: Python 3.8+

(back to top ↑)


Usage & Documentation

Full documentation, use case examples, and sample outputs are available in the User Guide:

User Guide — Getting Started

Category Module / Guide Description
Vietnamese Stock 01 — Stock Market Data Historical OHLCV, company profile, realtime quotes
Cryptocurrency 08 — Crypto Market Data Crypto OHLCV, depth, derivatives, delta footprint, leverage simulation
Forex & Commodities 09 — Forex Market Data Exchange rates, Forex OHLCV, commodities (Gold/Crude Oil), global indices
Australian Stock 10 — Dữ Liệu Chứng Khoán Úc ASX symbols list, OHLCV, company profile, balance sheet, income statement, cashflow, ratios, dividends, announcements, news
US Stock 11 — US Stock Market Data US Stock OHLCV, company profile, financials, balance sheet, income statement, cashflow, ratios, dividends, splits, calendar, news
Japanese Stock 12 — JP Stock Market Data JP Stock symbols list, OHLCV, company profile, balance sheet, income statement, cashflow, ratios, dividends, splits, calendar, news
China Stock 13 — CN Stock Market Data CN Stock symbols list, OHLCV, company profile, balance sheet, income statement, cashflow, ratios, dividends, splits, realtime quote, order book, ticks, heatmap
HK Stock 14 — HK Stock Market Data HK Stock symbols list, OHLCV, company profile, balance sheet, income statement, cashflow, ratios, dividends, splits, calendar, news, heatmap

(back to top ↑)


Supported Providers

Providers are grouped by market/asset class. Within each group, they are tried in priority order — if one fails, the next is used automatically.

Vietnamese Stock Market

Provider Source Tier Data Types
kbs KB Securities Vietnam Free OHLCV, Company Profile, News, Events
vci Vietcap Securities Free OHLCV, Profile, Financial Statements, Insider/Foreign/Prop Trading, Events
msn MSN Finance (Bing) Free OHLCV (VN & International)
mas MAS (Mass Asset Securities) Free Financial Statements, Financial Ratios
mbk Maybank Securities Vietnam Free Macro Indicators (M2, Credit Growth)
fmarket Fmarket Vietnam Free Mutual Fund NAV & Portfolio Holdings
tcbs TCBS (Techcom Securities) Free Realtime Quote, Order Book Depth

Cryptocurrency

Crypto data is sourced through the OpenStockAPI Core Engine — a managed, closed-source aggregation layer with automatic multi-provider failover and normalization. The specific upstream exchanges and data sources are not disclosed.

Capability Tier
Crypto OHLCV (historical klines) Free
Crypto OHLCV (async) Free
Order Book Depth Pro
Derivatives Indicators (OI, Funding Rate) Pro
Delta Footprint Heatmap Premium
Leverage & Margin Simulation Pro
Supported Symbols List Free
Realtime Tickers Pro
Options Instruments List Pro
Options Chain (Strikes, IV, Bid/Ask) Pro
Options Ticker & Greeks Pro
Crypto Market Heatmap Free

Forex & Commodities

Forex and Commodities data is sourced through the OpenStockAPI Core Engine with automatic fallback across multiple rate and price providers. Specific upstream sources are not disclosed.

| Forex Spot Rates | Free | | Forex OHLCV | Free | | Commodities Prices (Gold, Oil, etc.) | Free | | Global Indices & ETF (SPY, QQQ) | Free | | Cross-broker Rate Comparison | Pro | | Supported Forex Symbols List | Free | | Forex & Financial News | Free | | Global Macro Events Calendar | Free |

Australian Stock Market

Provider Source Tier Data Types
core Core Engine Free Symbols, OHLCV, Profile, Financials, Dividends, Announcements, News

US Stock Market

Provider Source Tier Data Types
core Core Engine Free OHLCV, Profile, Financials, Dividends, Splits, Calendar, News

Japanese Stock Market

Provider Source Tier Data Types
core Core Engine Free Symbols, OHLCV, Profile, Financials (Balance Sheet, Income Statement, Cashflow, Ratios), Dividends, Splits, Calendar, News

China Stock Market

Provider Source Tier Data Types
core Core Engine Free / Pro Symbols, OHLCV, Profile, Financials (Balance Sheet, Income Statement, Cashflow, Ratios), Dividends, Splits (Free); Realtime Quote, Order Book, Ticks (Pro)

HK Stock Market

Provider Source Tier Data Types
core Core Engine Free Symbols, OHLCV, Profile, Financials (Balance Sheet, Income Statement, Cashflow, Ratios), Dividends, Splits, Calendar, News

(back to top ↑)


Data Modules Overview

openstockapi
├── symbols()                # Get list of active stock symbols
├── ohlcv()                  # Historical Stock OHLCV (sync)
├── async_ohlcv()            # Historical Stock OHLCV (async)
├── profile()                # Stock Company profile
├── derivative_profile()     # Stock Derivatives (Futures/Warrants) profile
├── balance_sheet()          # Stock Balance sheet
├── income_statement()       # Stock Income statement
├── cashflow()               # Stock Cash flow statement
├── ratios()                 # Stock Financial ratios
├── quote()                  # Stock Realtime price quote
├── order_book()             # Stock Order book depth
├── market_index()           # Stock Market index OHLCV
├── macro_indicators()       # Macroeconomic data
├── fund_details()           # Stock Mutual fund info
├── company_news()           # Stock Corporate news (supports routing to Crypto/Forex via market param)
├── company_events()         # Stock Corporate events (supports routing to Crypto/Forex via market param)
├── vn_heatmap()             # VN Stock Market Heatmap data & logos
│
├── crypto_ohlcv()           # Historical Crypto OHLCV (sync)
├── async_crypto_ohlcv()     # Historical Crypto OHLCV (async)
├── crypto_depth()           # Crypto Order book depth
├── crypto_derivatives()     # Crypto Derivatives indicators
├── crypto_footprint()       # Crypto Delta footprint heatmap
├── simulate_leverage()      # Crypto Margin/leverage position simulator
├── crypto_symbols()         # Supported Crypto symbols list
├── crypto_tickers()         # Realtime Crypto tickers list
├── crypto_options_instruments() # Supported Crypto Options list
├── crypto_options_chain()   # Crypto Options chain data
├── crypto_options_ticker()  # Crypto Options detailed Greeks
├── crypto_news()            # Crypto News articles
├── crypto_events()          # Crypto Calendar events
├── crypto_profile()         # Crypto Token profile & logo
├── crypto_heatmap()         # Cryptocurrency market Heatmap
├── CryptoStream             # Realtime WebSocket streaming client
│
├── forex_rates()            # Forex Exchange rates
├── forex_ohlcv()            # Historical Forex OHLCV
├── commodities_prices()     # Commodities Prices (Gold, Oil)
├── global_indices_etf()     # Global indices and ETFs (SPY, QQQ)
├── compare_rates()          # Forex cross-broker arbitrage rates comparison
├── forex_symbols()          # Supported Forex symbols list
├── forex_news()             # Forex & Financial News articles
├── forex_events()           # Global Macro Events Calendar
├── forex_profile()          # Forex Currency Pair profile & cdn flags
│
├── asx_symbols()            # Supported ASX symbols list
├── asx_ohlcv()              # Historical ASX OHLCV
├── asx_profile()            # ASX Company profile
├── asx_balance_sheet()      # ASX Balance sheet
├── asx_income_statement()   # ASX Income statement
├── asx_cashflow()           # ASX Cash flow statement
├── asx_ratios()             # ASX Financial ratios
├── asx_dividends()          # ASX Dividend history
├── asx_announcements()      # ASX PDF announcements feed
├── asx_news()               # ASX Company news
├── asx_heatmap()            # ASX Market Heatmap data & logos
│
├── us_ohlcv()               # Historical US Stock OHLCV
├── us_profile()             # US Stock Company profile
├── us_financials()          # US Stock Financial statements
├── us_balance_sheet()       # US Stock Balance sheet
├── us_income_statement()    # US Stock Income statement
├── us_cashflow()            # US Stock Cash flow statement
├── us_ratios()              # US Stock Financial ratios
├── us_dividends()           # US Stock Dividend history
├── us_splits()              # US Stock Stock split history
├── us_calendar()            # US Stock Corporate calendar
├── us_news()                # US Stock Company news
├── us_heatmap()             # US Stock Market Heatmap data & logos
│
├── jp_symbols()             # JP Stock symbols list
├── jp_ohlcv()               # Historical JP Stock OHLCV
├── jp_profile()             # JP Stock Company profile
├── jp_financials()          # JP Stock Financial statements
├── jp_balance_sheet()       # JP Stock Balance sheet
├── jp_income_statement()    # JP Stock Income statement
├── jp_cashflow()            # JP Stock Cash flow statement
├── jp_ratios()              # JP Stock Financial ratios
├── jp_dividends()           # JP Stock Dividend history
├── jp_splits()              # JP Stock Stock split history
├── jp_calendar()            # JP Stock Corporate calendar
├── jp_news()                # JP Stock Company news
├── jp_heatmap()             # JP Stock Market Heatmap data & logos
│
├── cn_symbols()             # CN Stock symbols list
├── cn_ohlcv()               # Historical CN Stock OHLCV
├── cn_profile()             # CN Stock Company profile
├── cn_financials()          # CN Stock Financial statements
├── cn_balance_sheet()       # CN Stock Balance sheet
├── cn_income_statement()    # CN Stock Income statement
├── cn_cashflow()            # CN Stock Cash flow statement
├── cn_ratios()              # CN Stock Financial ratios
├── cn_dividends()           # CN Stock Dividend history
├── cn_splits()              # CN Stock Stock split history
├── cn_quote()               # CN Stock Realtime price quote (Pro)
├── cn_order_book()          # CN Stock Order book depth (Pro)
├── cn_tick()                # CN Stock Intraday ticks (Pro)
├── cn_heatmap()             # CN Stock Market Heatmap data & logos
│
├── hk_symbols()             # HK Stock symbols list
├── hk_ohlcv()               # Historical HK Stock OHLCV
├── hk_profile()             # HK Stock Company profile
├── hk_financials()          # HK Stock Financial statements
├── hk_balance_sheet()       # HK Stock Balance sheet
├── hk_income_statement()    # HK Stock Income statement
├── hk_cashflow()            # HK Stock Cash flow statement
├── hk_ratios()              # HK Stock Financial ratios
├── hk_dividends()           # HK Stock Dividend history
├── hk_splits()              # HK Stock Stock split history
├── hk_calendar()            # HK Stock Corporate calendar
├── hk_heatmap()             # HK Stock Market Heatmap data & logos
└── hk_news()                # HK Stock Company news

(back to top ↑)


Roadmap

  • Vietnamese equity OHLCV (KBS, VCI, MSN)
  • Financial statements (MAS, VCI)
  • Macroeconomic indicators (World Bank, Maybank)
  • Mutual fund data (Fmarket)
  • Corporate news & events (KBS, VCI)
  • Cryptocurrency data (Core Engine)
  • Crypto Options data (Deribit, OKX)
  • Forex & Commodities data (Core Engine)
  • Australian equity market data (ASX)
  • US equity market data (US)
  • WebSocket streaming quotes

(back to top ↑)


Contributing

Contributions are welcome! If you'd like to add a new data provider, please use our Connector Development Kit (CDK) which automates boilerplate code generation and validation.

For a step-by-step guide on how to add a provider using CDK, please refer to the CDK Contributor Guide.

General workflow:

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/new-provider
  3. Generate provider template: openstock-cdk generate --name <name> --market <market> --type <type>
  4. Implement your API parser logic and write tests
  5. Run tests: pytest tests/cdk/ -v
  6. Open a Pull Request

(back to top ↑)


Changelog

See all version updates, new features, and bug fixes at:

CHANGELOG.md

(back to top ↑)


License

Distributed under the GNU Affero General Public License v3.0 (AGPL-3.0). See LICENSE for more information.

(back to top ↑)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openstockapi-0.12.6.tar.gz (142.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openstockapi-0.12.6-py3-none-any.whl (201.4 kB view details)

Uploaded Python 3

File details

Details for the file openstockapi-0.12.6.tar.gz.

File metadata

  • Download URL: openstockapi-0.12.6.tar.gz
  • Upload date:
  • Size: 142.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for openstockapi-0.12.6.tar.gz
Algorithm Hash digest
SHA256 c74c917486703a59e937e74085a98ff2c80ab8a7418ca462573387edeedc6416
MD5 74c8120990bad99638c6cffd7423b2c6
BLAKE2b-256 6ae1b7c8f16a32ee592c925a4c567fc2817f7ad774d74c979eca93b0839454ae

See more details on using hashes here.

File details

Details for the file openstockapi-0.12.6-py3-none-any.whl.

File metadata

  • Download URL: openstockapi-0.12.6-py3-none-any.whl
  • Upload date:
  • Size: 201.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for openstockapi-0.12.6-py3-none-any.whl
Algorithm Hash digest
SHA256 414e9e65d74720d707092dbf8b47c0886d72de00342b9ddade5769ea6f50a370
MD5 760d781c766c5d0a3dd88e19b2e941ee
BLAKE2b-256 c24db788bab3fe2a93c89dbc3f301abd83615050a28ee4202a0187a872614ac4

See more details on using hashes here.

Release history Release notifications | RSS feed

0.13.25

2 files

0.13.24

2 files

0.13.23

2 files

0.13.22

2 files

0.13.21

2 files

0.13.20

2 files

0.13.19

2 files

0.13.18

2 files

0.13.17

2 files

0.13.16

2 files

0.13.15

2 files

0.13.14

2 files

0.13.13

2 files

0.13.12

2 files

0.13.11

2 files

0.13.10

2 files

0.13.9

2 files

0.13.8

2 files

0.13.7

2 files

0.13.6

2 files

0.13.5

2 files

0.13.4

2 files

0.13.2

2 files

0.13.1

2 files

0.13.0

2 files

0.12.9

2 files

0.12.8

2 files

0.12.7

2 files

This release

0.12.6 This release

2 files

0.12.5

2 files

0.12.4

2 files

0.12.3

2 files

0.12.2

2 files

0.12.1

2 files

0.12.0

2 files

0.10.5

2 files

0.10.4

2 files

0.10.3

2 files

0.10.2

2 files

0.10.1

2 files

0.10.0

2 files

0.2.3

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page