API Tips and Tricks


  • Hello fellow makers and developers.
    We're a small team and the API is a small portion of what we focus on, so mistakes are bound to be there. This post will hopefully help you deal with any common issues that might arise.

    Quick links

    V3schema Source

    MFThree on Pypi

    Matterandform/three-schema on NPM

    API structure

    The THREE software has two main components that run on the device itself; There is a C++ server and a Node Server. The C++ server is the brain of the THREE, and handles all the computational math and processing that's needed.  The Node server is our front end. 

    When the front end is served to your browser, the page tried to create a websocket connection to the backend. This websocket connection is the only way to communicate with the backend server. The list of commands is defined in our schema, formatted with a partially customized protobuf style. The actual communication is serialized as JSON to make development human readible. When we develop anything, the schema is code-generated into the language we are developing (JS/TS, C++, Python), which let's us make libraries easily, and avoid communication conflicts.

    Libraries

    There are two public libraries for both Python and Node.
    Because protobuf was not strictly adheared to (legacy decision), the Python library required additional abstractions and conversion and as such has its own source code which you can find here. The Node package is built off the Schema repo linked above.

    Inspecting

    The last most important resource for anyone when trying to debug is to simply inspect what the front end is doing. Using any of the developer tools in your browser, you can inspect the Websocket communications, resposes and requests. This is also a ground truth for any communication, because of version differences, and old documentation. You can find an example of how to do this on Firefox here.

     



Please login to reply this topic!