List all posts

Use the .Get() function to get the latest version of each post sorted by most recent

Returns

The function returns an object containing a posts array as well as details on the number of posts and pages returned:

Returned object structure
{ 
  posts: [ { ... }, { ... }, { ... }], 
  pagination_page: 1,
  pagination_total: 3,
  pagination_per_page: 200,
  pagination_item: 'posts'
 }

The "post objects" within the array returned are made of a combination of:

  • the post message object

  • additional details to help reference the original post (original_...)

  • the post.item_content object attributes (type, content, address, time) are merged in at the top level of the post result

Post object in returned array
// Regular Post Message
channel:
time:
chain:
sender:
hash_type:
item_content:
  type:
  address:
  content:
  time:
  ref:
item_hash:
item_type:

// Details from original
original_item_hash
original_signature
original_tx_hash
original_type
original_ref
hash

// item_content object merged in
type:
content:
address:
time:
ref:

// Additional info from server
size:
confirmations:
confirmed:

Usage & Example

import { post } from 'aleph-sdk-ts'

(async() => {
  await post.Get({
    types: 'mytype', 
    pagination: 200,
    page: 1,
    refs: [], 
    addresses: [],
    tags: [],
    hashes: [],
    APIServer: "https://api2.aleph.im"
  })
})()

Required parameters

Optional parameters

No optional parameters are available for this function.

Example: .Get()

GET_POSTS
let response = await post.Get({
    types: 'mytype', 
    pagination: 3,
    page: 1,
    refs: [], 
    addresses: [],
    tags: [],
    hashes: [],
    APIServer: "https://api2.aleph.im"
})

In the response, the item_content object attributes (type, content, address, time) are merged in the post message object to be easily reachable. Item_content is still available in the message object as well.

The original_ fields are here in case you amended the post.

This function retrieves the latest version of all posts. If a post was updated twice after the original version was created, only the last updated post will show.

To see all the changes made to a post, check the next header item (To retrieve all changes made to a post)

RESPONSE
{ posts:
 [
  {
    address: "0xEb19D760dAdFce03A27ef6460184C7976Fe5eFE0"
    chain: "ETH"
    channel: "TEST"
    confirmed: false
    content: {body: 'test post written on Aug 17th edited'}
    hash: "63a77911a924f0d61632f2b74784af496fbd094a11fbeed76ad6455ffad18ef8"
    item_content: "{\"type\":\"amend\",\"address\":\"0xEb19D760dAdFce03A27ef6460184C7976Fe5eFE0\",\"content\":{\"body\":\"test post written on Aug 17th edited\"},\"time\":1636144778.602,\"ref\":\"63a77911a924f0d61632f2b74784af496fbd094a11fbeed76ad6455ffad18ef8\"}"
    item_hash: "f47f34ad2cd7ae011dd114abb2dd544502fe554be94586116799646f8d43ff74"
    item_type: "inline"
    original_item_hash: "63a77911a924f0d61632f2b74784af496fbd094a11fbeed76ad6455ffad18ef8"
    original_signature: "0x724509a5aae2d1d126231f71915356f9e5420730d7183c52b8030ee9d1e7d9042e6418896c23a5d9cc46b53039985599c3d95ef4f355ac75e8a761f04e630cd31c"
    original_type: "mytype"
    ref: "63a77911a924f0d61632f2b74784af496fbd094a11fbeed76ad6455ffad18ef8"
    sender: "0xEb19D760dAdFce03A27ef6460184C7976Fe5eFE0"
    signature: "0x99dc18149d8c39391a16d999cf126e08a2a22a629c3855aefe5127c6235dfd43693b971e6d325459308ede7c903f00d3559ce153d0569e9d4bf914860f1a6af31b"
    size: 224
    time: 1636144778.602
    type: "amend"
    _id: {$oid: '6185968a16d179f0c1c2d8c5'}
  },
  {...},
  {...}
 ],
 pagination_page: 1,
 pagination_total: 3,
 pagination_per_page: 248,
 pagination_item: 'posts'
}

History for a post

To retrieve all updates made to a specific post and the original post, use list all messages endpoint rather than list all posts referencing the original item hash. When using list all posts with the item_hash reference, any updated posts, including amends of amends will get displayed whether or not they were performed by the account address. In addition, the original post cannot be retrieved by this endpoint.

Last updated