You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Running the daemon with the right port](#running-the-daemon-with-the-right-port)
53
58
-[Importing the module and usage](#importing-the-module-and-usage)
54
59
-[In a web browser](#in-a-web-browser)
@@ -87,6 +92,53 @@ Both the Current and Active LTS versions of Node.js are supported. Please see [n
87
92
88
93
## Usage
89
94
95
+
#### `ipfsHttpClient([options])`
96
+
97
+
> create an instance of the HTTP API client
98
+
99
+
#### Parameters
100
+
101
+
None
102
+
103
+
#### Options
104
+
105
+
`options` can be a `String`, a `URL` or a `Multiaddr` which will be interpreted as the address of the IPFS node we wish to use the API of.
106
+
107
+
Alternatively it can be an object which may have the following keys:
108
+
109
+
| Name | Type | Default | Description |
110
+
| ---- | ---- | ------- | ----------- |
111
+
| url |`String` or `URL` or `Multiaddr`|`'http://localhost:5001/api/v0'`| A URL that resolves to a running instance of the IPFS HTTP API |
112
+
| protocol |`String`|`'http'`| The protocol to used (ignored if url is specified) |
113
+
| host |`String`|`'localhost'`| The host to used (ignored if url is specified) |
114
+
| port |`number`|`5001`| The port to used (ignored if url is specified) |
115
+
| path |`String`|`'api/v0'`| The path to used (ignored if url is specified) |
116
+
| agent |[http.Agent](https://nodejs.org/api/http.html#http_class_http_agent)|`http.Agent({ keepAlive: true, maxSockets: 6 })`| An `http.Agent` used to control client behaviour (node.js only) |
117
+
118
+
#### Returns
119
+
120
+
| Type | Description |
121
+
| -------- | -------- |
122
+
|`Object`| An object that conforms to the [IPFS Core API](https://github.com/ipfs/js-ipfs/tree/master/docs/core-api)|
123
+
124
+
#### Example
125
+
126
+
```JavaScript
127
+
constcreateClient=require('ipfs-http-client')
128
+
129
+
// connect to the default API address http://localhost:5001
[](https://github.com/ipfs/js-ipfs/tree/master/packages/interface-ipfs-core)
@@ -99,7 +151,6 @@ All core API methods take _additional_ `options` specific to the HTTP API:
99
151
100
152
*`headers` - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options.
101
153
*`searchParams` - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request.
102
-
*`agent` - A node [http.Agent](https://nodejs.org/api/http.html#http_class_http_agent) used to configure connection persistence and reuse (only supported in node.js)
0 commit comments