Skip to content

GUI Pipe API

Long Hoang edited this page Feb 13, 2017 · 3 revisions

The PeerBackend and Frontend is communicating via stdin / stdout pipes.

Post new Post

{"command":"postPost", "arguments": {"content": "Life tiny, die never!"}}
{"hash": "QmdFWdZTL5dujL1woPMSe1kpzzTxJdKYpHfL35y5uikkqP"}

Get Post given hash

{"command":"getPost", "arguments": {"hash": "QmdFWdZTL5dujL1woPMSe1kpzzTxJdKYpHfL35y5uikkqP"}}
{
   "Alias":"Long",
   "Content":"Life tiny, die never!",
   "Timestamp":1486967871,
   "Hash":"QmS2LEajk9jBm9YRnKMz3ukchmcWymF89d4MFpezYBBCMm",
   "Key":"TODO",
   "UserData":{
      "Score":11,
      "Flagged":false
   }
}

Get all posts

{"command":"getPosts"}
[
   {
      "Alias":"Long",
      "Content":"Life tiny, die never!",
      "Timestamp":1486967871,
      "Hash":"QmS2LEajk9jBm9YRnKMz3ukchmcWymF89d4MFpezYBBCMm",
      "Key":"TODO",
      "UserData":{
         "Score":11,
         "Flagged":false
      }
   },
   {
      "Alias":"Long",
      "Content":"Life tiny, die never!",
      "Timestamp":1486997097,
      "Hash":"QmeyRdWCpeReyUdfcyMiaXEBJbZvvUwe5BFroTHZ1Lh9k4",
      "Key":"TODO",
      "UserData":{
         "Score":0,
         "Flagged":false
      }
   }
]

Post new Comment to Post

{
   "command":"postComment",
   "arguments":{
      "post":"QmdFWdZTL5dujL1woPMSe1kpzzTxJdKYpHfL35y5uikkqP",
      "content":"Tardigrades FTW",
      "parent":"QmdFWdZTL5dujL1woPMSe1kpzzTxJdKYpHfL35y5uikkqP"
   }
}
{"hash": "QmTjyYMFaK3Djsm2Aaezy3FoFBHCnHpo6stMRTE6x9F4Gm"}

Post new Comment on reply to another Comment

Note that parent hash refers to the comment it replies to, while post hash still refers to the same post.

{
   "command":"postComment",
   "arguments":{
      "post":"QmdFWdZTL5dujL1woPMSe1kpzzTxJdKYpHfL35y5uikkqP",
      "content":"I agree that Tardigrades are amazing!",
      "parent":"QmTjyYMFaK3Djsm2Aaezy3FoFBHCnHpo6stMRTE6x9F4Gm"
   }
}
{"hash": "QmTdhGNVMQq83S8Ns2XZFaRNuzkrVC4rtBdWniKTZTjwhd"}

Get all comments of a post

{"command":"getCommentsFromPost", "arguments": {"hash": "QmdFWdZTL5dujL1woPMSe1kpzzTxJdKYpHfL35y5uikkqP"}}
[
   {
      "Post":"QmdFWdZTL5dujL1woPMSe1kpzzTxJdKYpHfL35y5uikkqP",
      "Parent":"QmdFWdZTL5dujL1woPMSe1kpzzTxJdKYpHfL35y5uikkqP",
      "Alias":"Long",
      "Content":"Tardigrades FTW",
      "Timestamp":1486890516,
      "Hash":"QmTjyYMFaK3Djsm2Aaezy3FoFBHCnHpo6stMRTE6x9F4Gm",
      "Key":"TODO"
   },
   {
      "Post":"QmdFWdZTL5dujL1woPMSe1kpzzTxJdKYpHfL35y5uikkqP",
      "Parent":"QmTjyYMFaK3Djsm2Aaezy3FoFBHCnHpo6stMRTE6x9F4Gm",
      "Alias":"Long",
      "Content":"I agree that Tardigrades are amazing!",
      "Timestamp":1486890532,
      "Hash":"QmTdhGNVMQq83S8Ns2XZFaRNuzkrVC4rtBdWniKTZTjwhd",
      "Key":"TODO"
   }
]

Change UserData of Post and Comment

E.g. change score to 4711 and change flagged status

{
   "command":"setPostUserData",
   "arguments":{
      "hash":"QmS2LEajk9jBm9YRnKMz3ukchmcWymF89d4MFpezYBBCMm",
      "UserData":{
         "Score":4711,
         "Flagged":true
      }
   }
}
{"status": "success"}

Note: Works similarly for Comments, just use setCommentUserData as command