Catalog/encoding-varint

Encoding

LEB128 varint codec API

Encodes/decodes protobuf-style LEB128 variable-length integers, with optional zigzag wrapping for signed values, returning byte layout and decoded magnitude. Answers 'What is the varint encoding of 300?', 'Decode this protobuf varint.'

Price$0.02per request
MethodPOST
Route/v1/encoding/varint
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
varintleb128protobufzigzagencodedecodeintegerencoding
API URLhttps://x402.hexl.dev/v1/encoding/varint
Integration docs
Example request
{
  "value": 300
}
Example response
{
  "operation": "encode",
  "signed": false,
  "hex": "ac02",
  "byteLength": 2,
  "bytes": [
    172,
    2
  ],
  "interpretation": "Encoded 300 as 2-byte LEB128 varint (0xac02)."
}
Input schema
{
  "type": "object",
  "required": [
    "value"
  ],
  "properties": {
    "value": {
      "type": [
        "number",
        "string"
      ],
      "examples": [
        300,
        "ac02"
      ]
    },
    "operation": {
      "type": "string",
      "enum": [
        "encode",
        "decode"
      ]
    },
    "signed": {
      "type": "boolean"
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}