Skip to content

Create JSON API #46

@miron

Description

@miron
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions