To get the pixels from the current canvas you can use the /get_pixels endpoint. This will return the pixels RGB colour in a byte format. Knowing the canvas size (/get_size) you can fetch colour data with cartesian coordinates (x and y).

What does the bytes response represent?

The response from /get_pixels returns the current state of the canvas, each pixel being 3 bytes long. Each byte in a pixel represents the red, green and blue component.

After fetching the state of the canvas in and storing it to a bytes variable you can index it to find the colour components of each pixel.

>>> pixels = ... # Fetch pixel state from /get_pixels
>>> first_pixel = pixels[0:3]
>>> first_pixel
b'\\xfd\\xd2\\x81'

In the above example, the bytestring b'\\x87\\xce\\xeb' represents the first pixel in the canvas.

You can convert the components to an integer by fetching a single index from the bytestring.

>>> first_pixel[0]
253
>>> first_pixel[1]
210
>>> first_pixel[2]
129

We now know that we have the RGB colour (253, 210, 129), or in hex notation, #FDD281.

This logic can be combined with the sizes returned by the /get_size endpoint to find the colour data for a single pixel given the X and Y coordinate.

Useful tools and libraries

We'll leave this as an exercise to the reader but there are useful libraries that can help you render the canvas image.