diff --git a/content/reference/api/http.md b/content/reference/api/http.md index e04e743..948a74d 100644 --- a/content/reference/api/http.md +++ b/content/reference/api/http.md @@ -9,7 +9,7 @@ menu: -Generated on 2019-06-22, from go-ipfs v0.4.21. +Generated on 2019-11-05, from go-ipfs v0.4.22. When an IPFS node is running as a daemon, it exposes an HTTP API that allows you to control the node and run the same commands you can from the command @@ -20,17 +20,21 @@ your program — it allows you to maintain peer connections that are longer lived than your app and you can keep a single IPFS node running instead of several if your app can be launched multiple times. In fact, the `ipfs` CLI commands use this API when operating in [online mode]({{< relref -"usage.md#going-online" >}}). +"usage.md#taking-your-node-online" >}}). -This document is autogenerated from go-ipfs. For issues and support, check out -the [ipfs-http-api-docs](https://github.com/ipfs/ipfs-http-api-docs) -repository on GitHub. + -## Getting started +## Getting Started ### Alignment with CLI Commands -[Every command](../commands/) usable from the CLI is also available through +The HTTP API under `/api/v0/` is an RPC-style API over HTTP, not a REST API. + +[Every command]({{< relref "cli.md" >}}) usable from the CLI is also available through the HTTP API. For example: ```sh > ipfs swarm peers @@ -87,6 +91,19 @@ flag is the `&encoding=json` query parameter below: } ``` +### HTTP Status Codes + +Status codes used at the RPC layer are simple: + +* `500` - RPC endpoint returned an error +* `404` - RPC endpoint doesn't exist +* `400` - Malformed RPC, argument type error, etc +* `403` - RPC call forbidden + +In other words, `500` means that the function _does_ exist, it just failed internally for some reason. To know that reason, you have to look at the "application layer" error (commands lib error). + +## HTTP Commands + ### /api/v0/add Add a file or directory to ipfs.