Skip to content

Commit 97da4bc

Browse files
committed
Added rest example
1 parent 77c7953 commit 97da4bc

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22

33
# A Python client library for Polgyon's WebSocket and RESTful APIs
44

5-
Currently this repo only supports the WebSocket API
6-
75
## Getting Started
86

97
For a basic product overview, check out our [setup and use documentation](https://polygon.io/sockets)
108

119

12-
## Simple Demo
10+
## Simple WebSocket Demo
1311
```python
1412
import time
1513

1614

17-
from polygon_client import WebSocketClient, STOCKS_CLUSTER
15+
from polygon import WebSocketClient, STOCKS_CLUSTER
1816

1917

2018
def my_customer_process_message(message):
@@ -36,3 +34,27 @@ if __name__ == "__main__":
3634
main()
3735

3836
```
37+
38+
## Simple REST Demo
39+
```python
40+
from polygon import RESTClient
41+
42+
43+
def main():
44+
key = "your api key"
45+
client = RESTClient(key)
46+
47+
resp = client.stocks_equities_daily_open_close("AAPL", "2018-3-2")
48+
print(f"On: {resp.from_} Apple opened at {resp.open} and closed at {resp.close}")
49+
50+
51+
if __name__ == '__main__':
52+
main()
53+
```
54+
55+
56+
## Notes about the REST Client
57+
58+
We use swagger as our API spec and we used this swagger to generate most of the code that defines the REST client.
59+
We made this decision due to the size of our API, many endpoints and object definitions, and to accommodate future changes.
60+

rest-example.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from polygon import RESTClient
2+
3+
4+
def main():
5+
key = "your api key"
6+
client = RESTClient(key)
7+
8+
resp = client.stocks_equities_daily_open_close("AAPL", "2018-3-2")
9+
print(f"On: {resp.from_} Apple opened at {resp.open} and closed at {resp.close}")
10+
11+
12+
if __name__ == '__main__':
13+
main()

0 commit comments

Comments
 (0)