I am currently working with the Monero daemon RPC and have a little problem understanding the format of the binary request (/get_o_indexes.bin for example).

Does anyone have an example of how should I generate my binary request with Python's requests library?

1 Answer 1


To call the binary methods, you have to send raw binary data as an application/octet-stream in the request body and read the binary data sent back in the response body.

There's a StackOverflow answer that shows making binary requests using Python here. Quoting the requests library example:

import requests

data = 'test data'
res = requests.post(url='http://localhost:8888',
                headers={'Content-Type': 'application/octet-stream'})

Here you would replace data with the binary tx id (which is 32 bytes), wrapped as a Levin packet. A brief overview can be found here.

For working out how to serialize the request data and deserialize the returned response data, you should start by looking in this folder.

Here is an annotated response for the interested:

0111010101010201        signature
01                      version
0c                      section
09 6f5f696e6465786573   field: string length then data: o_indexes
85                      type (uint64 | array flag)
08                      length 2 (0x08 >> 2)
aca87f0000000000        idx
ada87f0000000000        idx
06 737461747573         field: string length then data: status
0a                      type (string)
08                      length 2 (0x08 >> 2)
4f4b                    OK
09 756e74727573746564   field: string length then data: untrusted
0b                      type (bool)
00                      false

Here is a quick and dirty example of calling then parsing the response using Python.

  • Thank you for your answer, I tested your suggestion and still end up with a 404 not found. I retrieved the binary from a tx id as a string of bit and used it in the post requestas data and still end up with a 404 not found. This is my query: data = "".join(RPC_queries.to_bin(x) for x in utx); res = requests.post(url='http://localhost:18081/get_o_indexes.bin', data=data,headers={'Content-Type': 'application/octet-stream'})
    – Jeremy V.
    Commented Dec 25, 2018 at 23:09
  • Your conversion of a hex tx id to binary looks iffy - e.g. you want to use something like binascii.unhexlify.
    – jtgrassie
    Commented Dec 26, 2018 at 1:19
  • Here is a complete example of calling the method and parsing the response using python.
    – jtgrassie
    Commented Dec 27, 2018 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.