- Agregore IPFS/IPNS Gateway Spec
Responses always have the following headers to allow for cross-origin requests:
Access-Control-Allow-Headers: Content-Type
Access-Control-Allow-Headers: Range
Access-Control-Allow-Headers: User-Agent
Access-Control-Allow-Headers: X-Ipfs-Pin
Access-Control-Allow-Headers: X-Requested-With
Access-Control-Allow-Methods: GET
Access-Control-Allow-Methods: HEAD
Access-Control-Allow-Methods: POST
Access-Control-Allow-Methods: PUT
Access-Control-Allow-Methods: DELETE
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: Content-Range
Access-Control-Expose-Headers: Etag
Access-Control-Expose-Headers: Ipfs-Hash
Access-Control-Expose-Headers: X-Chunked-Output
Access-Control-Expose-Headers: X-Ipfs-Path
Access-Control-Expose-Headers: X-Ipns-Path
Access-Control-Expose-Headers: X-Stream-Output
All CIDs returned from the API are CIDv1. CIDv0 are converted before being included in a response. This API will never output CIDv0. It accepts both in requests.
Some APIs support uploading multiple files in a single request using the multipart/form-data
media type. The client must set Content-Type: multipart/form-data
, and then set the request body to valid form data, as defined by RFC 7578.
The name of the field containing the file data must be file
to be uploaded. Fields with other names will be ignored. The filename desired for each file can be set in the filename part of the Content-Disposition
header inside the form data.
Browser clients can use the FormData API to submit form data requests.
Download IPFS data.
- CID: IPFS CID, v0 and v1 supported
- Ex:
QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG
orbafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354
- Ex:
- path: path to files or directories under the CID if it's a directory
- Ex:
/some/dir/file.txt
- Ex:
Accept: application/json
return a JSON directory listing for directories- No
Accept
header also returns JSON. HTML is returned ifAccept
has any other value.
- No
noResolve
return a directory listing for a directory even if it contains anindex.html
file- E:
/ipfs/.../my/dir?noResolve
- E:
filename=some_filename
explicitly specify the filename- Ex:
https://ipfs.io/ipfs/QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG?filename=hello_world.txt
- When you try to save above page, you browser will use passed
filename
instead of a CID.
- Ex:
download=true
skip browser rendering and trigger immediate "save as" dialog- Ex:
https://ipfs.io/ipfs/QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG?filename=hello_world.txt&download=true
- Ex:
Serves the file at the provided path. If the path leads to a directory, the gateway behaves like a normal webserver, serving index.html
or a directory listing as necessary - subject to the headers and query params listed above.
If the directory path does not end in a /
, a /
is appended and the user is redirected. This helps avoid serving duplicate content from different paths.
Etags and range requests are supported. File mimetypes are detected and set in Content-Type
.
The header X-IPFS-Path
is set to the URL path. IPFS-Hash
is set to CID of the IPFS path provided, this may differ from the CID in the URL path.
The same as GET, but with no response body.
Upload file(s) to IPFS.
X-IPFS-Pin
pin the uploaded file(s) if this header is present
The response body is uploaded, and a 201 Created status code is returned, with the Location
header set to ipfs://<CID>
. The response header IPFS-Hash
is set to the CID of the uploaded content.
Form data is supported, in which case multiple files could be uploaded, and the returned CID would point to a directory containing those files. In this case the URL in the Location
header would end with a /
to indicate it's a directory.
Upload a file to an existing path, such as /ipfs/<CID>/path/to/file.ext
. Form data is supported, in which case the path must point to a directory, such as /ipfs/<CID>/path/to/dir
.
This can also be used to wrap a file in a directory, by using the empty directory CID: /ipfs/bafybeiczsscdsbs7ffqz55asqdf3smv6klcw3gofszvwlyarci47bgf354
.
X-IPFS-Pin
pin the resulting new CID if this header is present
A 201 Created response with the Location
header set to ipfs://<new root CID>[/<path>]
is returned. It ends with a /
if form data was uploaded, which means the path is a directory.
The response header IPFS-Hash
is set to the new root CID that has resulted from the
file(s) upload.
Remove the file or directory at the provided path.
X-IPFS-Pin
pin the new CID that results from deletion if this header is present
A 201 Created response with the Location
header set to ipfs://<new root CID>[/<path>]
is returned. The path in the header is the directory containing the deletion path. So if the path in the URL was /ipfs/<CID>/path/to/file.ext
, the header URL will be to ipfs://<new CID>/path/to/
. Note the ending slash, because the path is a directory.
The response header IPFS-Hash
is set to the new root CID that has resulted from the deletion.
Unpin the provided CID.
200 OK if successful.
Same as GET /ipfs/<CID>[/<path>]
Resolves the IPNS key to an IPFS path, and then returns the same response as /ipfs/
. Also supports resolving custom domains with DNSLink.
The header X-IPFS-Path
is set to the URL path. IPFS-Hash
is set to CID of the IPFS path provided, this may differ from the CID in the URL path. This allows for getting the CID of an IPNS path/key.
Update all or part of the content behind an IPNS name. The new content is pinned, and the previous content is unpinned if it exists.
A valid IPFS path in the format /ipfs/<CID>[/<path>]
. A naked CID is also valid, and so is starting with ipfs://
instead of /ipfs/
.
200 OK if everything went well. The header X-IPNS-Path
is set to the /ipns/<key>[/<path>]
.
The same as POST /ipns/<key>[/<path>]
, but where the response body is the file to be uploaded, not an IPFS path. Multiple files can be uploaded using form data, in which case files will go inside the directory in the path.
Remove content behind an IPNS name. The new content is pinned, and the previous content is unpinned.
200 OK if everything went well.
The header X-IPNS-Path
is set to /ipns/<key>[/<path>]
, with the same path logic as above.
Does a 302 Found redirect to the actual key address, for example ipns://k2k4r8lm5pakezcj5cvqpik57twe4ds2sxikeue09ju6se765uvk9ilp
. If a path is included, that will be included in the redirect as well. If a key with that name doesn't exist, 404 will be returned.
key=some_name
: Required. This specifies the key you want by name
Creates a key with the provided name, and returns a 201 Created response, with the Location
header set to the key URL, with ending slash: ipns://.../
. If a key with that name already exists, it will return the same redirect with no issues.
key=some_name
: Required. This specifies the key you want by name
This will delete the key with the provided name from the keystore, and unpin the data it points to.
key=some_name
: Required. This specifies the key you want by name
An experimental pubsub API is supported to give users direct access to sending and receiving pubsub messages.
format
: can bejson
,utf8
,base64
, or not specified, which defaults tobase64
. This controls the decoding of pubsub message bytes
If the Accept
header is set to text/event-stream
, the response is an event stream, described below. But otherwise, the response is some JSON information about pubsub. Example:
{
"id": "ExampleIDHere", // Prettified node ID of this node
"topic": "example", // name of pubsub topic
"subscribed": false, // whether the node is already subscribed to the topic or not
}
Event Stream
The response is an event stream, so pubsub messages for that topic will be sent to the client as long as the connection remains open.
Pubsub messages are encoded as events like this:
id: FuhB2orEIwE=
data: {"from":"QmfULfLaRtF7Kg3ShjFdiYL97P7eEcyL4PcvQLhkzCPCeG","data":"aGVsbG8=","topics":["test"]}
The "message identifier" of the pubsub message is base64-encoded to form the id:
. data:
is always encoded as JSON, with the other three things known about a pubsub message.
In the JSON: from
is the prettified ID of the node who sent the message, data
is the message data, and topics
is an array of topics this message was sent to.
In the JSON, data
is either a JSON object, a string, or bytes base64-encoded into a string. This behaviour depends on the format parameter mentioned above.
Errors are also sent as events in the stream:
data: something failed blah blah
event: error
Errors with decoding the message bytes into the desired format
are represented with the type error-decode
:
event: error-decode
data: not valid UTF-8
This will return the same headers as any GET pubsub request. This API call will work on /pubsub/
and any path below it, and will always return the same headers.
Send a pubsub message, with a maximum size of 1 MiB. Anything larger is rejected with status code 413.