| Both sides previous revision Previous revision Next revision | Previous revision |
| products:software:edgeos:api [2020/06/07 11:32] – matthew1471 | products:software:edgeos:api [2025/05/12 13:37] (current) – external edit 127.0.0.1 |
|---|
| ====== EdgeOS API Guide ====== | ====== EdgeOS API Guide ====== |
| |
| The EdgeOS API is largely undocumented. However as the requests and responses can be monitored in a web-browser a lot of information on how it works can be derived. | The EdgeOS API is not publicly documented. However as the requests and responses can be monitored in a web-browser along with the JavaScript source being available, a lot of information on how it works can be derived. |
| | |
| | A subset of the information here was taken from https://github.com/matthew1471/EdgeOS-API/tree/master/Documentation |
| |
| ===== Authentication ===== | ===== Authentication ===== |
| ===== Websocket - Stats ===== | ===== Websocket - Stats ===== |
| |
| You can get streaming statistical data from the endpoint ''<nowiki>wss://host-or-ip/ws/stats</nowiki>''. The data from the WebSocket is framed oddly, it's actually a streaming protocol that has been sent and received over WebSocket. The data will not arrive like you might expect. You *MUST* reassemble the web socket data fragments since the frames may not align with data boundaries. Commands must be sent with a valid SESSION_ID. | You can get streaming statistical data from the endpoint ''<nowiki>wss://host-or-ip/ws/stats</nowiki>''. The data from the WebSocket is framed oddly, it's actually a streaming protocol that has been sent and received over WebSocket. The data will not arrive like you might expect. You *MUST* reassemble the web socket data fragments since the frames may not align with data boundaries. Commands must be sent with a valid SESSION_ID. Origin header is not needed for the 2.x branch of the firmware but is needed for 1.x branches. |
| |
| The format of data to and from the WebSocket stream is "LENGTH\nJSON_PAYLOAD". Failure of sending properly formed messages to start the streaming will result in no messages from server aka "dead air". | The format of data to and from the WebSocket stream is "LENGTH\nJSON_PAYLOAD". Failure of sending properly formed messages to start the streaming will result in no messages from server aka "dead air". |
| === Bandwidth Test ("bwtest-feed") === | === Bandwidth Test ("bwtest-feed") === |
| Client: | Client: |
| <code> | |
| 150 | <code>150 |
| {"SUBSCRIBE":[{"name":"bwtest-feed","sub_id":"bandwidth5","server":"192.168.0.253"}],"UNSUBSCRIBE":[],"SESSION_ID":"9a00126c5bf04e29835f7c13fe5ab155"}</code> | {"SUBSCRIBE":[{"name":"bwtest-feed","sub_id":"bandwidth5","server":"192.168.0.253"}],"UNSUBSCRIBE":[],"SESSION_ID":"9a00126c5bf04e29835f7c13fe5ab155"}</code> |
| | |
| | or with advanced properties set: |
| | |
| | <code>273 |
| | {"SUBSCRIBE":[{"name":"bwtest-feed","sub_id":"bandwidth2","server":"192.168.0.254","duration":"1","protocol":"udp","udp-bandwidth":"500","parallel-flows":"1","tcp-window-size":"64","reverse-direction":true}],"UNSUBSCRIBE":[],"SESSION_ID":"9a00126c5bf04e29835f7c13fe5ab155"}</code> |
| |
| Server: | Server: |
| ===== Third Party Unofficial APIs ===== | ===== Third Party Unofficial APIs ===== |
| There are a few developers who have worked on creating unofficial APIs: | There are a few developers who have worked on creating unofficial APIs: |
| * https://github.com/matthew1471/EdgeOS-API (written in C#) | * https://github.com/matthew1471/EdgeOS-API : C# |
| * https://github.com/andrewstuart/edgeos-rest (written in Go) | * https://github.com/andrewstuart/edgeos-rest : Go |
| | * https://github.com/brontide/aioedgeos : Python with influx collector including DPI |
| |