Live streaming API

PixelAuction has an API that livestreams changes to the state. This is what our homepage uses to listen for state changes. The livestreaming endpoint is https://pixel.auction/sse, and you can receive messages in a two ways:

Parsing messages

Messages are sent as base64-encoded Protocol Buffers. Here is the buffer format:

syntax = "proto3";

message ServerUpdate {
  required bool pixel_updated = 1;
  required string state_id = 2;
  required uint32 grid_width = 3;
  required float round_interval = 4;
  required float next_round = 5;
  required uint32 grid_upscale_factor = 6;
  required uint32 cur_x = 7;
  required uint32 cur_y = 8;
  required uint32 round = 9;
  message ColorBid {
    required uint32 id = 1;
    required uint32 credits = 2;
  }
  repeated ColorBid bid_totals = 10;
}

Decoding the message

Colors

The current bid state is sent as multipe ColorBids, each of which has an ID and a credits total. With this you can determine how many bids each color has. You can map IDs to hex values by looking up the color in this array.