Polygon API client
Project description
Polygon Python Client - WebSocket & RESTful APIs
Python client for the Polygon.io Stocks API
Getting Started
For a basic product overview, check out our setup and use documentation
Install
pip install polygon-api-client
polygon-api-client
supports python version >= 3.6
Simple WebSocket Demo
import time
from polygon import WebSocketClient, STOCKS_CLUSTER
def my_customer_process_message(message):
print("this is my custom message processing", message)
def main():
key = 'your api key'
my_client = WebSocketClient(STOCKS_CLUSTER, key, my_customer_process_message)
my_client.run_async()
my_client.subscribe("T.MSFT", "T.AAPL", "T.AMD", "T.NVDA")
time.sleep(2)
my_client.close_connection()
if __name__ == "__main__":
main()
Simple REST Demo
from polygon import RESTClient
def main():
key = "your api key"
client = RESTClient(key)
resp = client.stocks_equities_daily_open_close("AAPL", "2018-3-2")
print(f"On: {resp.from_} Apple opened at {resp.open} and closed at {resp.close}")
if __name__ == '__main__':
main()
Notes about the REST Client
We use swagger as our API spec and we used this swagger to generate most of the code that defines the REST client. We made this decision due to the size of our API, many endpoints and object definitions, and to accommodate future changes.
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
polygon-api-client-0.1.6.tar.gz
(18.9 kB
view hashes)
Built Distribution
Close
Hashes for polygon_api_client-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8792b719eac9282883ed890f8ecef8fb992cfe024086a900110834d6d565bf7f |
|
MD5 | 4e751187abdd148732a9f91632b3d21e |
|
BLAKE2b-256 | 6e7123eb422ac9cbcec7b28e28d7176cd0bc37d90925008479fe89b53b840aa0 |