I am searching for an example preferably with curl on how to call the binary apis /getblocks.bin, /gethashes.bin and so on.
Is there somewhere an example besides the c++ code?
I would love an example in java or even curl.
The difference between JSON RPCs and binary RPCs is the format of the data in the HTTP POST request and in the server's answer.
JSON RPCs use strings representing JSON objects.
Binary RPCs use a "portable binary storage" serialization (it starts with the header
011101010101020101 and the data is organized in a kind of tree that can contain sections, integers, booleans, strings, arrays, etc.). The files defining it are in contrib/epee/include/storages/ in the Monero source code (portable_storage.h, portable_storage_from_bin.h, portable_storage_to_bin.h).
The parameters and types used by a specific binary RPC can be found in src/rpc/core_rpc_server_commands_defs.h.
So, to use binary RPCs with a language other than C++, most of the work is in implementing the functions to serialize and deserialize the "portable binary storage" format. Then, for example, to call getblocks_by_height.bin you would use something like:
parameters = serialize_to_binary_storage(array_of_block_heights) answer = rpc(host, port, "/getblocks_by_height.bin", parameters) blocks = deserialize_from_binary_storage(answer)
I wrote a lisp library of Monero tools with an implementation (experimental) of the "portable binary storage" serialization. It could be used in addition to the C++ code to help writing implementations in other languages. It can be found in https://github.com/glv2/cl-monero-tools (src/serialization/constants.lisp, src/serialization/storage.lisp). There are also a few examples of RPCs in src/rpc/daemon.lisp.