Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit b7b24b8

Browse files
committed
docs: consolidate API docs and update readme files
Moves api docs into `/docs` folder similarly to how js-libp2p has organised their docs. Tries to trim readmes down a bit to make them more digestible and adds links to futher information on different topics. Also reinstates dependency statuses.
1 parent 8c97de1 commit b7b24b8

34 files changed

+826
-929
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ node_modules
1818
# Build artefacts
1919
dist
2020

21-
# Doc generation
22-
docs
23-
2421
# Deployment files
2522
.npmrc
2623

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ We've come a long way, but this project is still in Alpha, lots of development i
4343

4444
## Lead Maintainer <!-- omit in toc -->
4545

46-
[Alan Shaw](https://github.com/alanshaw)
46+
[Alex Potsides](http://github.com/achingbrain)
4747

4848
## Table of Contents <!-- omit in toc -->
4949

@@ -66,9 +66,7 @@ This project is broken into several modules, their purposes are:
6666
* [`/packages/ipfs`](./packages/ipfs) The core implementation
6767
* [`/packages/ipfs-http-client`](./packages/ipfs-http-client) A client for the RPC-over-HTTP API presented by both js-ipfs and go-ipfs
6868
* [`/packages/interface-ipfs-core`](./packages/interface-ipfs-core) Tests to ensure adherance of an implementation to the spec
69-
* [`/packages/ipfs-utils`](./packages/ipfs-utils) Helpers and utilities common to core and the HTTP RPC API client
70-
* [`/packages/ipfs-mfs`](./packages/ipfs-mfs) The mfs implementation
71-
* [`/packages/ipfs-multipart`](./packages/ipfs-multipart) A module that handles adding files via multipart HTTP requests for core and the mfs
69+
* [`/packages/ipfs-core-utils`](./packages/ipfs-core-utils) Helpers and utilities common to core and the HTTP RPC API client
7270

7371
## Development
7472

docs/API.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# API <!-- omit in toc -->
2+
3+
`ipfs` can run as part of your program (an in-process node) or as a standalone daemon process that can be communicated with via an HTTP RPC API using the [`ipfs-http-client`](../packages/ipfs-http-api) module.
4+
5+
The http client module can be used to control either a `go-ipfs` or a `js-ipfs` daemon, though the amount of the API implemented in each language varies.
6+
7+
Whether accessed directly or over HTTP, both methods support the full [Core API](#core-api). In addition other methods are available to construct instances of each module, etc.
8+
9+
## Table of Contents <!-- omit in toc -->
10+
11+
- [Core API](#core-api)
12+
- [ipfs module](#ipfs-module)
13+
- [ipfs-http-client module](#ipfs-http-client-module)
14+
- [Additional Options](#additional-options)
15+
- [Instance Utils](#instance-utils)
16+
- [Static Types and Utils](#static-types-and-utils)
17+
- [Glob source](#glob-source)
18+
- [`globSource(path, [options])`](#globsourcepath-options)
19+
- [Example](#example)
20+
- [URL source](#url-source)
21+
- [`urlSource(url)`](#urlsourceurl)
22+
- [Example](#example-1)
23+
24+
## Core API
25+
26+
The Core API defines the set of operations that are possible to do with an IPFS node.
27+
28+
It is broken up into the following sections:
29+
30+
* [BITSWAP.md](api/BITSWAP.md)
31+
* [BLOCK.md](api/BLOCK.md)
32+
* [BOOTSTRAP.md](api/BOOTSTRAP.md)
33+
* [CONFIG.md]([api/CONFIG.md)
34+
* [DAG.md](api/DAG.md)
35+
* [DHT.md](api/DHT.md)
36+
* [FILES.md](api/FILES.md)
37+
* [KEY.md](api/KEY.md)
38+
* [MISCELLANEOUS.md](api/MISCELLANEOUS.md)
39+
* [NAME.md](api/NAME.md)
40+
* [OBJECT.md](api/OBJECT.md)
41+
* [PIN.md](api/PIN.md)
42+
* [PUBSUB.md](api/PUBSUB.md)
43+
* [REFS.md](api/REFS.md)
44+
* [STATS.md](api/STATS.md)
45+
* [SWARM.md](api/SWARM.md)
46+
47+
## ipfs module
48+
49+
See [IPFS.md](./IPFS.md) for constructor details and instance methods not part of the Core API.
50+
51+
## ipfs-http-client module
52+
53+
These are functions not in the [Core API](#core-api) but that are specific to [`ipfs-http-client`](../packages/ipfs-http-client).
54+
55+
### Additional Options
56+
57+
All core API methods take _additional_ `options` specific to the HTTP API:
58+
59+
* `headers` - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options.
60+
* `signal` - An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) that can be used to abort the request on demand.
61+
* `timeout` - A number or string specifying a timeout for the request. If the timeout is reached before data is received a [`TimeoutError`](https://github.com/sindresorhus/ky/blob/2f37c3f999efb36db9108893b8b3d4b3a7f5ec45/index.js#L127-L132) is thrown. If a number is specified it is interpreted as milliseconds, if a string is passed, it is intepreted according to [`parse-duration`](https://www.npmjs.com/package/parse-duration). Note that this option can also be [configured globally](#global-timeouts) via the constructor options.
62+
* `searchParams` - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request.
63+
64+
### Instance Utils
65+
66+
- `ipfs.getEndpointConfig()`
67+
68+
Call this on your client instance to return an object containing the `host`, `port`, `protocol` and `api-path`.
69+
70+
### Static Types and Utils
71+
72+
Aside from the default export, `ipfs-http-client` exports various types and utilities that are included in the bundle:
73+
74+
- [`Buffer`](https://www.npmjs.com/package/buffer)
75+
- [`multiaddr`](https://www.npmjs.com/package/multiaddr)
76+
- [`multibase`](https://www.npmjs.com/package/multibase)
77+
- [`multicodec`](https://www.npmjs.com/package/multicodec)
78+
- [`multihash`](https://www.npmjs.com/package/multihashes)
79+
- [`CID`](https://www.npmjs.com/package/cids)
80+
- [`globSource`](https://github.com/ipfs/js-ipfs-utils/blob/master/src/files/glob-source.js) (not available in the browser)
81+
- [`urlSource`](https://github.com/ipfs/js-ipfs-utils/blob/master/src/files/url-source.js)
82+
83+
These can be accessed like this, for example:
84+
85+
```js
86+
const { CID } = require('ipfs-http-client')
87+
// ...or from an es-module:
88+
import { CID } from 'ipfs-http-client'
89+
```
90+
91+
#### Glob source
92+
93+
A utility to allow files on the file system to be easily added to IPFS.
94+
95+
##### `globSource(path, [options])`
96+
97+
- `path`: A path to a single file or directory to glob from
98+
- `options`: Optional options
99+
- `options.recursive`: If `path` is a directory, use option `{ recursive: true }` to add the directory and all its sub-directories.
100+
- `options.ignore`: To exclude file globs from the directory, use option `{ ignore: ['ignore/this/folder/**', 'and/this/file'] }`.
101+
- `options.hidden`: Hidden/dot files (files or folders starting with a `.`, for example, `.git/`) are not included by default. To add them, use the option `{ hidden: true }`.
102+
103+
Returns an async iterable that yields `{ path, content }` objects suitable for passing to `ipfs.add`.
104+
105+
##### Example
106+
107+
```js
108+
const IpfsHttpClient = require('ipfs-http-client')
109+
const { globSource } = IpfsHttpClient
110+
const ipfs = IpfsHttpClient()
111+
112+
for await (const file of ipfs.add(globSource('./docs', { recursive: true }))) {
113+
console.log(file)
114+
}
115+
/*
116+
{
117+
path: 'docs/assets/anchor.js',
118+
cid: CID('QmVHxRocoWgUChLEvfEyDuuD6qJ4PhdDL2dTLcpUy3dSC2'),
119+
size: 15347
120+
}
121+
{
122+
path: 'docs/assets/bass-addons.css',
123+
cid: CID('QmPiLWKd6yseMWDTgHegb8T7wVS7zWGYgyvfj7dGNt2viQ'),
124+
size: 232
125+
}
126+
...
127+
*/
128+
```
129+
130+
#### URL source
131+
132+
A utility to allow content from the internet to be easily added to IPFS.
133+
134+
##### `urlSource(url)`
135+
136+
- `url`: A string URL or [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) instance to send HTTP GET request to
137+
138+
Returns an async iterable that yields `{ path, content }` objects suitable for passing to `ipfs.add`.
139+
140+
##### Example
141+
142+
```js
143+
const IpfsHttpClient = require('ipfs-http-client')
144+
const { urlSource } = IpfsHttpClient
145+
const ipfs = IpfsHttpClient()
146+
147+
for await (const file of ipfs.add(urlSource('https://ipfs.io/images/ipfs-logo.svg'))) {
148+
console.log(file)
149+
}
150+
/*
151+
{
152+
path: 'ipfs-logo.svg',
153+
cid: CID('QmTqZhR6f7jzdhLgPArDPnsbZpvvgxzCZycXK7ywkLxSyU'),
154+
size: 3243
155+
}
156+
*/
157+
```
File renamed without changes.
File renamed without changes.
File renamed without changes.

docs/IPFS-HTTP-CLIENT.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# ipfs-http-client module <!-- omit in toc -->
2+
3+
These are functions not in the [Core API](#core-api) but that are specific to [`ipfs-http-client`](../packages/ipfs-http-client).
4+
5+
## Table of contents <!-- omit in toc -->
6+
7+
- [Additional Options](#additional-options)
8+
- [Instance Utils](#instance-utils)
9+
- [Static Types and Utils](#static-types-and-utils)
10+
- [Glob source](#glob-source)
11+
- [`globSource(path, [options])`](#globsourcepath-options)
12+
- [Example](#example)
13+
- [URL source](#url-source)
14+
- [`urlSource(url)`](#urlsourceurl)
15+
- [Example](#example-1)
16+
17+
## Additional Options
18+
19+
All core API methods take _additional_ `options` specific to the HTTP API:
20+
21+
* `headers` - An object or [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers) instance that can be used to set custom HTTP headers. Note that this option can also be [configured globally](#custom-headers) via the constructor options.
22+
* `signal` - An [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) that can be used to abort the request on demand.
23+
* `timeout` - A number or string specifying a timeout for the request. If the timeout is reached before data is received a [`TimeoutError`](https://github.com/sindresorhus/ky/blob/2f37c3f999efb36db9108893b8b3d4b3a7f5ec45/index.js#L127-L132) is thrown. If a number is specified it is interpreted as milliseconds, if a string is passed, it is intepreted according to [`parse-duration`](https://www.npmjs.com/package/parse-duration). Note that this option can also be [configured globally](#global-timeouts) via the constructor options.
24+
* `searchParams` - An object or [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) instance that can be used to add additional query parameters to the query string sent with each request.
25+
26+
## Instance Utils
27+
28+
- `ipfs.getEndpointConfig()`
29+
30+
Call this on your client instance to return an object containing the `host`, `port`, `protocol` and `api-path`.
31+
32+
## Static Types and Utils
33+
34+
Aside from the default export, `ipfs-http-client` exports various types and utilities that are included in the bundle:
35+
36+
- [`Buffer`](https://www.npmjs.com/package/buffer)
37+
- [`multiaddr`](https://www.npmjs.com/package/multiaddr)
38+
- [`multibase`](https://www.npmjs.com/package/multibase)
39+
- [`multicodec`](https://www.npmjs.com/package/multicodec)
40+
- [`multihash`](https://www.npmjs.com/package/multihashes)
41+
- [`CID`](https://www.npmjs.com/package/cids)
42+
- [`globSource`](https://github.com/ipfs/js-ipfs-utils/blob/master/src/files/glob-source.js) (not available in the browser)
43+
- [`urlSource`](https://github.com/ipfs/js-ipfs-utils/blob/master/src/files/url-source.js)
44+
45+
These can be accessed like this, for example:
46+
47+
```js
48+
const { CID } = require('ipfs-http-client')
49+
// ...or from an es-module:
50+
import { CID } from 'ipfs-http-client'
51+
```
52+
53+
### Glob source
54+
55+
A utility to allow files on the file system to be easily added to IPFS.
56+
57+
#### `globSource(path, [options])`
58+
59+
- `path`: A path to a single file or directory to glob from
60+
- `options`: Optional options
61+
- `options.recursive`: If `path` is a directory, use option `{ recursive: true }` to add the directory and all its sub-directories.
62+
- `options.ignore`: To exclude file globs from the directory, use option `{ ignore: ['ignore/this/folder/**', 'and/this/file'] }`.
63+
- `options.hidden`: Hidden/dot files (files or folders starting with a `.`, for example, `.git/`) are not included by default. To add them, use the option `{ hidden: true }`.
64+
65+
Returns an async iterable that yields `{ path, content }` objects suitable for passing to `ipfs.add`.
66+
67+
#### Example
68+
69+
```js
70+
const IpfsHttpClient = require('ipfs-http-client')
71+
const { globSource } = IpfsHttpClient
72+
const ipfs = IpfsHttpClient()
73+
74+
for await (const file of ipfs.add(globSource('./docs', { recursive: true }))) {
75+
console.log(file)
76+
}
77+
/*
78+
{
79+
path: 'docs/assets/anchor.js',
80+
cid: CID('QmVHxRocoWgUChLEvfEyDuuD6qJ4PhdDL2dTLcpUy3dSC2'),
81+
size: 15347
82+
}
83+
{
84+
path: 'docs/assets/bass-addons.css',
85+
cid: CID('QmPiLWKd6yseMWDTgHegb8T7wVS7zWGYgyvfj7dGNt2viQ'),
86+
size: 232
87+
}
88+
...
89+
*/
90+
```
91+
92+
### URL source
93+
94+
A utility to allow content from the internet to be easily added to IPFS.
95+
96+
#### `urlSource(url)`
97+
98+
- `url`: A string URL or [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) instance to send HTTP GET request to
99+
100+
Returns an async iterable that yields `{ path, content }` objects suitable for passing to `ipfs.add`.
101+
102+
#### Example
103+
104+
```js
105+
const IpfsHttpClient = require('ipfs-http-client')
106+
const { urlSource } = IpfsHttpClient
107+
const ipfs = IpfsHttpClient()
108+
109+
for await (const file of ipfs.add(urlSource('https://ipfs.io/images/ipfs-logo.svg'))) {
110+
console.log(file)
111+
}
112+
/*
113+
{
114+
path: 'ipfs-logo.svg',
115+
cid: CID('QmTqZhR6f7jzdhLgPArDPnsbZpvvgxzCZycXK7ywkLxSyU'),
116+
size: 3243
117+
}
118+
*/
119+
```

0 commit comments

Comments
 (0)