Skip to main content

UniBit

PyPI version Documentation Status

A Python module to get stock data and news from the UniBit API

UniBit is a free API that provides real time and historical financial data, as well as financial news. This SDK is a client-side implementation of the UniBit API (https://www.unibit.ai) which has Python functions for each available API call. For the UniBit API documentation, visit (https://unibit.ai/docs)

To get started, sign up at (https://unibit.ai/signup) to request a free access key. With a free key, all non-news API features are available with generous rate limits.

The UniBit Stock News API requires a premium account, but in return gives a wealth of news articles on all 8000 US-listed companies. Along with this, UniBit provides analyses on each news article. With deep learning, each article is classified into a comprehensive genre list, and named entities and sentiment are also extracted.

Update

Unibit python SDK is now available for Version2 APIs! For the API documentation, visit (https://unibit.ai/docs/V2.0/introduction) For the python SDK for Version2 APIs, go to Version2 APIs example
If there are multiple tickers in your input, please put them into a list, see examples Version2 APIs example

Install

To install UniBit, type:

pip install python-unibit

To install from the source, type:

git clone https://github.com/unibit-api/python-unibit.git
pip install -e python-unibit

API V2.0 Example

Get the real time price of Apple (AAPL)

from unibit_api_v2.stock import StockPrice
sp = StockPrice(key="YOUR_KEY")
aapl_stock = sp.getHistoricalStockPrice(ticker=["AAPL","WORK"],startDate="2019-09-15",endDate="2019-09-20")

Get Apple's Company Profile

from unibit_api_v2.company import CompanyInfo
ci = CompanyInfo(key="YOUR_KEY")
aapl_profile = ci.getCompanyProfile(ticker=["AAPL"])

Get Apple's Stock News

from unibit_api_v2.news import StockNews
sn = StockNews(key = "YOUR_KEY")
aapl_news = sn.getStockNews(ticker = ["AAPL"], startDate = "2019-08-25", endDate = "2019-08-30", startMinute = "10:00:00", endMinute = "11:00:00", genre = "partnership", sector = "technology")

Get Corporate Splits

from unibit_api_v2.corporate import Corporate
corporate = Corporate(key = "YOUR_KEY")
corporate_splits = corporate.getCorporateSplits(ticker = ["all"], startDate="2019-02-01", endDate="2019-02-11")

Get Historical Crypto Price

from unibit_api_v2.crypto import CryptoPrice
cp = CryptoPrice(key = "YOUR_KEY")
historical_crypto_price = cp.getHistoricalCryptoPrice(ticker=["BCH-USD"], startDate = "2019-08-25", endDate = "2019-08-30")

Get Forex Rate

from unibit_api_v2.forex import ForexRate
fr = ForexRate(key = "YOUR_KEY")
realtime_forex = fr.getRealtimeForexRates(base = "usd", foreign = ["cny","eur","inr"], amount = 1, startDate = "2019-08-29", endDate = "2019-08-29", startMinute = "11:00:00", endMinute = "12:00:00")

Get Asset Coverage

from unibit_api_v2.reference import Coverage
c = Coverage(key = "YOUR_KEY")
asset_coverage = c.getAssetCoverage(exchange = "NASDAQ")

The CSV format is supported on many of the UniBit APIs. Requesting a CSV datatype will return a csv.reader() of the data

from unibit.stockprice import StockPrice
sp = StockPrice(key="YOUR_KEY")
aapl_price_csv = sp.getPricesRealTime("AAPL", size=10, datatype="csv")

API V1.0 Example

Get the real time price of Apple (AAPL)

from unibit_api_v1.stockprice import StockPrice
sp = StockPrice(key="YOUR_KEY")
aapl_price = sp.getPricesRealTime("AAPL")

Get Apple's Company Profile

from unibit_api_v1.companyinfo import CompanyInfo
ci = CompanyInfo(key="YOUR_KEY")
aapl_profile = ci.getCompanyProfile("AAPL")

Get the latest news on Apple

from unibit_api_v1.news import StockNews
sn = StockNews(key="YOUR_KEY")
aapl_news = sn.getLatestStockNews("AAPL")

Contribute!

In the UniBit Python SDK, we not only want to wrap the UniBit API, but open source methods of stock analysis, be it with some fancy quantitative strategy, with graphing, or with machine learning. Propose something in an issue or contact me at stefan@unibit.ai if you want to help!

Documentation

Detailed documentation on the UniBit API is available at https://unibit.ai/docs/V2.0/introduction

License

This project is developed under an MIT License.

Metadata

Release files for python-unibit 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-unibit 2.1.0
File Size Uploaded
python-unibit-2.1.0.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-unibit 2.1.0
File Interpreter ABI Platform
python_unibit-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.8 kB

Release files / python-unibit-2.1.0.tar.gz

Download URL python-unibit-2.1.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a175ea1b8ccb6b005a3bf48f3af925abb9a9835cc26bbaf4d0cd79ef5fd814d6
BLAKE2b-256 checksum
How to use checksums
3ea1545afee9dccaa7c958df61af03500c6bcc5cecc2b3c88231a4d0a8f15bc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

Release files / python_unibit-2.1.0-py3-none-any.whl

Download URL python_unibit-2.1.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd6918195549d400824c20d8c72e04000775c785108bd63011e359641c27f659
BLAKE2b-256 checksum
How to use checksums
a25cc07fb591aeea38102b67fad3e162637c14f117fe92123e75d3f83cc66088
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

2.0.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release 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