How do I interact with a local node (go-ipfs) via a javascript script?

Hi peeps, thanks for any help with this - I have read the docs and can’t figure it out:

Please correct me if I’m wrong:

  1. If I want to run a local ipfs node, I need to implement go-ipfs.

I have got a local node running and would like to interact with it via a script, ideally javascript.
2) Is this possible or do I need to use the js-ipfs implementation?

  1. If I do need to use js-ipfs, can I run a local node too?
    i.e. host a local node using go-ipfs, then interact with it (add/cat/get etc) using a js script js-ipfs?

Thank you for your help! As you can tell, I’m a little confused…

If your goal is to say on JS if you can, just install JS-IPFS, and yes that can run a full node and be eithe rin NodeJS (server side even) or completely inside browser. Why were you wanting to use GO-IPFS if you need/want only JS? In my setup I’m using GO-IPFS and then calling the API thru the HTTP-API, so that’s an interesting question about whether the JS API can directly control a GO instance. I’m not sure.

1 Like

There is a js implementation of the HTTP API. If you check out the js-ipfs docs and repo structure you should see more info. There is also a shared interface that can be backed by either the HTTP API or a js-ipfs node.

If you’re in an environment where you can use go-ipfs over js-ipfs (i.e. you don’t need the node to be fully in a browser and you are not trying to configure/create subcomponents of IPFS using JS) it’s likely that go-ipfs is the better choice given that it tends to get features first.

2 Likes

Thanks - it was my intention to run the go-ipfs node, because it appears to be the ‘default’ version, that is all. I do not need to run it in a browser, so wanted to have a ~standalone ipfs node running, separately to everything else.
Not done this before so not sure what the best approach is!

Brilliant, thanks. I had not come across the shared interface yet - will read it now! Thanks for your help.