List all posts

Use the .get_posts() function to get the latest version of each post returned by the query.

Returns

An object containing a posts array as well as details on the number of posts and pages returned:

STRUCTURE OF THE RETURNED OBJECT
{   
    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 referencing 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

STRUCTURE OF EACH OBJECT IN THE POSTS 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

def get_posts(
    pagination,
    page,
    types,
    refs,
    addresses,
    tags,
    hashes,
    channels,
    start_date,
    end_date,
    session,
    api_server,
)

Required Arguments

All arguments are optional. If none are passed, all posts will be returned for the default argument values.

Optional Arguments

  • pagination - integer Default: 200 Number of messages returned per page

  • page - integer Default: 1 The number of pages returned

  • types - Iterable of strings Default: None Posts with the "post_types" in theitem_content.type as well as any last amended post where the original post type was "post_types"

    The value can be an array of one type or multiple types.

    ex: ["blog", "comment"]

  • refs - Iterable of strings Default: None Array of Refs listed in content refs (item_content.ref)

  • addresses - Iterable of strings Default: None Array of addresses listed in the content address (item_content.address) or sender (sender) attribute of the Message.

    If multiple addresses are passed, any post with one of the queried addresses in the content address or sender attribute will be returned.

  • tags - Iterable of strings Default: None Array of post content content tag. (item_content.content.tags).

    If multiple tags are passed, posts with at least one of the tags present in the content content tags will be returned.

  • hashes - Iterable of strings Default: None Array of hashes listed in the item hash (item_hash) or transaction hash (tx_hash)

  • channels - Iterable of strings Default: None

    Array of channels

  • start_date - datetime or float (timestamp) Default: None Filtering posts on the time attribute (time).

    If only the start date is passed, posts with time greater than the start date will be returned. If both start and end dates are passed, posts with time in between start date and end date will be returned.

  • end_date - datetime or float (timestamp) Default: None If only the end date is passed, posts with time less than the end date will be returned. If both start and end dates are passed, posts with time in between start date and end date will be returned.

  • session Default: None

  • api_server - string Default: "https://api2.aleph.im" Target API server

Example

from aleph_client.asynchronous import get_posts

await get_posts(
    types=['chat'], 
    refs= ['hall'], 
    pagination=3)

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)

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