ThingEngineering / wowthing-sync

Automatic upload client for WoWthing
MIT License
15 stars 3 forks source link

Document API (on site or here?) #8

Open bloerwald opened 4 months ago

bloerwald commented 4 months ago

As a non-windows user, but still a lazy person, I had to reverse engineer the API. It boiled down to

#!/bin/bash
set -euo pipefail
apiKey="${1}"
luaFile="${2}"
curl \
  --user-agent "WoWthing Sync" \
  --header "Content-Type: application/json" \
  --header "Content-Encoding: gzip" \
  --data-binary @<(jq --raw-output \
                      --arg data "$(cat "${luaFile}")" \
                      --arg apikey "${apiKey}" \
                      '{"LuaFile": $data, "ApiKey": $apikey}' <<<'{}' | \
                      gzip) \
  https://wowthing.org/api/upload

i.e.


/upload

I feel this should probably be in some by-default-hidden block on the /upload page. No real need in hiding it.

One could engineer this into a docker container with inotify-watch for the lua file etc to have a platform-agonistic sync application, but meh. I personally will just manually run it every once in a while. To me, documenting the API somewhere would be enough.

Of course, dumping the above script in this repo is also a good thing for people like me.