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
{{ message }}
This repository was archived by the owner on Mar 10, 2020. It is now read-only.
refactor: rename library to ipfs-http-client (#897)
BREAKING CHANGE: the `ipfs-api` library has been renamed to `ipfs-http-client`.
Now install via `npm install ipfs-http-client`.
Note that in the browser build the object attached to `window` is now `window.IpfsHttpClient`.
License: MIT
Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
If you omit the host and port, the API will parse `window.host`, and use this information. This also works, and can be useful if you want to write apps that can be run from multiple different gateways:
148
+
If you omit the host and port, the client will parse `window.host`, and use this information. This also works, and can be useful if you want to write apps that can be run from multiple different gateways:
149
149
150
150
```js
151
-
constipfs=window.IpfsApi()
151
+
constipfs=window.IpfsHttpClient()
152
152
```
153
153
154
154
### CORS
155
155
156
-
In a web browser IPFS API (either browserified or CDN-based) might encounter an error saying that the origin is not allowed. This would be a CORS ("Cross Origin Resource Sharing") failure: IPFS servers are designed to reject requests from unknown domains by default. You can whitelist the domain that you are calling from by changing your ipfs config like this:
156
+
In a web browser IPFS HTTP client (either browserified or CDN-based) might encounter an error saying that the origin is not allowed. This would be a CORS ("Cross Origin Resource Sharing") failure: IPFS servers are designed to reject requests from unknown domains by default. You can whitelist the domain that you are calling from by changing your ipfs config like this:
If 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:
167
167
168
-
```
169
-
const ipfs = IpfsApi({
168
+
```js
169
+
constipfs=ipfsClient({
170
170
host:'localhost',
171
171
port:5001,
172
172
protocol:'http',
@@ -182,7 +182,7 @@ const ipfs = IpfsApi({
182
182
183
183
[](https://github.com/ipfs/interface-ipfs-core)
184
184
185
-
> `js-ipfs-api` follows the spec defined by [`interface-ipfs-core`](https://github.com/ipfs/interface-ipfs-core), which concerns the interface to expect from IPFS implementations. This interface is a currently active endeavor. You can use it today to consult the methods available.
185
+
> `js-ipfs-http-client` follows the spec defined by [`interface-ipfs-core`](https://github.com/ipfs/interface-ipfs-core), which concerns the interface to expect from IPFS implementations. This interface is a currently active endeavor. You can use it today to consult the methods available.
186
186
187
187
#### Files
188
188
@@ -329,18 +329,18 @@ const ipfs = IpfsApi({
329
329
330
330
#### Pubsub Caveat
331
331
332
-
**Currently, the [PubSub API only works in Node.js environment](https://github.com/ipfs/js-ipfs-api/issues/518)**
332
+
**Currently, the [PubSub API only works in Node.js environment](https://github.com/ipfs/js-ipfs-http-client/issues/518)**
333
333
334
334
We currently don't support pubsub when run in the browser, and we test it with separate set of tests to make sure if it's being used in the browser, pubsub errors.
335
335
336
-
More info: https://github.com/ipfs/js-ipfs-api/issues/518
336
+
More info: https://github.com/ipfs/js-ipfs-http-client/issues/518
337
337
338
338
This means:
339
-
- You can use pubsub from js-ipfs-api in Node.js
340
-
- You can use pubsub from js-ipfs-api in Electron
341
-
(when js-ipfs-api is ran in the main process of Electron)
342
-
- You can't use pubsub from js-ipfs-api in the browser
343
-
- You can't use pubsub from js-ipfs-api in Electron's
339
+
- You can use pubsub from js-ipfs-http-client in Node.js
340
+
- You can use pubsub from js-ipfs-http-client in Electron
341
+
(when js-ipfs-http-client is ran in the main process of Electron)
342
+
- You can't use pubsub from js-ipfs-http-client in the browser
343
+
- You can't use pubsub from js-ipfs-http-client in Electron's
344
344
renderer process
345
345
- You can use pubsub from js-ipfs in the browsers
346
346
- You can use pubsub from js-ipfs in Node.js
@@ -360,14 +360,12 @@ A set of data types are exposed directly from the IPFS instance under `ipfs.type
Adding to the methods defined by [`interface-ipfs-core`](https://github.com/ipfs/interface-ipfs-core), `js-ipfs-api` exposes a set of extra utility methods. These utility functions are scoped behind the `ipfs.util`.
366
+
Adding to the methods defined by [`interface-ipfs-core`](https://github.com/ipfs/interface-ipfs-core), `js-ipfs-http-client` exposes a set of extra utility methods. These utility functions are scoped behind the `ipfs.util`.
369
367
370
-
Complete documentation for these methods is coming with: https://github.com/ipfs/js-ipfs-api/pull/305
368
+
Complete documentation for these methods is coming with: https://github.com/ipfs/js-ipfs-http-client/pull/305
371
369
372
370
##### Get endpoint configuration (host and port)
373
371
@@ -395,9 +393,9 @@ We run tests by executing `npm test` in a terminal window. This will run both No
395
393
396
394
## Contribute
397
395
398
-
The js-ipfs-api is a work in progress. As such, there's a few things you can do right now to help out:
396
+
The js-ipfs-http-client is a work in progress. As such, there's a few things you can do right now to help out:
399
397
400
-
-**[Check out the existing issues](https://github.com/ipfs/js-ipfs-api/issues)**!
398
+
-**[Check out the existing issues](https://github.com/ipfs/js-ipfs-http-client/issues)**!
401
399
-**Perform code reviews**. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
402
400
-**Add tests**. There can never be enough tests. Note that interface tests exist inside [`interface-ipfs-core`](https://github.com/ipfs/interface-ipfs-core/tree/master/js/src).
403
401
-**Contribute to the [FAQ repository](https://github.com/ipfs/faq/issues)** with any questions you have about IPFS or any of the relevant technology. A good example would be asking, 'What is a merkledag tree?'. If you don't know a term, odds are, someone else doesn't either. Eventually, we should have a good understanding of where we need to improve communications and teaching together to make IPFS and IPN better.
@@ -414,4 +412,4 @@ This module started as a direct mapping from the go-ipfs cli to a JavaScript imp
Copy file name to clipboardexpand all lines: examples/bundle-browserify/README.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
-
# Bundle js-ipfs-api with Browserify!
1
+
# Bundle js-ipfs-http-client with Browserify!
2
2
3
-
> In this example, you will find a boilerplate you can use to guide yourself into bundling js-ipfs-api with browserify, so that you can use it in your own web app!
3
+
> In this example, you will find a boilerplate you can use to guide yourself into bundling js-ipfs-http-client with browserify, so that you can use it in your own web app!
4
4
5
5
## Setup
6
6
7
-
As for any js-ipfs-api example, **you need a running IPFS daemon**, you learn how to do that here:
7
+
As for any js-ipfs-http-client example, **you need a running IPFS daemon**, you learn how to do that here:
8
8
9
9
-[Spawn a go-ipfs daemon](https://ipfs.io/docs/getting-started/)
10
10
-[Spawn a js-ipfs daemon](https://github.com/ipfs/js-ipfs#usage)
11
11
12
-
**Note:** If you load your app from a different domain than the one the daemon is running (most probably), you will need to set up CORS, see https://github.com/ipfs/js-ipfs-api#cors to learn how to do that.
12
+
**Note:** If you load your app from a different domain than the one the daemon is running (most probably), you will need to set up CORS, see https://github.com/ipfs/js-ipfs-http-client#cors to learn how to do that.
Copy file name to clipboardexpand all lines: examples/bundle-webpack/README.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
-
# Bundle js-ipfs-api with Webpack!
1
+
# Bundle js-ipfs-http-client with Webpack!
2
2
3
-
> In this example, you will find a boilerplate you can use to guide yourself into bundling js-ipfs-api with webpack, so that you can use it in your own web app!
3
+
> In this example, you will find a boilerplate you can use to guide yourself into bundling js-ipfs-http-client with webpack, so that you can use it in your own web app!
4
4
5
5
## Setup
6
6
7
-
As for any js-ipfs-api example, **you need a running IPFS daemon**, you learn how to do that here:
7
+
As for any js-ipfs-http-client example, **you need a running IPFS daemon**, you learn how to do that here:
8
8
9
9
-[Spawn a go-ipfs daemon](https://ipfs.io/docs/getting-started/)
10
10
-[Spawn a js-ipfs daemon](https://github.com/ipfs/js-ipfs#usage)
11
11
12
-
**Note:** If you load your app from a different domain than the one the daemon is running (most probably), you will need to set up CORS, see https://github.com/ipfs/js-ipfs-api#cors to learn how to do that.
12
+
**Note:** If you load your app from a different domain than the one the daemon is running (most probably), you will need to set up CORS, see https://github.com/ipfs/js-ipfs-http-client#cors to learn how to do that.
Copy file name to clipboardexpand all lines: examples/upload-file-via-browser/README.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,15 @@
1
-
# Upload file to IPFS via browser using js-ipfs-api
1
+
# Upload file to IPFS via browser using js-ipfs-http-client
2
2
3
-
> In this example, you will find a simple React app to upload a file to IPFS via the browser using js-ipfs-api and Webpack.
3
+
> In this example, you will find a simple React app to upload a file to IPFS via the browser using js-ipfs-http-client and Webpack.
4
4
5
5
## Setup
6
6
7
-
As for any js-ipfs-api example, **you need a running IPFS daemon**, you learn how to do that here:
7
+
As for any js-ipfs-http-client example, **you need a running IPFS daemon**, you learn how to do that here:
8
8
9
9
-[Spawn a go-ipfs daemon](https://ipfs.io/docs/getting-started/)
10
10
-[Spawn a js-ipfs daemon](https://github.com/ipfs/js-ipfs#usage)
11
11
12
-
**Note:** If you load your app from a different domain than the one the daemon is running (most probably), you will need to set up CORS, see https://github.com/ipfs/js-ipfs-api#cors to learn how to do that.
12
+
**Note:** If you load your app from a different domain than the one the daemon is running (most probably), you will need to set up CORS, see https://github.com/ipfs/js-ipfs-http-client#cors to learn how to do that.
13
13
14
14
A quick (and dirty way to get it done) is:
15
15
@@ -31,4 +31,4 @@ Now open your browser at `http://localhost:3000`
31
31
32
32
After uploading a file (left screen), and opening the uploaded file (right screen), you should see something like:
reason: 'FIXME Waiting for fix on go-ipfs https://github.com/ipfs/js-ipfs-api/pull/307#discussion_r69281789 and https://github.com/ipfs/go-ipfs/issues/2927'
46
+
reason: 'FIXME Waiting for fix on go-ipfs https://github.com/ipfs/js-ipfs-http-client/pull/307#discussion_r69281789 and https://github.com/ipfs/go-ipfs/issues/2927'