Skip to content

API docs

techygrrrl edited this page Jul 8, 2024 · 3 revisions

All endpoints are visible in the ./api directory, so if you run tree api you'll see them all there:

api
├── clear
│   └── index.go
├── info
│   └── index.go
├── join
│   └── index.go
├── leave
│   └── index.go
├── next
│   └── index.go
└── position
    └── index.go

6 directories, 6 files

All endpoints are GET endpoints for simplicity. Endpoints will be documented in alphabetical order.

All documentation will use my host queuerrr.vercel.app but you'll need to replace this with your own.

GET /api/clear

This will clear the queue.

Recommended for use only by broadcasters and moderators since this mutates the current queue, deleting everyone from it.

Recommended Twitch chat command mapping: !queue clear

Example request

curl --request GET \
  --url https://queuerrr.vercel.app/api/clear \
  --header 'Authorization: Bearer someGeneratedTokenABC123'

Example response

{
  "status": "successfully cleared the queue"
}

GET /api/info

Information about the queue.

Example request

curl --request GET \
  --url https://queuerrr.vercel.app/api/info \
  --header 'Authorization: Bearer someGeneratedTokenABC123'

Recommended Twitch chat command mapping: !queue info which could output either the link to the website, or the first X number of users in the queue (or all users if you don't anticipate having many users).

Example response

{
  "total": 2,
  "users": [
    {
      "created_at": "2024-07-08T02:52:16.028782Z",
      "twitch_username": "techydrrroid",
      "twitch_user_id": "717321974",
      "notes": "Room code is ABC123"
    },
    {
      "created_at": "2024-07-08T02:52:22.313001Z",
      "twitch_username": "techygrrrl",
      "twitch_user_id": "176082690",
      "notes": ""
    }
  ]
}

GET /api/join

Allows a user to join the queue.

Query params:

  • username: viewer's username or display name
  • user_id: viewer's immutable user identifier
  • notes: viewer can supply notes, e.g. a room code for the match or their username on the gaming platform so you can look them up

Recommended Twitch chat command mapping: !queue join and an alias !join for simplicity.

They should also be able to provide notes to help expedite the process, e.g. !join the room code is ABC123 or you can do a channel point redemption and allow the user to enter text.

Example request

curl --request GET \
  --url 'https://queuerrr.vercel.app/api/join?user_id=176082690&username=techygrrrl&notes=Room%20code%20is%20ABC123' \
  --header 'Authorization: Bearer someGeneratedTokenABC123'

Example response

{
  "created_at": "2024-07-08T02:52:22.313001Z",
  "twitch_username": "techygrrrl",
  "twitch_user_id": "176082690",
  "notes": "Room code is ABC123 and my gamer tag is techygrrrl"
}

GET /api/leave

Allows a user to leave the queue.

Query params:

  • user_id: viewer's immutable user identifier

Recommended Twitch chat command mapping: !queue leave and an alias !leave for simplicity.

Example request

curl --request GET \
  --url 'https://queuerrr.vercel.app/api/leave?user_id=176082690' \
  --header 'Authorization: Bearer someGeneratedTokenABC123'

Example response

{
  "status": "successfully left queue"
}

GET /api/next

Recommended for use only by broadcasters and moderators since this mutates the current queue, popping the first person in line off.

Recommended Twitch chat command mapping: !queue next and an alias !next for simplicity.

Example request

curl --request GET \
  --url 'https://queuerrr.vercel.app/api/next' \
  --header 'Authorization: Bearer someGeneratedTokenABC123'

Example response

{
  "created_at": "2024-07-08T02:52:22.313001Z",
  "twitch_username": "techygrrrl",
  "twitch_user_id": "176082690",
  "notes": "Room code is ABC123 and my gamer tag is techygrrrl"
}

GET /api/position

Get the current position of a user.

Recommended Twitch chat command mapping: !position and an alias !position for simplicity.

Query params:

  • user_id: viewer's immutable user identifier

Example request

curl --request GET \
  --url 'https://queuerrr.vercel.app//api/position?user_id=176082690' \
  --header 'Authorization: Bearer someGeneratedTokenABC123'

Example response

Returns -1 if the user is not in the queue, otherwise the position. Position count starts at 1.

{
  "position": 2
}