Add CLI options to show HTTP request & body for commands

The docs for the HTTP API states “In fact, the ipfs CLI commands use this API when operating in online mode.”

Is there a way to have the CLI display the HTTP request (full URL + query string) as well as the HTML POST body generated by the command?

If not, it would be great if a CLI option could be added that prints out that info. This will greatly help those of us that are trying to use the HTTP API to build a bridge from environments other than Go and Javascript.

Yes / No.
Use wireshark.

1 Like

Your reply was prompt but unhelpful.

I guess you don’t know what wireshark is.

Wireshark is a network inspection tool, it can be used by hackers to eavesdrop for example.
So you run wireshark, and you will be able to see the HTTP calls made on your machine (be sure to bind on loopback).
A filter like tcp.port == 5001 && http should help you filter for the IPFS api.

My tip is eavesdrop yourself, that would show you the API calls. (I know it’s more hacky than something built in, but that also far less efforts)

I’m aware of the tool. However, not everyone works in an environment where they are allowed to load hacking tools on their company workstations. :upside_down_face:

It’s not a hacking tool, it’s a software debugging tool.

I’m sorry if you are banned to use wireshark, but wireshark is just a tool, it’s a hacking tool if you use it to hack, it’s a debugging tool if you use it to debug things.

Or just choose a tool that they don’t know about. An http snooping proxy like Charles or any number of similar proxies.

Many thanks for the suggestions. Much easier to use another distributed storage solution with a well documented API.

You can inspect most raw responses by using ipfs --enc=json ... in your commands.

If you are wondering about the requests, they are as they are documented, with the querying options matching the CLI flags as explained in the docs.

The main exception is the /add command, which takes a multipart body, which is amply documented.

Is there a specific endpoint you are wondering about or having issues with?

Thanks for the suggestion. I’ve started “reverse engineering” using curl --verbose where possible.

There are a few places where the documentation is unclear. Here are a couple examples:

  1. block/rm docs suggest it can be used to remove multiple blocks but it is unclear how the multiple block hashes are passed.
  2. Similar suggestion in the docs for cid/base32 (“Convert CIDs to Base32”)
  3. Docs for cid/format do not identify the default values for the ‘v’ and ‘codec’ arguments
  4. Doc for config/edit suggest it can be used to edit the config. How is that possible through the HTTP API?

I don’t mind digging deep into the docs. Since I don’t “speak” Go or Javascript (I primarily work on back-end/library/driver projects) the source is not a lot of help.