From ec365ca53d257a01f9906920eb9d5938ba264d3e Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Fri, 5 Feb 2016 12:20:23 -0500 Subject: [PATCH 1/2] Added group `cat` --- apiary.apib | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) diff --git a/apiary.apib b/apiary.apib index 8c7ffb9..5251f9c 100644 --- a/apiary.apib +++ b/apiary.apib @@ -1338,6 +1338,170 @@ Outputs the list of peers that were removed. # Group cat +Show IPFS object data + +## cat [GET /cat{?arg}] +Retrieves the object named by and outputs the data it contains. + ++ Parameters + + arg (string, required) - The path to the IPFS object or objects to be outputted + ++ Response 200 + + + Headers + + ``` + Transfer-Encoding: chunked + X-Stream-Output: 1 + ``` + ++ Request Without Arguments + + #### curl + + curl -i "http://localhost:5001/api/v0/cat" + + + Body + + ``` + curl -i "http://localhost:5001/api/v0/cat" + ``` + ++ Response 400 + + + Headers + + ``` + Date: Fri, 05 Feb 2016 17:14:24 GMT + Content-Length: 32 + Content-Type: text/plain; charset=utf-8 + ``` + + + Attributes (string) + + + Body + + ``` + Argument 'ipfs-path' is required + ``` + ++ Request With Empty Argument + + The response is the same if there is an invalid argument. For example: + + curl -i "http://localhost:5001/api/v0/cat?arg=kitten" + + #### curl + + curl -i "http://localhost:5001/api/v0/cat?arg=" + + + Body + + ``` + curl -i "http://localhost:5001/api/v0/cat?arg=" + ``` + ++ Response 500 + + + Headers + + ``` + Content-Type: application/json + Trailer: X-Stream-Error + Transfer-Encoding: chunked + Date: Fri, 05 Feb 2016 17:14:49 GMT + Transfer-Encoding: chunked + ``` + + + Attributes (Error) + - Message: "invalid ipfs ref path" + - Code: 0 + + + Body + + ``` + { + "Message": "invalid ipfs ref path", + "Code": 0 + } + ``` + ++ Request With Valid Argument But Invalid DAG Node + + The multihash in this request is for a directory, not for an object. + + #### curl + + curl -i "http://localhost:5001/api/v0/cat?arg=QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ" + + + Body + + ``` + curl -i "http://localhost:5001/api/v0/cat?arg=QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ" + ``` + ++ Response 500 + + + Headers + + ``` + Content-Type: application/json + Trailer: X-Stream-Error + Transfer-Encoding: chunked + Date: Fri, 05 Feb 2016 17:16:07 GMT + Transfer-Encoding: chunked + ``` + + + Attributes (Error) + - Message: "this dag node is a directory" + - Code: 0 + + + Body + + ``` + { + "Message": "this dag node is a directory", + "Code": 0 + } + ++ Request With Valid Argument + + In this request, 'QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o' is the hash for a file, 'test', + with the following contents + + hello world + + #### curl + + curl -i "http://localhost:5001/api/v0/cat?arg=QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o" + + + Body + + ``` + curl -i "http://localhost:5001/api/v0/cat?arg=QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o" + ``` + ++ Response 200 + + + Headers + + ``` + Content-Type: text/plain + Trailer: X-Stream-Error + Transfer-Encoding: chunked + X-Stream-Output: 1 + Date: Fri, 05 Feb 2016 17:18:10 GMT + Transfer-Encoding: chunked + ``` + + + Attributes (string) + + + Body + + ``` + hello world + ``` + # Group commands # Group config From cf6f4c27d62976826d0004034f73f79cfb8ab498 Mon Sep 17 00:00:00 2001 From: Richard Littauer Date: Wed, 17 Feb 2016 13:49:16 -0500 Subject: [PATCH 2/2] Added periods, removed errant response, added Attr desc --- apiary.apib | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/apiary.apib b/apiary.apib index 5251f9c..6f74565 100644 --- a/apiary.apib +++ b/apiary.apib @@ -646,7 +646,9 @@ Stores input as an IPFS block In the example provided, the 'test' file has the following contents: + ``` hello world + ``` #### curl @@ -1338,22 +1340,13 @@ Outputs the list of peers that were removed. # Group cat -Show IPFS object data +Show IPFS object data. ## cat [GET /cat{?arg}] Retrieves the object named by and outputs the data it contains. + Parameters - + arg (string, required) - The path to the IPFS object or objects to be outputted - -+ Response 200 - - + Headers - - ``` - Transfer-Encoding: chunked - X-Stream-Output: 1 - ``` + + arg (string, required) - The path to the IPFS object or objects to be outputted. + Request Without Arguments @@ -1379,6 +1372,8 @@ Retrieves the object named by and outputs the data it contai + Attributes (string) + This is the raw content of the file. + + Body ``` @@ -1463,13 +1458,16 @@ Retrieves the object named by and outputs the data it contai "Message": "this dag node is a directory", "Code": 0 } + ``` + Request With Valid Argument In this request, 'QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o' is the hash for a file, 'test', with the following contents + ``` hello world + ``` #### curl