Skip to main content

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)

Usage: Placing Orders

order = public.place_order(
    symbol='AAPL',
    quantity=1,
    side='BUY', # or 'SELL'
    order_type='MARKET', # or 'LIMIT' or 'STOP'
    limit_price=None # pass float if using 'LIMIT' order_type
    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!

Sponsor 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


Download files

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

Source Distribution

public_invest_api-1.2.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

public_invest_api-1.2.2-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file public_invest_api-1.2.2.tar.gz.

File metadata

  • Download URL: public_invest_api-1.2.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.9

File hashes

Hashes for public_invest_api-1.2.2.tar.gz
Algorithm Hash digest
SHA256 164aee011c1aa0b849a03b1b1685f7aaeefe3a15b770f2fe92ef40b885032779
MD5 a225e2ed5ba2b30b7e74e4c1147d857c
BLAKE2b-256 b6e8c813360ca07e7a717d4c61027499b5e7c99f75ab5d599bf997e1e7bf5fb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for public_invest_api-1.2.2.tar.gz:

Publisher: pypi_publish.yml on NelsonDane/public-invest-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file public_invest_api-1.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for public_invest_api-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1940faa5ed7f34e26a93fb6898ad0172afbf47ba43ec2f179e442998cddea867
MD5 e433bc9ad8f604e438f450989a7d6a6f
BLAKE2b-256 cbd75acf4fd3c2e7484fc1e818a552ec173d50d6de45ac56fefb2403e2f9b706

See more details on using hashes here.

Provenance

The following attestation bundles were made for public_invest_api-1.2.2-py3-none-any.whl:

Publisher: pypi_publish.yml on NelsonDane/public-invest-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page