add async option to REST API using aio-http#73
add async option to REST API using aio-http#73yehoshuadimarsky wants to merge 2 commits intomassive-com:masterfrom
Conversation
takos22
left a comment
There was a problem hiding this comment.
I think the code you wrote is pretty good and I also need this feature, so I approve the review. I hope this will make maintainers merge the PR.
| # aiohttp doesn't handle booleans, see https://github.com/aio-libs/aiohttp/issues/4874 | ||
| bool_map = {True: 'true', False: 'false'} | ||
| params_copy = {} | ||
| for k,v in params.items(): |
There was a problem hiding this comment.
Maybe you could do the following to use the dict.get default argument:
params_copy = {name: bool_map.get(value, value) for name, value in params.items()}|
Hi, I hope to see this async option officialized in the project. Do you know when will this be added? |
|
@yjang43 sadly this lib seems to be largely unmaintained. If you need support for both asyncio and callback based websocket streaming library, I'm writing a Library for polygon APIs (click to check out). Although it already has most of the functionalities, all rest endpoints (stocks, references, forex, crypto), and all websocket streaming with both callback and asyncio based streaming client, |
|
@pssolanki111 Thanks for the suggestion. I took a look at it and the project looks great, but since my main plan is to retrieve with REST API only, I think your project does not suffice my goal, as it seems only to support websocket. Or am I missing something? |
|
@yjang43 Hey Yoo Sung, Do you mean you need REST endpoints but with That's exactly what I had in mind when I decided to implement both Stay Tuned :) |
|
@pssolanki111 Thank you! |
|
@yjang43 Oh yes I do 😆 Here take a look: https://github.com/pssolanki111/polygon/blob/main/polygon/stocks/client.py#L507 stocks and reference endpoints are already completed. I'll prolly also get crypto and forex done before I sleep today. The toggle is simple, normal_client = PolygonClient(api_key)
async_client = PolygonClient(api_key, use_async=True)All clients support context managers, (and yes support for Lemme know what you think :) |
|
@yjang43 Hey Yoo Sung, I just released a test version 0.0.2 of the lib. It has async support, context managers (both sync and async), and all endpoints. install is simply Please have a look and let me know :) |
|
@yjang43 The library is out now!! documentation: https://polygon.readthedocs.io/en/latest/ section about async support: https://polygon.readthedocs.io/en/latest/Getting-Started.html#async-support-for-rest-endpoints pypi page: https://pypi.org/project/polygon/ The README has 4 examples. Second example shows how to use async for rest: https://github.com/pssolanki111/polygon more examples will be added as i get time. |
|
Hey @yehoshuadimarsky, thanks for being interested enough in our Python client to add async support! We've released a new client (v1.0.0b) that uses Feel free to open any issues that you may have doing that and we'll work to address them. |
@clickingbuttons can you say more about this? My understanding of python concurrency is shaky at best, but it looks like the polygon python REST client is implemented with synchronous urllib3 APIs, so I don't understand how users wrapping functions in Are y'all aware of this project? It looks like someone already tried to write an async python lib for your REST API. |
Would be interesting to benchmark against the current PoolManager. I no longer work on this library, but to those who do, it may be worth checking out.
We were when I wrote it. |
Here's an implementation of adding
asynccapability to the REST API. Although, when I tested it it was NOT any faster for some reason, is that a server side limitation?Closes #56
Thanks.