Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create JSON API #46

Open
miron opened this issue Jul 8, 2022 · 0 comments · May be fixed by #47
Open

Create JSON API #46

miron opened this issue Jul 8, 2022 · 0 comments · May be fixed by #47

Comments

@miron
Copy link
Member

miron commented Jul 8, 2022

  • You can do websockets in Flask too: Flask SocketIO

  • Flasks own request instance of Request class and requests

  • Rewrite of cmd to client that gets data from API endpoints instead of importing Algo class.

  • API documentation in get request at root, i.e. api.street.yoga/
    Returns all endpoints and servertime from class, but split it up to appropriate resource classes and save to database.
    check postman Code snippets for http.client or requests payload
    See this list of http-clients, it includes asynchronious libraries and even one that offers HTTP 2.0 support.
    Using one of the asynchronious ones is a strong consideration.

  • Websockets under Windows: pyOpenSSL expects trusted root set from twisted but gets none:

    In PowerShell:

    Can't run any websocket example binance/binance-connector-python#57 (comment)

    PS C:\> $env:SSL_CERT_FILE=(py -m certifi); py yourscript.py

    In Script:

    Can't run any websocket example binance/binance-connector-python#57 (comment)

    import os, certifi, win32api
    from binance.websocket.spot.websocket_client \
        import SpotWebsocketClient as WebsocketClient
    os.environ['SSL_CERT_FILE'] = certifi.where()
    ws_client = WebsocketClient()
    
    def message_handler(message):
        print(message)
    
    ws_client.start()
    
    ws_client.mini_ticker(
        symbol='bnbusdt',
        id=1,
       callback=message_handler,
    )
    
    # Combine selected streams
    ws_client.instant_subscribe(
       stream=['bnbusdt@bookTicker', 'ethusdt@bookTicker'],
        callback=message_handler,
    )
    
    win32api.SetConsoleCtrlHandler(lambda _: ws_client.stop(), True)

    Cryptographic Authority wants to kill pyopenssl, avoid, as well as frameworks that depend on it, like twisted
    Discussion: SSL backend python-trio/trio#1145 (comment)

  • An alternative to Flask is FastAPI, uses asyncio

  • Removed binance-connector because being dependant on twisted

  • Pyramid and Django probably overkill

@miron miron linked a pull request Jul 8, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant