placeholderfeatureplaceholdersliderplaceholderthumb
get-posts-stateless Docs & Discord
Top

get-posts-stateless Docs & Discord

by kitty4d

collecting all the stuff i can find about this API endpoint! you can jump around to the different sections here. jump, jump around.

DeSo Official Documentation | OG DeSo Discord - Technical Talk > technical-general | OG DeSo - Technical Talk > nodes | DeSo Foundation Tech - DEVELOPERS > dev-support | DeSo Foundation Tech - DEVELOPERS > dev-general

here’s code i’ve written so far for dealing with this particular method, still in-progress - i’ll be putting it up on github eventually but maybe the code will help. i am using it over on my site - Kitty4D on the B-Chain - DeSo Post Vault - so, it does work.

first i have my method that calls the API

async getPosts({ pk = this.pkey, postHashHex = null, orderBy = '', postContent = '', numToFetch = null, 
fetchSubComments = false, getPostsForFollowFeed = false, getPostsForGlobalWhitelist = false,
getPostsByDESO = false, mediaRequired = false, postsByDESOMinutesLookback = null,
addGlobalFeedBool = false }) {
let url = this.apiurl + 'get-posts-stateless';

try {
let res = await fetchCache(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
ReaderPublicKeyBase58Check: pk,
PostHashHex: postHashHex,
OrderBy: orderBy,
StartTstampSecs: null,
PostContent: postContent,
NumToFetch: numToFetch,
FetchSubcomments: fetchSubComments,
GetPostsForFollowFeed: getPostsForFollowFeed,
GetPostsForGlobalWhitelist: getPostsForGlobalWhitelist,
GetPostsByDESO: getPostsByDESO,
MediaRequired: mediaRequired,
PostsByDESOMinutesLookback: postsByDESOMinutesLookback,
AddGlobalFeedBool: addGlobalFeedBool
})
});
return await res;
} catch (error) {
console.log(error);
}
return null;
}

then i have a little helper method that just abstracts it out a little. originally i had my ‘get-posts-all’ logic in the code that requires this module, but i thought it might be more useful to include that in here. though i’m not 100% sure that a while loop is totally cool with these promises - but it works, and i did look things up as i was writing it.

	case 'get-posts':
/* for Posts, pass:
pk: reader's public key,
postHashHex: for paging, send last received post hash,
orderBy: newest|oldest|last_comment,
postContent: only return posts whose (body only?) matches the text,
numToFetch: non-zero,
fetchSubComments: return 1 level deep of comments? haven't tested yet,
getPostsForFollowFeed: follow feed for reader's pk,
getPostsForGlobalWhitelist: global posts, i guess this is node-agnostic?,
getPostsByDESO: kinda basically the hot feed i guess,
mediaRequired: false, or true but would be nice to specify image and/or video
postsByDESOMinutesLookback: must be <= 60, getPostsByDESO = true - dunno why it doesn't work for all,
addGlobalFeedBool: posts will contain a bool (but i kinda thought they already had an IsGlobal..?)
*/

try {
res = await this.getPosts({ pk: params.readerPk ? params.readerPk : undefined,
postHashHex: params.postHashHex ? params.postHashHex : undefined,
orderBy: params.orderBy ? params.orderBy : undefined,
postContent: params.postContent ? params.postContent : undefined,
numToFetch: params.numToFetch ? params.numToFetch : 10,
mediaRequired: params.mediaRequired ? params.mediaRequired : false });
res = res.PostsFound;
} catch (error) {
res = [];
}
break;

