Unofficial Public.com Invest API written in Python Requests
Project description
Unofficial Public.com Invest API
This is an unofficial API for Public.com. It is a simple Python wrapper around the Public.com requests API. It is not affiliated with Public.com in any way. Use at your own risk.
This is still a very work in progress, so it will have bugs and missing features. Feel free to contribute!
Installation
pip install public-invest-api
Usage: Logging In
from public_invest_api import Public
public = Public()
public.login(
username='your_email',
password='your_password'
wait_for_2fa=True # When logging in for the first time, you need to wait for the SMS code
)
If you'd like to handle the 2FA code yourself, set wait_for_2fa=False and it will throw an Exception relating to 2FA. Catch this, then when you get the 2FA code, call it again with the code:
public.login(
username='your_email',
password='your_password',
wait_for_2fa=False,
code='your_2fa_code' # Should be six digit integer
)
Usage: Get Holdings
positions = public.get_positions()
for position in positions:
print(position)
Place Order
order = public.place_order(
symbol='AAPL',
quantity=1,
side='BUY', # or 'SELL'
order_type='MARKET', # or 'LIMIT' or 'STOP'
time_in_force='DAY' # or 'GTC' or 'IOC' or 'FOK'
is_dry_run=False # If True, it will not actually place the order
tip=0 # The amount to tip Public.com
)
print(order)
Contributing
Found or fixed a bug? Have a feature request? Feel free to open an issue or pull request!
Enjoying the project? Feel free to Sponsor me on GitHub or Ko-fi!
DISCLAIMER
DISCLAIMER: I am not a financial advisor and not affiliated with Public.com. Use this tool at your own risk. I am not responsible for any losses or damages you may incur by using this project. This tool is provided as-is with no warranty.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file public_invest_api-1.0.2.tar.gz.
File metadata
- Download URL: public_invest_api-1.0.2.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7d448a58cdb3ddf3ea378f5f1e54d35a291d3d6ee0b2196d7391c01ce1c9ee7
|
|
| MD5 |
0ad0743d97b89d152b49c99edafa1b28
|
|
| BLAKE2b-256 |
4bcd144a96855f5dc0139b94a07e3c243fa638e1aaeca05356336b2219216f93
|
File details
Details for the file public_invest_api-1.0.2-py3-none-any.whl.
File metadata
- Download URL: public_invest_api-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
329f691643fbcf6cab810239ac243ebe1ac9879c53d7af20d313dec5b5c1f108
|
|
| MD5 |
70e4669ab4ae7cc5eaa305c979d42abe
|
|
| BLAKE2b-256 |
4f6a170e14b6f1b49637e9b8db0b6726bed99ffe4e295698cf471a0e4ec6b36a
|