3939 - [ Install] ( #install )
4040 - [ Next Steps] ( #next-steps )
4141- [ Usage] ( #usage )
42- - [ ` ipfsHttpClient ([options])` ] ( #ipfshttpclientoptions )
42+ - [ ` create ([options])` ] ( #createoptions )
4343 - [ Parameters] ( #parameters )
4444 - [ Options] ( #options )
4545 - [ Returns] ( #returns )
@@ -92,7 +92,7 @@ Both the Current and Active LTS versions of Node.js are supported. Please see [n
9292
9393## Usage
9494
95- #### ` ipfsHttpClient ([options])`
95+ #### ` create ([options])`
9696
9797> create an instance of the HTTP API client
9898
@@ -124,16 +124,16 @@ Alternatively it can be an object which may have the following keys:
124124#### Example
125125
126126``` JavaScript
127- const createClient = require (' ipfs-http-client' )
127+ const { create } = require (' ipfs-http-client' )
128128
129129// connect to the default API address http://localhost:5001
130- const client = createClient ()
130+ const client = create ()
131131
132132// connect to a different API
133- const client = createClient (' http://127.0.0.1:5002' )
133+ const client = create (' http://127.0.0.1:5002' )
134134
135135// connect using a URL
136- const client = createClient (new URL (' http://127.0.0.1:5002' ))
136+ const client = create (new URL (' http://127.0.0.1:5002' ))
137137
138138// call Core API methods
139139const { cid } = await client .add (' Hello world!' )
@@ -195,9 +195,8 @@ Returns an async iterable that yields `{ path, content }` objects suitable for p
195195##### Example
196196
197197``` js
198- const IpfsHttpClient = require (' ipfs-http-client' )
199- const { globSource } = IpfsHttpClient
200- const ipfs = IpfsHttpClient ()
198+ const { create , globSource } = require (' ipfs-http-client' )
199+ const ipfs = create ()
201200
202201const file = await ipfs .add (globSource (' ./docs' , { recursive: true }))
203202console .log (file)
@@ -230,9 +229,8 @@ Returns an async iterable that yields `{ path, content }` objects suitable for p
230229##### Example
231230
232231``` js
233- const IpfsHttpClient = require (' ipfs-http-client' )
234- const { urlSource } = IpfsHttpClient
235- const ipfs = IpfsHttpClient ()
232+ const { create , urlSource } = require (' ipfs-http-client' )
233+ const ipfs = create ()
236234
237235const file = await ipfs .add (urlSource (' https://ipfs.io/images/ipfs-logo.svg' ))
238236console .log (file)
@@ -265,19 +263,19 @@ To interact with the API, you need to have a local daemon running. It needs to b
265263### Importing the module and usage
266264
267265``` javascript
268- const ipfsClient = require (' ipfs-http-client' )
266+ const { create } = require (' ipfs-http-client' )
269267
270268// connect to ipfs daemon API server
271- const ipfs = ipfsClient (' http://localhost:5001' ) // (the default in Node.js)
269+ const ipfs = create (' http://localhost:5001' ) // (the default in Node.js)
272270
273271// or connect with multiaddr
274- const ipfs = ipfsClient (' /ip4/127.0.0.1/tcp/5001' )
272+ const ipfs = create (' /ip4/127.0.0.1/tcp/5001' )
275273
276274// or using options
277- const ipfs = ipfsClient ({ host: ' localhost' , port: ' 5001' , protocol: ' http' })
275+ const ipfs = create ({ host: ' localhost' , port: ' 5001' , protocol: ' http' })
278276
279277// or specifying a specific API path
280- const ipfs = ipfsClient ({ host: ' 1.1.1.1' , port: ' 80' , apiPath: ' /ipfs/api/v0' })
278+ const ipfs = create ({ host: ' 1.1.1.1' , port: ' 80' , apiPath: ' /ipfs/api/v0' })
281279```
282280
283281### In a web browser
@@ -334,7 +332,7 @@ const ipfs = window.IpfsHttpClient()
334332If you wish to send custom headers with each request made by this library, for example, the Authorization header. You can use the config to do so:
335333
336334``` js
337- const ipfs = ipfsClient ({
335+ const ipfs = create ({
338336 host: ' localhost' ,
339337 port: 5001 ,
340338 protocol: ' http' ,
@@ -350,9 +348,9 @@ To set a global timeout for _all_ requests pass a value for the `timeout` option
350348
351349``` js
352350// Timeout after 10 seconds
353- const ipfs = ipfsClient ({ timeout: 10000 })
351+ const ipfs = create ({ timeout: 10000 })
354352// Timeout after 2 minutes
355- const ipfs = ipfsClient ({ timeout: ' 2m' })
353+ const ipfs = create ({ timeout: ' 2m' })
356354// see https://www.npmjs.com/package/parse-duration for valid string values
357355```
358356
0 commit comments