case 'get-posts-all':
/* for Posts, pass:
pk: reader's public key,
postHashHex: for paging, send last received post hash,
orderBy: newest|oldest|last_comment,
postContent: only return posts whose (body only?) matches the text,
numToFetch: non-zero,
fetchSubComments: return 1 level deep of comments? haven't tested yet,
getPostsForFollowFeed: follow feed for reader's pk,
getPostsForGlobalWhitelist: global posts, i guess this is node-agnostic?,
getPostsByDESO: kinda basically the hot feed i guess,
mediaRequired: false, or true but would be nice to specify image and/or video
postsByDESOMinutesLookback: must be <= 60, getPostsByDESO = true - dunno why it doesn't work for all,
addGlobalFeedBool: posts will contain a bool (but i kinda thought they already had an IsGlobal..?)
*/

try {

let batch = null;
let results = [];

let lastPostHash = params.postHashHex ? params.postHashHex : undefined;

while (batch === null || batch.length) {
batch = await this.getPosts({ pk: params.readerPk ? params.readerPk : undefined,
postHashHex: lastPostHash, orderBy: params.orderBy ? params.orderBy : undefined,
postContent: params.postContent ? params.postContent : undefined,
numToFetch: params.numToFetch ? params.numToFetch : 10,
mediaRequired: params.mediaRequired ? params.mediaRequired : false });
batch = batch.PostsFound;
lastPostHash = '';
if (batch.length) {
results.push(...batch);
lastPostHash = batch[batch.length - 1].PostHashHex;
}
}

res = results;
} catch (error) {
res = [];
}
break;

DeSo Documentation

it would be nice if it had info about the response, but even having info about the parameters is brand new and a welcome change. these links are provided on that page, but i’ll include them here as well. these links go to the DeSo Githubs:


not nearly as much info about this from the discords as i guess i hoped, but below is what i could find!


OG DeSo Discord - Technical Talk > technical-general

Avatar tijn
That works when not logged in ?
Avatar
HPaulson 29-Mar-21 08:19 AM
Yup
This is going to be nearly impossible to reverse engineer
since their api is closed source
these routes only work for posts
Likewise:
curl 'https://api.bitclout.green/get-posts-stateless' \ -H 'content-type: application/json' \ --data-raw '{"PostHashHex":"","ReaderPublicKeyBase58Check":"BC1YLhxkeyUesN6W9c8gDrXtUkhBookv727L2fWwXdvfkUcd7EWW9uf","OrderBy":"","StartTstampSecs":null,"PostContent":"","NumToFetch":50,"FetchSubcomments":false,"GetPostsForFollowFeed":false,"GetPostsForGlobalWhitelist":true,"AddGlobalFeedBool":false}' \ --compressed
(Used to fetch posts in global)
It gives all decoded data
So the tx hex is never decoded client side (It seems?)
Unless it's decoded somewhere else
And if that's the case, this just got about 1000000000 times more complex
Lemme try sum
Avatar
leonardofibonacci 22-Apr-21 01:35 AM
Is there a way to use get-posts-stateless to get only posts of one publickey? I am using it and it appears to just get a general list of random posts
Avatar
brootle 22-Apr-21 03:52 AM
Jesus Christ, why can't they just give us a list of API calls with parameters, all of them are actually in this file https://github.com/bitclout/explorer/blob/main/src/app/app.component.ts
Contribute to bitclout/explorer development by creating an account on GitHub.
kekwdisco 2
Avatar
brootle 22-Apr-21 04:02 AM
I think they are building their own apps on top of Bitclout API, so this is not in their interest to make life of other devs easy.
Avatar
brootle 22-Apr-21 04:20 AM
it makes me angry as hell 😆
or maybe their level is so low that they simply have no idea what they are doing and how to make it right
Avatar cfky
Has anyone found a way to get the bitcoin deposit address linked to a bitclout wallet?
Avatar
cdj 22-Apr-21 04:55 PM
I noticed that it is appended to the mailto link on the help, mine looks like "mailto:[email protected]?body=The below information helps support address your case. My public key: BC1YLimromSjtiJo8Y7C9xwL9MFf8z5BdEidjWTC4WAiUZct2VrHbr8 My BTC Address: 1P3V4joGWzbFPmNEDSZgQw6KGrrT2vSZnf"
if that's what you meant
so I'm looking for timestamps, they're returned on the get-posts API, but I don't see them on blockchain explorer EDIT found PrivateMessageTxindexMetadata, maybe its a different place for each action (edited)
btw I got blockchain explorer running locally using mitmproxy but I'm annoyed with how much code it took, if anyone knows how to set headers on mitmproxy on the command line and not in a python script lmk
😢 1
Avatar
leonardofibonacci 22-Apr-21 01:35 AM
Is there a way to use get-posts-stateless to get only posts of one publickey? I am using it and it appears to just get a general list of random posts
Avatar leonardofibonacci
@salil have you figured out how to grab posts for one particular user?
Avatar
salil 27-Apr-21 12:58 AM
The cURL should be: curl 'https://api.bitclout.com/get-posts-for-public-key' \ -H 'Connection: keep-alive' \ -H 'Accept: application/json, text/plain, /' \ -H 'User-Agent: Mozilla/5.0 (Macintosh; Ontel Mac OS X 11_2_3) AppleWebKit/537/36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36' \ -H 'Content-Type: application/json' \ -H 'Accept-Language: en, zh-TW;q=0.8,en-US;q=0.7' \ --data-raw '{"PublicKeyBase58Check":"BC1YLgQkRFM1P3qvW5HQ47cTCikyfB464o4oEbqRkcqJohVs3jfUPib"}' \ --compressed \ --insecure But it is not pulling the posts. Pretty sure there is some flag that needs to be passed in the body that we don't know off yet. Method seems to be correct
💯 1

