From fd4646474e7866638f29291de6a552436aaa89cf Mon Sep 17 00:00:00 2001 From: Jessica Schilling Date: Tue, 5 Nov 2019 13:56:44 -0700 Subject: [PATCH] Update api.md Added changes from https://github.com/ipfs/docs/pull/368 --- docs/reference/http/api.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/reference/http/api.md b/docs/reference/http/api.md index 602db528a..10e2d8e00 100644 --- a/docs/reference/http/api.md +++ b/docs/reference/http/api.md @@ -7,7 +7,7 @@ title: HTTP API -_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 @@ -17,17 +17,19 @@ In many cases, using this API this is preferable to embedding IPFS directly in 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](usage.md#going-online). +CLI commands use this API when operating in online mode. -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. +::: tip +This document was autogenerated from go-ipfs. For issues and support, check out the [a href="https://github.com/ipfs/ipfs-http-api-docs](ipfs-http-api-docs) repository on GitHub. +::: ## 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](/reference/cli/) usable from the CLI is also available through the HTTP API. For example: ```sh @@ -85,6 +87,16 @@ 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.