Configure --api through .ipfs/config

Is it possible to set --api permanently?

My use case is that I have a program that calls /usr/bin/ipfs, and I want to point that on a remote node without modifying the code of that program.

I’ve tried Addresses.API, but that’s obviously stands for a listening address, not a contact one. Then I’ve tried and Gateway.APICommands, it didn’t work either, but I’m not sure if it should because I couldn’t find any documentation on that.

Thanks in advance!

This is not possible that I know of, but you could replace the ipfs binary with a script that acts as an alias and sticks the flag in place for you.

Thanks for the answer!

That’s true, I could replace it with a shell script. May it cause signal handling problems for IPFS, or something like that?

Btw, does this sound worthy of a feature request on GitHub?

Should be ok with something like exec ipfs --api <api> $@ I think?

Maybe. I think this should probably be environment-variable-controlled behaviour. The config file is more the “server” side configuration, while this is a client option. There might already be issues for this, or similar.

You can create an empty IPFS repo with an api file that points to your remote node. That is:

In ~/.ipfs/api (no other files needed in this repo):

/ip4/.../tcp/...
1 Like