OG DeSo - Technical Talk > nodes

Avatar
petern 10-Jun-21 05:55 PM
I was also wondering, when you call e.g. /api/v0/get-posts-stateless you get PostEntryResponse struct as a response. It has a LikeCount field, but doesn't contain details about who liked the post. Is there any way to get that information?
Avatar petern
I was also wondering, when you call e.g. /api/v0/get-posts-stateless you get PostEntryResponse struct as a response. It has a LikeCount field, but doesn't contain details about who liked the post. Is there any way to get that information?
Avatar
Crypto Fren 10-Jun-21 05:58 PM
haven't been there, i guess you can make some modifications to the backend ?
when i needed i joined a go discord channel lol the guys helped me a lot
Avatar Crypto Fren
haven't been there, i guess you can make some modifications to the backend ?
Avatar
petern 10-Jun-21 06:00 PM
I noticed that in UtxoView you have a LikeKeyToLikeEntry field, which is exactly what I want, but it's currently only used to count the number of likes. I was trying to code it so that the PostEntryResponse also returns the LikeEntries. @maebeam Do you think it's possible to do, or should I give up and accept we can only get like count lol?
Avatar
JustifydWarrior 10-Jun-21 06:00 PM
we can do it from the v1 api data with heavy post processing
i get 4+ mb of json data back from the trasancactions api (edited)
but that's just a hack/workaround. not a long term solution
Avatar
petern 10-Jun-21 06:02 PM
if only those ConnectTransaction errors wouldn't return instead... (edited)
Avatar
JustifydWarrior 10-Jun-21 06:04 PM
my mempool tab now pops this up but seems to be working when i close it
but the posts tabs work, every other tab works. that endpoint returns stuff
just when you refresh on the admin tabs (edited)
i cannot duplicate the 502 on that endpoint
Avatar petern
I noticed that in UtxoView you have a LikeKeyToLikeEntry field, which is exactly what I want, but it's currently only used to count the number of likes. I was trying to code it so that the PostEntryResponse also returns the LikeEntries. @maebeam Do you think it's possible to do, or should I give up and accept we can only get like count lol?
Avatar
Crypto Fren 10-Jun-21 06:19 PM
it is possible, backend is nothing from the other world
and golang is not so hard as it seems
kind of a mixture between python & c
Avatar petern
I noticed that in UtxoView you have a LikeKeyToLikeEntry field, which is exactly what I want, but it's currently only used to count the number of likes. I was trying to code it so that the PostEntryResponse also returns the LikeEntries. @maebeam Do you think it's possible to do, or should I give up and accept we can only get like count lol?
Avatar
Avatar JustifydWarrior
my mempool tab now pops this up but seems to be working when i close it
Avatar
Crypto Fren 10-Jun-21 06:21 PM
@maebeam same here, some txn paseed then node is being rejected
Avatar maebeam
this is the code you're looking for https://github.com/bitclout/core/pull/15
Avatar
petern 10-Jun-21 06:37 PM
Thanks, also found the backend branch. This is how I feel about you and Rph now: curl --location --request GET https://complimentr.com/api (edited)

