nimhq is a HQ Trivia API wrapper written in nim.
Install the package with nimble
nimble install nimhq
To use nimhq, you must import both nimhq
and json
import nimhq, json
When compiling, you must define a conditional symbol of SSL
, to enable SSL support. For example:
nim c -d:SSL -r file.nim
Creating a new hqClient to interface with the API
let client = hqClient(loginToken="ac4321NGx06pCFVHZEfSmD4k5caYE3NbR8utLrvduGJPYGTpkoctVdMGukC5VMFF")
Displaying the schedule
echo client.schedule()
Changing a username
discard(client.changeUsername("ExampleUsername123"))
This wrapper was originally inteded to use types, which, for example, would have changed echo client["accessToken"]
to echo client.accessToken
. While that would be much more preferred, Nim does not currently support types than can vary, as parts of the HQ Trivia API change the type of data they return. As such, using JsonNode
's was the best possible solution, despite being the less desirable one. If Nim adds support for this in the future, usage of types may be revisited.
MIT