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

Commit 173d97a

Browse files
committed
Edited API.md, removed Callbacks and put it into README.md, Filled out Contribute, fixed a couple of grammar things
Related to #152
1 parent 0b70872 commit 173d97a

File tree

3 files changed

+48
-32
lines changed

3 files changed

+48
-32
lines changed

API.md

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
33
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
44

5-
- [API](#api)
6-
- [Callbacks and promises](#callbacks-and-promises)
7-
- [Reference](#reference)
8-
- [Core](#core)
5+
- [API Reference](#api-reference)
6+
- [Core](#core)
97
- [`version([callback])`](#versioncallback)
108
- [`id([callback])`](#idcallback)
119
- [`block`](#block)
@@ -32,7 +30,7 @@
3230
- [`pin.list(hash, options, [callback])`](#pinlisthash-options-callback)
3331
- [`log`](#log)
3432
- [`log.tail([callback])`](#logtailcallback)
35-
- [Extensions](#extensions)
33+
- [Extensions](#extensions)
3634
- [`add(arrayOrBufferOrStream, [callback])`](#addarrayorbufferorstream-callback)
3735
- [`name`](#name)
3836
- [`name.publish(hash, [callback])`](#namepublishhash-callback)
@@ -47,7 +45,7 @@
4745
- [`files.write(file, bufferOrArray, [options, callback])`](#fileswritefile-bufferorarray-options-callback)
4846
- [`files.mv(src, target, [callback])`](#filesmvsrc-target-callback)
4947
- [`mount(ipfs, ipns, [callback])`](#mountipfs-ipns-callback)
50-
- [Tooling](#tooling)
48+
- [Tooling](#tooling)
5149
- [`commands([callback])`](#commandscallback)
5250
- [`update`](#update)
5351
- [`update.apply([callback])`](#updateapplycallback)
@@ -57,7 +55,7 @@
5755
- [`diag.net([callback])`](#diagnetcallback)
5856
- [`diag.sys([callback])`](#diagsyscallback)
5957
- [`diag.cmds([callback])`](#diagcmdscallback)
60-
- [Network](#network)
58+
- [Network](#network)
6159
- [`ping(id, [callback])`](#pingid-callback)
6260
- [`dht`](#dht)
6361
- [`dht.findprovs([callback])`](#dhtfindprovscallback)
@@ -69,30 +67,13 @@
6967

7068
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
7169

72-
# API
70+
# API Reference
7371

7472
We classify the API calls by 'core', 'extensions', 'tooling', and 'network', following the same API spec organization available at [ipfs/specs](https://github.com/ipfs/specs/tree/master/api).
7573

7674
The tests folder also contains great examples that can be used to understand how this client library interacts with the HTTP-API. You can find the [tests here](test/api).
7775

78-
79-
## Callbacks and promises
80-
81-
If you do not pass in a callback all api functions will return a `Promise`, for example
82-
83-
```js
84-
ipfs.id()
85-
.then(function (id) {
86-
console.log('my id is: ', id)
87-
})
88-
```
89-
90-
This relies on a global `Promise` object. If you are in an environemnt where that is not
91-
yet available you need to bring your own polyfill.
92-
93-
## Reference
94-
95-
### Core
76+
## Core
9677

9778
#### `version([callback])`
9879

@@ -149,7 +130,7 @@ yet available you need to bring your own polyfill.
149130

150131
##### `log.tail([callback])`
151132

152-
### Extensions
133+
## Extensions
153134

154135
#### `add(arrayOrBufferOrStream, [callback])`
155136

@@ -179,7 +160,7 @@ yet available you need to bring your own polyfill.
179160

180161
- [tests](test/api/mount.spec.js)
181162

182-
### Tooling
163+
## Tooling
183164

184165
#### `commands([callback])`
185166

@@ -201,7 +182,7 @@ yet available you need to bring your own polyfill.
201182
##### `diag.sys([callback])`
202183
##### `diag.cmds([callback])`
203184

204-
### Network
185+
## Network
205186

206187
#### `ping(id, [callback])`
207188

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ You should have [node.js], [npm] and [gulp] installed.
66

77
## Linting
88

9-
Linting is done using [eslint] and the rules are based on [standard]
9+
Linting is done using [eslint] and the rules are based on [standard].
1010

1111
```bash
1212
$ gulp lint

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ IPFS API wrapper library in JavaScript
1818
$ npm install --save ipfs-api
1919
```
2020

21+
#### Running the daemon with the right port
22+
23+
To interact with the API, you need to have a local daemon running (at the moment; we have plans to make it work independently). It needs to be open on the right port: `5001`. This is the default.
24+
25+
```sh
26+
# Show the ipfs config API port to check it is correct
27+
$ ipfs config Addresses.API
28+
/ip4/127.0.0.1/tcp/5001
29+
# Set it if it does not match the above output
30+
$ ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001
31+
# Restart the daemon after changing the config
32+
33+
# Run the daemon
34+
$ ipfs daemon
35+
```
36+
37+
#### Importing the module and usage
38+
2139
```javascript
2240
var ipfsAPI = require('ipfs-api')
2341

@@ -67,11 +85,28 @@ $ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://exam
6785

6886
See [API.md](API.md) and [`tests/api`](test/api) for details on available methods.
6987

88+
### Callbacks and promises
89+
90+
If you do not pass in a callback all API functions will return a `Promise`. For example:
91+
92+
```js
93+
ipfs.id()
94+
.then(function (id) {
95+
console.log('my id is: ', id)
96+
})
97+
```
98+
99+
This relies on a global `Promise` object. If you are in an environment where that is not
100+
yet available you need to bring your own polyfill.
101+
70102
## Contribute
71103

72-
Contributions are welcome! Please check out the [issues](https://github.com/ipfs/js-ipfs-api/issues).
104+
The js-ipfs API is a work in progress. As such, there's a few things you can do right now to help out:
73105

74-
Some general things we always need are more tests. If you can add them, we'll work on making them pass (hopefully with you!).
106+
* **[Check out the existing issues](https://github.com/ipfs/js-ipfs-api/issues)**!
107+
* **Perform code reviews**. More eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
108+
* **Add tests**. There can never be enough tests.
109+
* **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.
75110

76111
## License
77112

0 commit comments

Comments
 (0)