{"openapi":"3.1.0","info":{"title":"Bencode API","version":"1.0.0","description":"Encode and decode Bencode (BEP 3) — the serialization format BitTorrent uses for .torrent metainfo files and tracker responses. The encode endpoint turns a JSON value into Bencode: objects become dictionaries with their keys sorted in raw byte order exactly as the spec demands, arrays become lists, whole numbers become integers, and strings become length-prefixed byte strings. The decode endpoint parses Bencode back into a JSON value and enforces the spec strictly — no leading zeros in integers, no negative zero, dictionary keys must be sorted and unique, and no trailing data is tolerated — so malformed input is rejected rather than silently mangled. Binary byte strings that are not valid UTF-8 are represented losslessly as a {\"_bytes_hex\":\"…\"} object, so encode and decode round-trip exactly even for the binary \"pieces\" field of a real torrent. Decode accepts the data either as text or, for genuinely binary payloads, as hex; encode returns both the Bencode text (when printable) and its hex bytes. Everything is computed locally and deterministically, so it is instant and private. Ideal for building and parsing .torrent files, tracker tooling, BitTorrent clients and DHT messages, and teaching how the format works. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is BitTorrent's Bencode specifically; for base64, hex, URL or HTML encoding use a general encoding API, and for JSON, YAML, TOML or XML use those format APIs.","contact":{"name":"PremiumApi","url":"https://www.oanor.com/by/premiumapi"}},"servers":[{"url":"https://api.oanor.com/bencode-api","description":"oanor gateway"}],"tags":[{"name":"Bencode"},{"name":"Meta"}],"components":{"securitySchemes":{"oanorKey":{"type":"apiKey","in":"header","name":"x-oanor-key","description":"Get your key at https://www.oanor.com/developer/keys"}}},"security":[{"oanorKey":[]}],"paths":{"/v1/decode":{"get":{"operationId":"get_v1_decode","tags":["Bencode"],"summary":"Decode Bencode to a JSON value","description":"","parameters":[{"name":"bencode","in":"query","required":false,"description":"The Bencode text","schema":{"type":"string"},"example":"d3:cow3:moo4:spam4:eggse"},{"name":"hex","in":"query","required":false,"description":"Or the raw Bencode bytes as hex (binary .torrent data)","schema":{"type":"string"}}],"security":[{"oanorKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"bytes":24,"value":{"cow":"moo","spam":"eggs"}},"meta":{"timestamp":"2026-06-03T17:42:17.858Z","request_id":"221cb14e-c7c8-4ec2-ab41-53f3e78e6f12"},"status":"ok","message":"Decode from Bencode","success":true}}}},"401":{"description":"Missing or invalid x-oanor-key header"},"402":{"description":"Active subscription required"},"429":{"description":"Rate-limit or monthly quota reached"},"502":{"description":"Upstream did not respond"}}}},"/v1/encode":{"get":{"operationId":"get_v1_encode","tags":["Bencode"],"summary":"Encode a JSON value to Bencode","description":"","parameters":[{"name":"json","in":"query","required":true,"description":"A JSON value to encode","schema":{"type":"string"},"example":"{\"cow\":\"moo\",\"spam\":\"eggs\"}"}],"security":[{"oanorKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"hex":"64333a636f77333a6d6f6f343a7370616d343a6567677365","bytes":24,"bencode":"d3:cow3:moo4:spam4:eggse"},"meta":{"timestamp":"2026-06-03T17:42:17.955Z","request_id":"58d1290b-e355-4dba-9b32-2fed678518b3"},"status":"ok","message":"Encode to Bencode","success":true}}}},"401":{"description":"Missing or invalid x-oanor-key header"},"402":{"description":"Active subscription required"},"429":{"description":"Rate-limit or monthly quota reached"},"502":{"description":"Upstream did not respond"}}}},"/v1/meta":{"get":{"operationId":"get_v1_meta","tags":["Meta"],"summary":"Spec","description":"","parameters":[],"security":[{"oanorKey":[]}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"name":"Bencode API","notes":"Bencode has four types: byte strings, integers, lists and dictionaries. There is no boolean, null or float — torrents use 0/1 and integers. Dictionary keys are always emitted sorted by raw byte order. This is BitTorrent's format; for base64/hex/URL/HTML use a general encoding API and for JSON/YAML/TOML/XML use those format APIs. Nothing is stored.","version":"v1","endpoints":[{"path":"/v1/encode","params":{"json":"a JSON value to encode (string)"},"returns":"the Bencode text (when printable), its hex, and byte length"},{"path":"/v1/decode","params":{"hex":"or the raw Bencode bytes as hex (for binary .torrent data)","bencode":"the Bencode text"},"returns":"the decoded JSON value"},{"path":"/v1/meta","params":[],"returns":"this document"}],"description":"Encode and decode Bencode (BEP 3) — the serialization format used by BitTorrent for .torrent metainfo files and tracker responses. The encode endpoint turns a JSON value into Bencode (objects become dictionaries with keys sorted in raw byte order as the spec requires, arrays become lists, whole numbers become integers, strings become length-prefixed byte strings); the decode endpoint parses Bencode back into a JSON value, enforcing the spec's rules (no leading zeros in integers, no negative zero, strictly sorted unique dictionary keys, no trailing data). Binary byte strings that are not valid UTF-8 are represented losslessly as {\"_bytes_hex\":\"…\"} so encode/decode round-trip exactly. Decode accepts the data as text or, for real binary .torrent payloads, as hex; encode returns both the Bencode text (when printable) and its hex. Everything is computed locally and deterministically. Pure local computation — no key, no third-party service, instant. Live, nothing stored."},"meta":{"timestamp":"2026-06-03T17:42:18.060Z","request_id":"583ef47d-4389-4f84-b821-de14e2b305e0"},"status":"ok","message":"Meta","success":true}}}},"401":{"description":"Missing or invalid x-oanor-key header"},"402":{"description":"Active subscription required"},"429":{"description":"Rate-limit or monthly quota reached"},"502":{"description":"Upstream did not respond"}}}}},"x-oanor-pricing":[{"slug":"free","name":"Free","price_cents_month":0,"monthly_call_quota":5335,"rps_limit":2,"hard_limit":true},{"slug":"starter","name":"Starter","price_cents_month":685,"monthly_call_quota":14850,"rps_limit":8,"hard_limit":true},{"slug":"pro","name":"Pro","price_cents_month":2675,"monthly_call_quota":199500,"rps_limit":20,"hard_limit":true},{"slug":"mega","name":"Mega","price_cents_month":6475,"monthly_call_quota":1040000,"rps_limit":50,"hard_limit":true}],"x-oanor-marketplace-url":"https://www.oanor.com/api/bencode-api"}