HQ Trivia API
This is a Node.JS wrapper for HQ Trivia
Installation
npm i hqtrivia-api
API Methods
hq.getUserData()
- Get the authenticated user datahq.getShows()
- Get the game schedulehq.getLeaderboard()
- Get the game leaderboardhq.getUserById()
- Get user by IDhq.searchUsers()
- Search usershq.getFriends()
- Get all friendshq.acceptFriendRequest(userId)
- Accept friend requesthq.addFriend(userId)
- Add friendhq.getIncomingFriendRequests()
- Get incoming friend requestshq.connectToGame()
- Connect to the gamehq.disconnectFromGame()
- Disconnect from the gamehq.getUpcomingSchedule()
- Get upcoming games schedule
Trivia Game Methods
hq.sendAnswer(answerID, questionId)
- Send answer to HQhq.sendSurveyAnswer(answerID, questionId)
- Send survey answer to HQhq.useExtralive(questionId)
- Use extra livehq.sendEraser(questionId)
- Use eraserhq.getErasers(friendIds)
- Get erasers
Words Game Methods
hq.sendLetter(roundId, showId, letter)
- Send letter to HQhq.sendWord(roundId, showId, word)
- Send word to HQ
Events
connected
- Called when successfully connected to the game (Words, Trivia)disconnected
- Called when disconnected from the game (Words, Trivia)question
- Called when a question is received from the server (Trivia)questionClosed
- Called when a question is closed (Trivia)questionSummary
- Called when the summary of a question is received from the server (Trivia)questionFinished
- Called when question is finished (Trivia)gameStatus
- Called when the game status is received from the server (Words, Trivia)startRound
- Called when the round starts (Words)letterReveal
- Called when letter reveal (Words)endRound
- Called when round ends (Words)showWheel
- Called when wheel shows (Words)hideWheel
- Called when wheel hideens (Words)guessResponse
- Called after sending a letter or word (Words)
Trivia Example 1
const HQTrivia = require('hqtrivia-api')
const hq = new HQTrivia('[token]')
hq.connectToGame()
hq.on('connected', () => {
console.log('Connected to HQ WS')
})
hq.on('question', (data) => {
console.log(`Question #${data.questionNumber}/${data.questionCount}`)
console.log(data.question)
console.log(data.answers.map(answer => answer.text).join(' | '))
hq.sendAnswer(data.answers[1].answerId, data.questionId)
})
hq.on('disconnected', (code) => {
console.log('Disconnected from HQ WS')
})
Words Example 1
const HQTrivia = require('hqtrivia-api')
const hq = new HQTrivia('[token]')
hq.connectToGame()
hq.on('connected', () => {
console.log('Connected to HQ WS')
})
hq.on('startRound', (data) => {
console.log(`Round Number #${data.roundNumber}/${data.totalRounds}`)
console.log(`Hint: ${data.hint}`)
console.log(`Puzzle: `)
console.log(data.puzzleState.join(' | '))
hq.sendWord(data.roundId, data.showId, 'JUGGLING')
hq.sendWord(data.roundId, data.showId, 'MULTIPLE')
hq.sendWord(data.roundId, data.showId, 'CHAINSAWS')
hq.sendLetter(data.roundId, data.showId, 'J')
hq.sendLetter(data.roundId, data.showId, 'U')
hq.sendLetter(data.roundId, data.showId, 'G')
})
hq.on('disconnected', (code) => {
console.log('Disconnected from HQ WS')
})