Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 18, 2021 02:57 pm GMT

Getting posts of BitClout User

Just like the twitter API that gives tweet content and other information about tweets of users, BitClout API also offers the same feature but additionally, it also provides much more information about user's posts!

You can fetch any user's N number of posts through username. All you need is to make a POST request to https://bitclout.com/api/v0/get-posts-for-public-key
Below is a python code that fetches desired number of posts of any user:

import jsonimport requestsdef getPostsOfUser(username, numberOfPosts):  payload= {"PublicKeyBase58Check":"","Username":username,"ReaderPublicKeyBase58Check":"BC1YLhBLE1834FBJbQ9JU23JbPanNYMkUsdpJZrFVqNGsCe7YadYiUg","NumToFetch":numberOfPosts}  #here ReaderPublicKeyBase58Check means the reader of the post. You can leave it as it is or just use your own public key.   response = requests.post(url="https://bitclout.com/api/v0/get-posts-for-public-key", json=payload)  file = open("postsOfUser.json", "w")  json.dump(response.json(), file)  file.close()  return response.status_codeif __name__ == "__main__":  user = "ItsAditya"  print(getPostsOfUser(user, 20))

If on execution of the above code prints response code 200, a new file named postsOfUser.json will be created that contains 20 posts by that user (Reclouts included)
The response JSON file looks like this

{  "Posts": [    {      "PostHashHex": "b15caa1e109bcb4544acb2864e583b41db12e70790b435eac8ec45b875b4066b",      "PosterPublicKeyBase58Check": "BC1YLhBLE1834FBJbQ9JU23JbPanNYMkUsdpJZrFVqNGsCe7YadYiUg",      "ParentStakeID": "",      "Body": "One interesting fact as stated by @ElonTusk is that the money was transferred to @PR12M which can be read as Prism which is a US based surveillance program

Read more here: https://en.wikipedia.org/wiki/PRISM_(surveillance_program)", "ImageURLs": null, "RecloutedPostEntryResponse": { "PostHashHex": "8693d28eff9c5833173a33ac2bdea4ffaa7c3fc682fd6033d6837d78fbd4105d", "PosterPublicKeyBase58Check": "BC1YLhBLE1834FBJbQ9JU23JbPanNYMkUsdpJZrFVqNGsCe7YadYiUg", "ParentStakeID": "", "Body": "The compromised accounts who had lost money few days ago due to the \"hacks\" received their money back \ud83d\udc40

Maybe all this was done just to teach a lesson? \ud83e\udd14 ", "ImageURLs": [], "RecloutedPostEntryResponse": null, "CreatorBasisPoints": 1000, "StakeMultipleBasisPoints": 12500, "TimestampNanos": 1623937618272511376, "IsHidden": false, "ConfirmationBlockHeight": 34779, "InMempool": false, "StakeEntry": { "TotalPostStake": 0, "StakeList": [] }, "StakeEntryStats": { "TotalStakeNanos": 0, "TotalStakeOwedNanos": 0, "TotalCreatorEarningsNanos": 0, "TotalFeesBurnedNanos": 0, "TotalPostStakeNanos": 0 }, "ProfileEntryResponse": { "PublicKeyBase58Check": "BC1YLhBLE1834FBJbQ9JU23JbPanNYMkUsdpJZrFVqNGsCe7YadYiUg", "Username": "ItsAditya", "Description": "17 year young | Programmer | Illustrator

Founder: @DevsClout

Dev @knowyourclout \u27a1\ufe0f @GlobalClout

Discord: https://discord.gg/ggvtTje ", "IsHidden": false, "IsReserved": false, "IsVerified": false, "Comments": null, "Posts": null, "CoinEntry": { "CreatorBasisPoints": 1000, "BitCloutLockedNanos": 50542099887, "NumberOfHolders": 263, "CoinsInCirculationNanos": 36972965086, "CoinWatermarkNanos": 38212986918 }, "CoinPriceBitCloutNanos": 4101005003, "StakeMultipleBasisPoints": 12500, "StakeEntryStats": { "TotalStakeNanos": 0, "TotalStakeOwedNanos": 0, "TotalCreatorEarningsNanos": 0, "TotalFeesBurnedNanos": 0, "TotalPostStakeNanos": 0 }, "UsersThatHODL": null }, "Comments": null, "LikeCount": 29, "DiamondCount": 7, "PostEntryReaderState": { "LikedByReader": true, "DiamondLevelBestowed": 0, "RecloutedByReader": false, "RecloutPostHashHex": "" }, "InGlobalFeed": true, "IsPinned": false, "PostExtraData": {}, "CommentCount": 6, "RecloutCount": 3, "QuoteRecloutCount": 3, "ParentPosts": null, "DiamondsFromSender": 0 }, "CreatorBasisPoints": 1000, "StakeMultipleBasisPoints": 12500, "TimestampNanos": 1623939733768805958, "IsHidden": false, "ConfirmationBlockHeight": 34783, "InMempool": false, "StakeEntry": { "TotalPostStake": 0, "StakeList": [] }, "StakeEntryStats": { "TotalStakeNanos": 0, "TotalStakeOwedNanos": 0, "TotalCreatorEarningsNanos": 0, "TotalFeesBurnedNanos": 0, "TotalPostStakeNanos": 0 }, "ProfileEntryResponse": null, "Comments": null, "LikeCount": 4, "DiamondCount": 2, "PostEntryReaderState": { "LikedByReader": true, "DiamondLevelBestowed": 0, "RecloutedByReader": false, "RecloutPostHashHex": "" }, "InGlobalFeed": false, "IsPinned": false, "PostExtraData": {}, "CommentCount": 1, "RecloutCount": 1, "QuoteRecloutCount": 0, "ParentPosts": null, "DiamondsFromSender": 0 }]}

If you like the article don't forget to let us know in the comments or maybe give a shout to DevsClout ? You can also join DevsClout discord server to chat with more devs who are building awesome projects on BitClout! We would love to hear back from you!


Original Link: https://dev.to/itsaditya/getting-posts-of-bitclout-user-3h83

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To