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

Commit 07e7ecf

Browse files
committed
Merge pull request #73 from ipfs/feature/spot-check-readme
Edited for readbility, linguist
2 parents 0675696 + 9110232 commit 07e7ecf

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

README.md

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,29 @@ var ipfs = ipfsAPI('localhost', '5001') // leaving out the arguments will defaul
2525

2626
### In the Browser through browserify
2727

28-
Same as in Node.js, you just have to browserify the code before serving it.
28+
Same as in Node.js, you just have to [browserify](https://github.com/substack/node-browserify) the code before serving it. See the browserify repo for how to do that.
2929

3030
### In the Browser through `<script>` tag
3131

32-
Make the [ipfsapi.min.js](/ipfsapi.min.js) available through your server and load it using a normal `<script>` tag, this will exporrt the `ipfsAPI` constructor on the `window` object, such that:
32+
Make the [ipfsapi.min.js](/ipfsapi.min.js) available through your server and load it using a normal `<script>` tag, this will export the `ipfsAPI` constructor on the `window` object, such that:
3333

3434
```
3535
var ipfs = window.ipfsAPI('localhost', '5001')
3636
```
3737

38-
If you omit the host and port, the api will parse window.host, and use this information. I.e, this also works:
38+
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:
3939

4040
```
4141
var ipfs = window.ipfsAPI()
4242
```
4343

44-
This can be useful if you want to write apps that can be run from multiple different gateways.
45-
4644
#### Gotchas
4745

48-
When using the api from script tag for things that require buffers (ipfs.add, for example), you will have to use either the exposed ipfs.Buffer, that works just like a node buffer, or use this [browser buffer](https://github.com/feross/buffer)
46+
When using the api from script tag for things that require buffers (`ipfs.add`, for example), you will have to use either the exposed `ipfs.Buffer`, that works just like a node buffer, or use this [browser buffer](https://github.com/feross/buffer).
4947

5048
## CORS
5149

52-
If are using this module in a browser with something like browserify, then you will get an error saying that the origin is not allowed. This would be a CORS ("Cross Origin Resource Sharing") failure. The ipfs server rejects requests from unknown domains by default. You can whitelist the domain that you are calling from by exporting API_ORIGIN and restarting the daemon, like:
50+
If are using this module in a browser with something like browserify, then you will get an error saying that the origin is not allowed. This would be a CORS ("Cross Origin Resource Sharing") failure. The ipfs server rejects requests from unknown domains by default. You can whitelist the domain that you are calling from by exporting `API_ORIGIN` and restarting the daemon, like:
5351

5452
```bash
5553
export API_ORIGIN="http://localhost:8080"
@@ -82,33 +80,33 @@ ipfs.add(files, function(err, res) {
8280
also acceptable.
8381

8482
Example
85-
```
83+
```js
8684
var files = ["../files/hello.txt", new Buffer("ipfs!")]
8785
var files = "../files/hello.txt"
8886
```
8987

9088
**Curl**
91-
```
89+
```sh
9290
curl 'http://localhost:5001/api/v0/add?stream-channels=true' \
9391
-H 'content-type: multipart/form-data; boundary=a831rwxi1a3gzaorw1w2z49dlsor' \
9492
-H 'Connection: keep-alive' \
9593
--data-binary $'--a831rwxi1a3gzaorw1w2z49dlsor\r\nContent-Type: application/octet-stream\r\nContent-Disposition: file; name="file"; filename="Hello.txt"\r\n\r\nhello--a831rwxi1a3gzaorw1w2z49dlsor--' --compressed
9694
```
9795

9896
**Response**
99-
```
97+
```js
10098
[{
10199
Hash: string,
102100
Name: string
103101
}, ...]
104102
```
105-
*The name value will only be set for actual files*
103+
*The name value will only be set for actual files.*
106104

107105

108106

109107
#### cat
110108

111-
Retrieve the contents of a single, or array of hashes
109+
Retrieve the contents of a single hash, or array of hashes.
112110

113111
**Usage**
114112
```javascript
@@ -126,7 +124,7 @@ ipfs.cat(hashs, function(err, res) {
126124
```
127125

128126
**Curl**
129-
```
127+
```sh
130128
curl "http://localhost:5001/api/v0/cat?arg=<hash>&stream-channels=true"
131129
```
132130

@@ -135,7 +133,7 @@ curl "http://localhost:5001/api/v0/cat?arg=<hash>&stream-channels=true"
135133
The response is either a readable stream, or a string.
136134

137135
#### ls
138-
Get the node structure of a hash, included in it is a hash and array to links.
136+
Get the node structure of a hash. Included in it is a hash and array to links.
139137

140138
**Usage**
141139
```javascript
@@ -153,12 +151,12 @@ ipfs.ls(hashs, function(err, res) {
153151
```
154152

155153
**Curl**
156-
```
154+
```sh
157155
curl "http://localhost:5001/api/v0/ls?arg=<hash>&stream-channels=true"
158156
```
159157

160158
**Response**
161-
```
159+
```js
162160
{
163161
Objects: [
164162
{
@@ -195,21 +193,22 @@ Level 2 commands are simply named spaced wrapped commands
195193
#### Object
196194

197195
**Curl**
198-
```
196+
```sh
199197
curl 'http://localhost:5001/api/v0/object/get?arg=QmYEqnfCZp7a39Gxrgyv3qRS4MoCTGjegKV6zroU3Rvr52&stream-channels=true' --compressed
200198
```
201199

202200
**Response**
203-
```
201+
```js
204202
{
205203
Links: [{
206204
Name: string,
207205
Hash: string,
208206
Size: number
209207
}, ...],
210208
Data: string
209+
}
211210
```
212-
*Data is base64 encoded*
211+
*Data is base64 encoded.*
213212

214213
#### Swarm
215214

0 commit comments

Comments
 (0)