I have a fresh install of IPFS daemon on my computer :
ipfs init
ipfs daemon
When running the following command, the output seems correct:
$ ipfs routing findprovs QmUZzfuaCcPSXgADUnkF1GKBsDRUxxxxxxxxx
12D3KooWLJBTtGHSbeqHSEkAo4jTni1PBrtRktV2a85yKxxxxxx
When requesting the RPC API as follows (should give the same input as CLI):
curl -X POST "http://127.0.0.1:5001/api/v0/routing/findprovs?arg=QmUZzfuaCcPSXgADUnkF1GKBsDRUxxxxxxxxx"
The response I get contains multiple JSON objects (100+) separated by \n
{"Extra":"","ID":"12D3KooWAH9RHKrbpS1nZC7Wos91y8dD4HwN5Wq2JmHjxxxxxxx","Responses":null,"Type":7}
{"Extra":"","ID":"12D3KooWHWEKWG6Mh4ZgoCmxhP2uhyyVdBJGt388LMLXQQxxxxxx","Responses":null,"Type":0}
....
How can I get the same result as the CLI using the RPC API ?
I found a temporary solution (that is really not ideal) after further investigation and confirmation from this github post
Turns out the returned providers with
Type=4
are the ones identified by the CLI. Here is a ruby example to extract those from the response (after treating the response as plain text and not Json) :