DeSo Foundation Tech - DEVELOPERS > dev-support

Avatar
justNick 26-Jan-22 03:34 PM
Is anyone using the "MediaRequired" flag in the get-posts-stateless call? I am getting results that have no image or video URL. I do notice that some of the results have null in the value, while others have "". Is the backend only checking for nulls?
Avatar
justNick 02-Feb-22 10:35 AM
since MediaRequired flag does not work on get-posts-stateless, I need to pull 5000 posts to get 100 videos right now. I really hope this gets resolved. Issue raised on github.
Avatar justNick
since MediaRequired flag does not work on get-posts-stateless, I need to pull 5000 posts to get 100 videos right now. I really hope this gets resolved. Issue raised on github.
Avatar
cfky 02-Feb-22 11:16 AM
What is your use case? Trying to see if I can make it work on my wrapper
Avatar
justNick 02-Feb-22 12:39 PM
I'm only interested posts that have a valid VideoURL
also.. who's idea was it to not have follower count in profile? Am I missing something?
Avatar justNick
also.. who's idea was it to not have follower count in profile? Am I missing something?
Avatar
cfky 02-Feb-22 12:41 PM
yeah it's a separate endpoint... I actually just added it to the graphql wrapper hahaha
🔥 1
Avatar
justNick 02-Feb-22 02:36 PM
How do I get the sub comments to populate in the get-single-post call?
Avatar justNick
since MediaRequired flag does not work on get-posts-stateless, I need to pull 5000 posts to get 100 videos right now. I really hope this gets resolved. Issue raised on github.
Avatar
cfky 02-Feb-22 03:06 PM
This works btw afaik
Media is also in PostExtraData
Avatar
justNick 02-Feb-22 03:19 PM
PostExtraData?
i see tons with nothing in PostExtraData and no image or video url populated
Avatar
justNick 02-Feb-22 03:31 PM
is it including a post if it has a re-post with media?
Avatar
justNick 02-Feb-22 03:41 PM
even then I see posts with media and no reposts with empty PostExtraData. no media in sight
Avatar justNick
even then I see posts with media and no reposts with empty PostExtraData. no media in sight
Avatar
cfky 02-Feb-22 03:53 PM
Can you give me an example with a request and a post that doesn't match please?
Avatar
justNick 02-Feb-22 04:12 PM
check postHashHex a7ae35e78631fd4ce10941879bfe547931d4a633891ca2d800e0d03ee5d93faa. it is returned in the response
Avatar
justNick 02-Feb-22 04:20 PM
looks to me like the flag is ignored in post.go when not using followFeed or globalFeed option
Avatar
piratekev 03-Feb-22 05:30 PM
I'm confused about a post I found yesterday that instead of null imageUrl and videoUrls, populates both with [""]. Anyone seen this before? https://bitclout.com/posts/bc3b36d3f8cc7c4734c73f4fb183c664ed482428373e574d633832e81262c128
@SpunkArt @Twinsdivisions @Marialalart Thank you for the diamonds!!! Much 🥰🥰🥰...
Avatar piratekev
I'm confused about a post I found yesterday that instead of null imageUrl and videoUrls, populates both with [""]. Anyone seen this before? https://bitclout.com/posts/bc3b36d3f8cc7c4734c73f4fb183c664ed482428373e574d633832e81262c128
Avatar
Kuririn 03-Feb-22 05:32 PM
Yes, I have seen something like this. I have a code somewhere to deal with all of the combinations. (there is more if I remember correctly 🙈)
Avatar Kuririn
Yes, I have seen something like this. I have a code somewhere to deal with all of the combinations. (there is more if I remember correctly 🙈)
Avatar
piratekev 03-Feb-22 05:37 PM
I can refactor to handle this scenario but was more curious how this occurred. I haven't been able to recreated it from any node, only by directly submitting a transaction with the imageUrl set as ""
Avatar piratekev
I can refactor to handle this scenario but was more curious how this occurred. I haven't been able to recreated it from any node, only by directly submitting a transaction with the imageUrl set as ""
Avatar
kitty4D 03-Feb-22 08:29 PM
if it's possible like that, then it's possible and doesn't really matter what node allows it. eventually it sounds like things will be tagged with originatingNode but even then, you never really know what app/site might be interacting with its backend API unless it's closed off
Avatar piratekev
I can refactor to handle this scenario but was more curious how this occurred. I haven't been able to recreated it from any node, only by directly submitting a transaction with the imageUrl set as ""
Avatar
ADITYA 03-Feb-22 11:15 PM
Upload image > then remove it > post it
Avatar
kitty4D 17-Feb-22 10:14 AM
is there a fixed max number of posts that can get returned by get-posts-stateless? or maybe a max amount of days back it can go? i don't mean per request. i got about 1135 posts and then the next request brought back an empty array.
Avatar kitty4D
is there a fixed max number of posts that can get returned by get-posts-stateless? or maybe a max amount of days back it can go? i don't mean per request. i got about 1135 posts and then the next request brought back an empty array.
Avatar
Kuririn 17-Feb-22 10:32 AM
you can paginate by PostHashHex or StartTstampSecs I believe, there is also NumToFetch param

