ipfs.config.get(key, [options])
ipfs.config.getAll([options])
ipfs.config.set(key, value, [options])
ipfs.config.replace(config, [options])
ipfs.config.profiles.list([options])
ipfs.config.profiles.apply(name, [options])
Returns the currently being used config. If the daemon is off, it returns the stored config.
Name | Type | Description |
---|---|---|
key | String |
The key of the value that should be fetched from the config file. |
An optional object which may have the following keys:
Name | Type | Default | Description |
---|---|---|---|
timeout | Number |
undefined |
A timeout in ms |
signal | AbortSignal | undefined |
Can be used to cancel any long running requests started as a result of this call |
Type | Description |
---|---|
Promise<Object> |
An object containing the configuration of the IPFS node |
const config = await ipfs.config.get()
console.log(config)
A great source of examples can be found in the tests for this API.
Returns the full config been used. If the daemon is off, it returns the stored config.
An optional object which may have the following keys:
Name | Type | Default | Description |
---|---|---|---|
timeout | Number |
undefined |
A timeout in ms |
signal | AbortSignal | undefined |
Can be used to cancel any long running requests started as a result of this call |
Type | Description |
---|---|
Promise<Object> |
An object containing the configuration of the IPFS node |
const config = await ipfs.config.getAll()
console.log(config)
A great source of examples can be found in the tests for this API.
Adds or replaces a config value.
Name | Type | Description |
---|---|---|
key | String |
The key of the value that should be added or replaced |
value | any | The value to be set |
An optional object which may have the following keys:
Name | Type | Default | Description |
---|---|---|---|
timeout | Number |
undefined |
A timeout in ms |
signal | AbortSignal | undefined |
Can be used to cancel any long running requests started as a result of this call |
Type | Description |
---|---|
Promise<void> |
If action is successfully completed. Otherwise an error will be thrown |
Note that this operation will not spark the restart of any service, i.e: if a config.replace changes the multiaddrs of the Swarm, Swarm will have to be restarted manually for the changes to take difference.
await ipfs.config.set('Discovery.MDNS.Enabled', false)
// MDNS Discovery was set to false
A great source of examples can be found in the tests for this API.
Adds or replaces a config file
Name | Type | Description |
---|---|---|
config | Object | An object that contains the new config |
An optional object which may have the following keys:
Name | Type | Default | Description |
---|---|---|---|
timeout | Number |
undefined |
A timeout in ms |
signal | AbortSignal | undefined |
Can be used to cancel any long running requests started as a result of this call |
Type | Description |
---|---|
Promise<void> |
If action is successfully completed. Otherwise an error will be thrown |
Note that this operation will not spark the restart of any service, i.e: if a config.replace changes the multiaddrs of the Swarm, Swarm will have to be restarted manually for the changes to take difference.
const newConfig = {
Bootstrap: []
}
await ipfs.config.replace(newConfig)
// config has been replaced
A great source of examples can be found in the tests for this API.
List available config profiles
None
An optional object which may have the following keys:
Name | Type | Default | Description |
---|---|---|---|
timeout | Number |
undefined |
A timeout in ms |
signal | AbortSignal | undefined |
Can be used to cancel any long running requests started as a result of this call |
Type | Description |
---|---|
Promise<Array> |
An array with all the available config profiles |
const profiles = await ipfs.config.profiles.list()
profiles.forEach(profile => {
console.info(profile.name, profile.description)
})
A great source of examples can be found in the tests for this API.
Apply a config profile
Name | Type | Description |
---|---|---|
name | String |
The name of the profile to apply |
Call config.profiles.list()
for a list of valid profile names.
An optional object which may have the following keys:
Name | Type | Default | Description |
---|---|---|---|
dryRun | boolean |
false | If true does not apply the profile |
timeout | Number |
undefined |
A timeout in ms |
signal | AbortSignal | undefined |
Can be used to cancel any long running requests started as a result of this call |
Type | Description |
---|---|
Promise<Object> |
An object containing both the original and updated config |
const diff = await ipfs.config.profiles.apply('lowpower')
console.info(diff.original)
console.info(diff.updated)
Note that you will need to restart your node for config changes to take effect.
A great source of examples can be found in the tests for this API.