orbis.getPosts()

Returns an array of posts.

How to use?

let { data, error } = await orbis.getPosts();

Parameters

  • options: JSON object containing the filters you can use in this query:
  • context: string Context for which you want to retrieve the posts
  • did: string Retrieving posts shared by a specific user
  • master: string When quering the comments under a parent post
  • only_master: boolean Use true if you want only master posts to be returned
  • tag: string To query only posts shared with a specific tag
  • algorithm: string Returns an ordered list of posts shared in the global feed. Can be one of those:
  • recommendations: Posts shared by users being followed by the connected user or on which they reacted.
  • all-posts: Returns all the posts shared by users with an active wallet.
  • all-posts-non-filtered: Returns all the posts shared by users (not filtered with wallet activity).
  • page: int Is 0 by default, increment this to retrieve additional posts

Examples

/** To query the posts from a specific context */
orbis.getPosts({ context: "k..." });

/** To query the posts from a specific context with a specific tag */
orbis.getPosts({ context: "k...", tag: "main-category" });

/** To query the comments under a post */
orbis.getPosts({ master: "k..." });

/** To query the posts shared by a specific did */
orbis.getPosts({ did: "did:pkh:..." });

/** To query the posts shared on the global feed */
orbis.getPosts({ algorithm: "recommendations" });

/** To query the master posts shared in a context */
orbis.getPosts({
  algorithm: "all-context-master-posts",
  context: "k..."
});

Returns

[
  {
    stream_id: "kjzl6cwe1...e4wvxhiqj",
    creator: "did:pkh:...",
    creator_details: {
      did: "did:pkh:...",
      profile: {
        username: "Baptiste",
        pfp: "https://..."
      }
    },
    content: {
      body: "Content of the post itself",
      ...
    },
    context: null,
    context_details: {
      group_id: "...",
      group_details: {
        ...
      },
      channel_id: "...",
      channel_details: {
        ...
      },
    },
    master: "k...",
    reply_to: "k...",
    reply_to_details: {
      body: "Parent post being replied to...",
      ...
    },
    count_likes: 0,
    count_haha: 0,
    count_downvotes: 0,
    count_replies: 0
  },
  ...
]