@@ -61,12 +61,49 @@ If are using this module in a browser with something like browserify, then you w
61
61
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin " [\" http://example.com\" ]"
62
62
```
63
63
64
- ## API
64
+ ## Usage
65
65
66
- ### Level 1 Commands
67
- Level 1 commands are simple commands
66
+ 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/blob/ipfs/api/api/core/README.md )
68
67
69
- #### add
68
+ 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: https://github.com/ipfs/js-ipfs-api/tree/master/test/api
69
+
70
+ ### Core
71
+
72
+ ##### Block
73
+
74
+ ##### Object
75
+
76
+ ** Curl**
77
+ ``` sh
78
+ curl ' http://localhost:5001/api/v0/object/get?arg=QmYEqnfCZp7a39Gxrgyv3qRS4MoCTGjegKV6zroU3Rvr52&stream-channels=true' --compressed
79
+ ```
80
+
81
+ ** Response**
82
+ ``` js
83
+ {
84
+ Links: [{
85
+ Name: string,
86
+ Hash: string,
87
+ Size: number
88
+ }, ... ],
89
+ Data: string
90
+ }
91
+ ```
92
+ * Data is base64 encoded.*
93
+
94
+ ##### Pin
95
+
96
+
97
+ -------------------------------------------------------
98
+
99
+ ### Extensions
100
+
101
+
102
+ -------------------------------------------------------
103
+
104
+ ### Tooling
105
+
106
+ ##### add
70
107
71
108
Add a file (where file is any data) to ipfs returning the hash and name. The
72
109
name value will only be set if you are actually sending a file. A single or
@@ -83,6 +120,7 @@ ipfs.add(files, function(err, res) {
83
120
})
84
121
})
85
122
```
123
+
86
124
` files ` can be a mixed array of filenames or buffers of data. A single value is
87
125
also acceptable.
88
126
@@ -111,11 +149,12 @@ curl 'http://localhost:5001/api/v0/add?stream-channels=true' \
111
149
112
150
113
151
114
- #### cat
152
+ ##### cat
115
153
116
154
Retrieve the contents of a single hash, or array of hashes.
117
155
118
156
** Usage**
157
+
119
158
``` javascript
120
159
ipfs .cat (hashs, function (err , res ) {
121
160
if (err || ! res) return console .error (err)
@@ -131,6 +170,7 @@ ipfs.cat(hashs, function(err, res) {
131
170
```
132
171
133
172
** Curl**
173
+
134
174
``` sh
135
175
curl " http://localhost:5001/api/v0/cat?arg=<hash>&stream-channels=true"
136
176
```
@@ -139,7 +179,7 @@ curl "http://localhost:5001/api/v0/cat?arg=<hash>&stream-channels=true"
139
179
140
180
The response is either a readable stream, or a string.
141
181
142
- #### ls
182
+ ##### ls
143
183
Get the node structure of a hash. Included in it is a hash and array to links.
144
184
145
185
** Usage**
@@ -179,46 +219,12 @@ curl "http://localhost:5001/api/v0/ls?arg=<hash>&stream-channels=true"
179
219
}
180
220
```
181
221
222
+ ##### Update
182
223
183
- ** version**
184
-
185
- ** commands**
186
-
187
- ### Level 2 Commands
188
- Level 2 commands are simply named spaced wrapped commands
189
-
190
- #### Config
191
-
192
- #### Update
193
-
194
- #### Mount
195
-
196
- #### Diag
197
-
198
- #### Block
199
-
200
- #### Object
201
-
202
- ** Curl**
203
- ``` sh
204
- curl ' http://localhost:5001/api/v0/object/get?arg=QmYEqnfCZp7a39Gxrgyv3qRS4MoCTGjegKV6zroU3Rvr52&stream-channels=true' --compressed
205
- ```
224
+ -------------------------------------------------------
206
225
207
- ** Response**
208
- ``` js
209
- {
210
- Links: [{
211
- Name: string,
212
- Hash: string,
213
- Size: number
214
- }, ... ],
215
- Data: string
216
- }
217
- ```
218
- * Data is base64 encoded.*
226
+ ### Network
219
227
220
- #### Swarm
221
228
222
- #### Pin
223
229
224
- #### Gateway
230
+ -------------------------------------------------------
0 commit comments