DeSo Foundation Tech - DEVELOPERS > dev-general

Avatar
nathanwells 22-Dec-21 11:55 PM
Is there a way to check who owns an NFT through the API? I tried https://node.deso.org/api/v0/get-single-post but that doesn't have the info https://node.deso.org/api/v0/get-posts-stateless also doesn't seem to have that info...
Avatar
nathanwells 23-Dec-21 12:17 AM
Avatar
nandubatchu 24-Dec-21 11:04 PM
how do I differentiate the hidden reposts in the API? 🤔
curl --request POST \ --url https://love4src.com/api/v0/get-reposts-for-post \ --header 'content-type: application/json' \ --data '{"PostHashHex": "b0fd77e903517ee5aa01da9b7e5b39a5c1b4fa4d2fa4585120ddff64c5416ac2","Offset": 0,"Limit": 200}'
@mubashariqbal any idea? 🤔
Also why do post replies show-up in the quote-reposts?
curl --request POST \ --url https://love4src.com/api/v0/get-quote-reposts-for-post \ --header 'content-type: application/json' \ --data '{"PostHashHex": "b0fd77e903517ee5aa01da9b7e5b39a5c1b4fa4d2fa4585120ddff64c5416ac2","Offset": 0,"Limit": 200,"ReaderPublicKeyBase58Check": "BC1YLgLGxLRfMBTLjLHcS6borhxEtqXNPq2dCR3p2ihvPHsYNV9NGY7"}'
I want a reliable way to determine the non-hidden reposts & quote-reposts. Can someone guide me?
Avatar
mubashariqbal 24-Dec-21 11:12 PM
I believe in the response there is a "IsHidden" field. This is per node, so something might be hidden on DiamondApp, but not hidden on other nodes, and vice versa.
Avatar
nandubatchu 24-Dec-21 11:34 PM
On DiamondApp UI the repost is hidden, though in the API - it is marked as IsHidden: false (edited)
How is the UI handling this? 🤷