Ipfs node running started with ipfs-core is not accessible through RPC or API port

Hi, I am programmatically starting ipfs node using ipfs-core. I want to interact to this ipfs node from java. There is an npm package that connects with the node through the API port. But the node started using ipfs-core does not start the gateway and the api service itself. Is it possible to achieve that? If yes, please give idea on how to do that.

1 Like

I believe if you use the full js-ipfs package, that’ll give you everything you want. This is of course assuming you’re starting it via node and not in a browser (because browsers can’t listen).

I’m not sure how to put all the components together via core.

Found the solution. The IPFS node started programmatically using ipfs-core does not start the api and gateway by itself. They need to be started separately using the below code.

import * as IPFS from 'ipfs-core'
import { HttpApi } from 'ipfs-http-server'
import { HttpGateway } from 'ipfs-http-gateway'

async function startIpfsNode () {
  const ipfs = await IPFS.create()

  const httpApi = new HttpApi(ipfs)
  await httpApi.start()

  const httpGateway = new HttpGateway(ipfs)
  await httpGateway.start()

1 Like