Catalog/encoding-zigzag

Encoding

Zigzag signed mapping API

Maps signed integers to/from the unsigned zigzag encoding used by protobuf (0,-1,1,-2 -> 0,1,2,3) at 32- or 64-bit width. Answers 'What is the zigzag encoding of -1?', 'Decode this zigzag-encoded value.'

Price$0.01per request
MethodPOST
Route/v1/encoding/zigzag
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
zigzagprotobufsignedencodedecodeintegervarintencoding
API URLhttps://x402.hexl.dev/v1/encoding/zigzag
Integration docs
Example request
{
  "value": -1
}
Example response
{
  "operation": "encode",
  "bits": 64,
  "input": "-1",
  "output": "1",
  "interpretation": "Zigzag encode (64-bit): -1 -> 1."
}
Input schema
{
  "type": "object",
  "required": [
    "value"
  ],
  "properties": {
    "value": {
      "type": [
        "number",
        "string"
      ],
      "examples": [
        -1
      ]
    },
    "operation": {
      "type": "string",
      "enum": [
        "encode",
        "decode"
      ]
    },
    "bits": {
      "type": "number",
      "enum": [
        32,
        64
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}