Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 8ae12a3

Browse files
committed
next generation of the ipfs-api
1 parent 848cb87 commit 8ae12a3

File tree

7 files changed

+122
-370
lines changed

7 files changed

+122
-370
lines changed

API.md

-204
This file was deleted.

README.md

+43-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# js-ipfs-api
1+
ipfs-api
2+
========
23

34
[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)
45
[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/)
@@ -9,7 +10,9 @@
910
[![Travis CI](https://travis-ci.org/ipfs/js-ipfs-api.svg?branch=master)](https://travis-ci.org/ipfs/js-ipfs-api)
1011
[![Circle CI](https://circleci.com/gh/ipfs/js-ipfs-api.svg?style=svg)](https://circleci.com/gh/ipfs/js-ipfs-api)
1112

12-
> A client library for the IPFS HTTP API, implemented in JavaScript.
13+
> A client library for the IPFS HTTP API, implemented in JavaScript. This client library implements the [interface-ipfs-core](https://github.com/ipfs/interface-ipfs-core) enabling applications to change between a embebed js-ipfs node and any remove IPFS node without having to change the code. In addition, this client library implements a set of utility functions.
14+
15+
![](https://github.com/ipfs/interface-ipfs-core/raw/master/img/badge.png)
1316

1417
## Table of Contents
1518

@@ -20,7 +23,7 @@
2023
- [In the Browser through `<script>` tag](#in-the-browser-through-script-tag)
2124
- [CORS](#cors)
2225
- [Usage](#usage)
23-
- [Callbacks and promises](#callbacks-and-promises)
26+
- [Callbacks and Promises](#callbacks-and-promises)
2427
- [Contribute](#contribute)
2528
- [License](#license)
2629

@@ -99,7 +102,7 @@ $ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://exam
99102

100103
## Usage
101104

102-
See [API.md](API.md) and [`tests/api`](test/api) for details on available methods.
105+
See [interface-ipfs-core](https://github.com/ipfs/interface-ipfs-core) for the standard IPFS API. In addition, this module implements a set of utility functions.
103106

104107
### Callbacks and promises
105108

@@ -118,9 +121,40 @@ ipfs.id()
118121
This relies on a global `Promise` object. If you are in an environment where that is not
119122
yet available you need to bring your own polyfill.
120123

124+
### Utility functions
125+
126+
These utility functions are scoped behind the `ipfs.util`.
127+
128+
#### Add files or entire directories from the FileSystem to IPFS
129+
130+
> `ipfs.util.fsAdd(path, callback)`
131+
132+
Reads path from disk, if it is a directory, will add it recursively, if not, will add the file.
133+
134+
```JavaScript
135+
```
136+
137+
#### Add a file from a URL to IPFS
138+
139+
> `ipfs.util.urlAdd(url, callback)`
140+
141+
```JavaScript
142+
```
143+
144+
#### Add a file from a stream to IPFS
145+
146+
> `ipfs.util.streamAdd(stream, callback)`
147+
148+
This is very similar to `ipfs.files.add({path:'', content: stream})`. It is like the reverse of cat
149+
150+
```JavaScript
151+
```
152+
153+
154+
121155
## Contribute
122156

123-
The js-ipfs API is a work in progress. As such, there's a few things you can do right now to help out:
157+
The js-ipfs-api is a work in progress. As such, there's a few things you can do right now to help out:
124158

125159
* **[Check out the existing issues](https://github.com/ipfs/js-ipfs-api/issues)**!
126160
* **Perform code reviews**. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
@@ -131,6 +165,10 @@ The js-ipfs API is a work in progress. As such, there's a few things you can do
131165

132166
[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md)
133167

168+
## Historical context
169+
170+
This module started as a direct mapping from the go-ipfs cli to a JavaScript implementation, although this was useful and familiar to a lot of developers that were coming to IPFS for the first time, it also created some confusion on how to operate the core of IPFS and have access to the full capacity of the protocol. After much consideration, we decided to create `interface-ipfs-core` with the goal of standardizing the interface of a core implementation of IPFS, and keep the utility functions the IPFS community learned to use and love, such as reading files from disk and storing them directly to IPFS.
171+
134172
## License
135173

136174
[MIT](LICENSE)

package.json

+15-14
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,20 @@
22
"name": "ipfs-api",
33
"version": "6.0.3",
44
"description": "A client library for the IPFS API",
5-
"main": "lib/index.js",
5+
"main": "src/index.js",
66
"jsnext:main": "src/index.js",
7+
"scripts": {
8+
"test": "gulp test",
9+
"test:node": "gulp test:node",
10+
"test:browser": "gulp test:browser",
11+
"lint": "aegir-lint",
12+
"build": "gulp build",
13+
"release": "gulp release",
14+
"release-minor": "gulp release --type minor",
15+
"release-major": "gulp release --type major",
16+
"coverage": "gulp coverage",
17+
"coverage-publish": "aegir-coverage publish"
18+
},
719
"dependencies": {
820
"async": "^2.0.0-rc.5",
921
"babel-runtime": "^6.6.1",
@@ -20,6 +32,7 @@
2032
"ndjson": "^1.4.3",
2133
"promisify-es6": "^1.0.1",
2234
"qs": "^6.1.0",
35+
"streamifier": "^0.1.1",
2336
"wreck": "^7.0.2"
2437
},
2538
"engines": {
@@ -40,18 +53,6 @@
4053
"stream-http": "^2.2.0",
4154
"streamifier": "^0.1.1"
4255
},
43-
"scripts": {
44-
"test": "gulp test",
45-
"test:node": "gulp test:node",
46-
"test:browser": "gulp test:browser",
47-
"lint": "aegir-lint",
48-
"build": "gulp build",
49-
"release": "gulp release",
50-
"release-minor": "gulp release --type minor",
51-
"release-major": "gulp release --type major",
52-
"coverage": "gulp coverage",
53-
"coverage-publish": "aegir-coverage publish"
54-
},
5556
"pre-commit": [
5657
"lint",
5758
"test"
@@ -94,4 +95,4 @@
9495
"url": "https://github.com/ipfs/js-ipfs-api/issues"
9596
},
9697
"homepage": "https://github.com/ipfs/js-ipfs-api"
97-
}
98+
}

0 commit comments

Comments
 (0)