Skip to content

Commit 021b3e1

Browse files
Update README to Include trace mode (#512)
1 parent e3a118a commit 021b3e1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,34 @@ print(len(options_chain))
8686

8787
Also, please refer to the API documentation to get a full understanding of how the API works and the supported arguments. All required arguments are annotated with red asterisks " * " and argument examples are set.
8888

89+
## Debugging with RESTClient
90+
91+
Sometimes you may find it useful to see the actual request and response details while working with the API. The `RESTClient` allows for this through its `trace=True` option.
92+
93+
### How to Enable Debug Mode
94+
95+
You can activate the debug mode as follows:
96+
97+
```python
98+
client = RESTClient(trace=True)
99+
```
100+
101+
### What Does Debug Mode Do?
102+
103+
When debug mode is enabled, the client will print out useful debugging information for each API request. This includes: the request URL, the headers sent in the request, and the headers received in the response.
104+
105+
### Example Output
106+
107+
For instance, if you made a request for `TSLA` data for the date `2023-08-01`, you would see debug output similar to the following:
108+
109+
```
110+
Request URL: https://api.polygon.io/v2/aggs/ticker/TSLA/range/1/minute/2023-08-01/2023-08-01?limit=50000
111+
Request Headers: {'Authorization': 'Bearer REDACTED', 'Accept-Encoding': 'gzip', 'User-Agent': 'Polygon.io PythonClient/1.12.4'}
112+
Response Headers: {'Server': 'nginx/1.19.2', 'Date': 'Tue, 05 Sep 2023 23:07:02 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Vary': 'Accept-Encoding', 'X-Request-Id': '727c82feed3790b44084c3f4cae1d7d4', 'Strict-Transport-Security': 'max-age=15724800; includeSubDomains'}
113+
```
114+
115+
This can be an invaluable tool for debugging issues or understanding how the client interacts with the API.
116+
89117
## WebSocket Client
90118

91119
Import classes

0 commit comments

Comments
 (0)