Getting posts of BitClout User

Getting posts of BitClout User

·

3 min read

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 json
import requests

def 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_code

if __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\n\nRead 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\n\nMaybe 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\n\nFounder: @DevsClout\n\nDev @knowyourclout  \u27a1\ufe0f @GlobalClout\n\nDiscord: 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!