🔲

Overlays

Created
Jun 7, 2021 10:00 AM
Tags
Description
Documentation regarding the retrieval and updates of overlays
The overlay API allows you to retrieve info about overlays, as well as update overlay settings, and send commands to overlays(all in real time of course)

Base URL

All of the routes to follow will be based on the base URL:
https://api2.pixelchat.tv/public

List Overlays

Route

/overlays

Methods

GET

Response

{
	"asdf-asdf-asdf": { //this key is the overlay ID
		"type": "PixelGive", //this is the type of overlay
		"settings": {
			"title": { //this is the setting key
				"type": "text",
				"value": "My Giveaway"
			},
			//... rest of settings
		}
	}
}

JavaScript Fetch Example

const req = await fetch(`https://api2.pixelchat.tv/public/overlays`, 
	{
		headers: {
			"x-api-key": "asdf12344321fdsa"
		}
	}
)

const res = await req.json();

console.log(res)

Get/Edit overlay

Route

/overlays/[overlayId]

Methods

GET | PATCH

GET

Response Codes

200 | 404

Response

{
	"type": "PixelGive", //this is the type of overlay
	"settings": {
		"title": { //this is the setting key
			"type": "text",
			"value": "My Giveaway"
		},
		//... rest of settings
	}
}

JavaScript Fetch Example

const req = await fetch(`https://api2.pixelchat.tv/public/overlays/asd-asd-asd`, 
	{
		headers: {
			"x-api-key": "asdf12344321fdsa",
			"Content-Type": "application/json"
		},
		method: "PATCH",
		body: JSON.stringify({setting: "title", value: "My FAVORITE giveaway"})
	}
)

const res = await req.json();

console.log(res)

PATCH

Body

This is the template for the body to update an overlay setting. Note that only the settings are able to be updated.
{
	"setting": "title", //the key of the setting you want to update
	"value": "My FAVORITE giveaway" //the value you'd like to set this setting to. Note 
	//that the schema of this value can change from setting to setting.
}

Response Codes

200 | 404 | 406

Response

{
	"status": "success" | "error",
	"error"?: "Invalid setting" //this will only be provided if an error occurred
}

JavaScript Fetch Example

const req = await fetch(`https://api2.pixelchat.tv/public/overlays/asd-asd-asd`, 
	{
		headers: {
			"x-api-key": "asdf12344321fdsa",
			"Content-Type": "application/json"
		},
		method: "PATCH",
		body: JSON.stringify({setting: "title", value: "My FAVORITE giveaway"})
	}
)

const res = await req.json();

console.log(res)

Send Message to Overlay

Route

/overlays/[overlayId]/message

Methods

PUT

PUT

Body

{
	"type": "triggerGiveaway",
	"data": null
}
If for whatever reason you are unable to use a PUT request, this api is available via GET requests with some limitations. When using the GET version of the endpoint include your token as a ?token= query parameter, and instead of a body you can include the type as a query parameter(?type=). The limitation of using this endpoint via GET requests, is that you will not be able to send any data along, as such only messages that don't require any sort of data will work, such as triggerGiveaway.
Available Overlay Message Types

Response

{
	"status": "success"
}
Typically no matter what you send this API will respond with a success status as it is simply passing a message to the authenticated users overlay through the Pixel Chat network. Whether or not the overlay is capable of handling each message depends on the overlay.

JavaScript Fetch Example

const req = await fetch(`https://api2.pixelchat.tv/public/overlays/asd-asd-asd/message`, 
	{
		headers: {
			"x-api-key": "asdf12344321fdsa",
			"Content-Type": "application/json"
		},
		method: "PUT",
		body: JSON.stringify({type: "triggerGiveaway", data: "null"})
	}
)

const res = await req.json();

console.log(res)