These methods can be used to view casts, channels and users. All of them require a PinataFDK initialization with a Pinata JWT.

getCasts

With the getCasts method you can view a paginated list of casts on the Farcaster Network.

Params

  • pageToken - A pagination token to view the next page of casts. (Optional)

Example

import { Casts, PinataFDK } from "pinata-fdk";

const fdk = new PinataFDK({
  pinata_jwt: `${process.env.PINATA_JWT}`,
  pinata_gateway: "",
});

const pageToken = "eyJvZmZzZXQiOiIyODg3ODMzNTExNzY5NjcwOTk5In0"
const res: Casts = await fdk.getCasts(pageToken);

Response

{   
    "casts": [
        {
            "fid": 192,
            "hash": "0x27ec7197ace4365b6004ae4f729c7b46cbc569e2",
            "short_hash": "0x27ec7197",
            "thread_hash": null,
            "parent_hash": null,
            "parent_url": null,
            "root_parent_url": null,
            "parent_author": null,
            "author": {
                "uid": 192,
                "fid": 192,
                "custody_address": "0xc2e7484fbd2322a9986bc49f2e87d7fcac019e26",
                "recovery_address": "0x00000000fcb080a4d6c39a9354da9eb9bc104cd7",
                "following_count": 4,
                "follower_count": 52,
                "verifications": [],
                "bio": "@bunches | product, design, quality",
                "display_name": "Tomer Ben-David",
                "pfp_url": "https://warpcast.com/avatar.png?t=1709148185820",
                "username": "tome",
                "power_badge_user": false
            },
            "content": "gm everybody, gm",
            "timestamp": "2021-11-12T19:22:34Z",
            "embeds": [],
            "mentions": [],
            "mentionPositions": [],
            "reactions": {
                "likes": [
                    {
                        "fid": 192,
                        "fname": "tome"
                    }
                ]
            },
            "replies": {
                "count": 0
            },
            "mentioned_profiles": []
        },
    ...
    ],
    "next_page_token": "eyJvZmZzZXQiOiIyODg3ODMzNTExNzY5NjcwOTk5In0"
}   

getCastByHash

With the getCastByHash method you can view a specific cast on the Farcaster Network.

Params

  • hash - The specific hash of the desired cast.

Example

import { Cast, PinataFDK } from "pinata-fdk";

const fdk = new PinataFDK({
  pinata_jwt: `${process.env.PINATA_JWT}`,
  pinata_gateway: "",
});

const hash = "0x27ec7197ace4365b6004ae4f729c7b46cbc569e2"
const res: Cast = await fdk.getCastByHash(hash);

Response

{
    "fid": 192,
    "hash": "0x27ec7197ace4365b6004ae4f729c7b46cbc569e2",
    "short_hash": "0x27ec7197",
    "thread_hash": null,
    "parent_hash": null,
    "parent_url": null,
    "root_parent_url": null,
    "parent_author": null,
    "author": {
        "uid": 192,
        "fid": 192,
        "custody_address": "0xc2e7484fbd2322a9986bc49f2e87d7fcac019e26",
        "recovery_address": "0x00000000fcb080a4d6c39a9354da9eb9bc104cd7",
        "following_count": 4,
        "follower_count": 52,
        "verifications": [],
        "bio": "@bunches | product, design, quality",
        "display_name": "Tomer Ben-David",
        "pfp_url": "https://warpcast.com/avatar.png?t=1709148185820",
        "username": "tome",
        "power_badge_user": false
    },
    "content": "gm everybody, gm",
    "timestamp": "2021-11-12T19:22:34Z",
    "embeds": [],
    "mentions": [],
    "mentionPositions": [],
    "reactions": {
        "likes": [
            {
                "fid": 192,
                "fname": "tome"
            }
        ]
    },
    "replies": {
        "count": 0
    },
    "mentioned_profiles": []
}   

getUsers

With the getUsers method you can view a paginated list of users on the Farcaster Network.

Params

  • pageToken - A pagination token to view the next page of users. (Optional)

Example

import { Users, PinataFDK } from "pinata-fdk";

const fdk = new PinataFDK({
  pinata_jwt: `${process.env.PINATA_JWT}`,
  pinata_gateway: "",
});

const pageToken = "eyJvZmZzZXQiOiIxMDAifQ"
const res: Users = await fdk.getUsers(pageToken);

Response

{
    "users": [
        {
            "fid": 1,
            "custody_address": "0x8773442740c17c9d0f0b87022c722f9a136206ed",
            "recovery_address": "0x00000000fcb080a4d6c39a9354da9eb9bc104cd7",
            "following_count": 2,
            "follower_count": 12991,
            "verifications": [
                "0x86924c37a93734e8611eb081238928a9d18a63c0"
            ],
            "bio": "A sufficiently decentralized social network. farcaster.xyz",
            "display_name": "Farcaster",
            "pfp_url": "https://i.imgur.com/I2rEbPF.png",
            "username": "farcaster",
            "power_badge_user": true
        },
      ...
    ],
    "next_page_token": "eyJvZmZzZXQiOiIxMDAifQ"
}

getUserByFid

With the getUserByFid method you can view a specific user on the Farcaster Network.

Params

  • fid - The specific fid of the desired user.

Example

import { User, PinataFDK } from "pinata-fdk";

const fdk = new PinataFDK({
  pinata_jwt: `${process.env.PINATA_JWT}`,
  pinata_gateway: "",
});

const fid = 20591
const res: User = await fdk.getUserByFid(fid);

Response

{
    "fid": 20591,
    "custody_address": "0x62402434701e0ce0ae4ea4b3caf68230a6ddbe43",
    "recovery_address": "0x00000000fcb080a4d6c39a9354da9eb9bc104cd7",
    "following_count": 13,
    "follower_count": 351,
    "verifications": [
        "0x5ba9355a10611ed4339526472a59befed3549bad"
    ],
    "bio": "Everyone is from somewhere. Cofounder and CEO of Pinata. https://www.pinata.cloud/farcaster",
    "display_name": "Kyle Tut",
    "pfp_url": "https://i.imgur.com/TLMFnH6.jpg",
    "username": "kyletut",
    "power_badge_user": true
}

getChannelsFollowing

With the getChannelsFollowing method you can view a paginated list of the channels a specific user is following on the Farcaster Network.

Params

  • fid - The specific fid of the desired user.
  • pageToken - A pagination token to view the next page of channels followed. (Optional)

Example

import { ChannelsFollowing, PinataFDK } from "pinata-fdk";

const fdk = new PinataFDK({
  pinata_jwt: `${process.env.PINATA_JWT}`,
  pinata_gateway: "",
});

const fid = 3
const pageToken = "eyJwYWdlIjoxLCJsaW1pdCI6MjV9"
const res: ChannelsFollowing = await fdk.getChannelsFollowing(fid, pageToken);

Response

{
    "channels": [
        {
            "id": "aoe2",
            "name": "aoe2",
            "url": "https://warpcast.com/~/channel/aoe2",
            "description": "For fans of Age of Empires 2",
            "image_url": "https://i.imgur.com/q7dolW5.png",
            "lead_fid": 3,
            "created_at": 1709398612,
            "host_fids": [
                3
            ],
            "follower_count": 58,
            "followed_at": 1709398613
        },
        ...
    ],
    "next_page_token": "eyJwYWdlIjoxLCJsaW1pdCI6MjV9"
}

getChannelFollowingStatus

With the getChannelFollowingStatus method you can check if a specific user follows a specific channel on the Farcaster Network.

Params

  • fid - The specific fid of the desired user.
  • name - The specific name of the desired channel.

Example

import { ChannelFollowingStatus, PinataFDK } from "pinata-fdk";

const fdk = new PinataFDK({
  pinata_jwt: `${process.env.PINATA_JWT}`,
  pinata_gateway: "",
});

const fid = 20591
const name = "pinata"
const res: ChannelFollowingStatus = await fdk.getChannelFollowingStatus(fid, pageToken);

Response

{
    "following": true,
    "followed_at": 1706890562
}

getChannels

With the getChannels method you can view a paginated list of channels on the Farcaster Network.

Params

  • pageToken - A pagination token to view the next page of channels. (Optional)

Example

import { Channels, PinataFDK } from "pinata-fdk";

const fdk = new PinataFDK({
  pinata_jwt: `${process.env.PINATA_JWT}`,
  pinata_gateway: "",
});

const pageToken = "eyJvZmZzZXQiOiIxMDAifQ"
const res: Channels = await fdk.getChannels(pageToken);

Response

{
    "channels": [
        {
            "name": "pinata",
            "url": "https://warpcast.com/~/channel/pinata",
            "display_name": "pinata",
            "description": "Build on IPFS and Farcaster at Scale | https://docs.pinata.cloud/farcaster/farcaster-api/getting-started",
            "image_url": "https://i.imgur.com/u4mGk5b.gif",
            "lead_fid": 20591,
            "created_at": 1706890562,
            "host_fids": [
                20591,
                4823,
                6023
            ],
            "follower_count": 494
        },
      ...
    ],
    "next_page_token": "eyJvZmZzZXQiOiIxMDAifQ" 
}

getChannelByName

With the getChannelByName method you view a specific channel queried by name on the Farcaster Network.

Params

  • name - The specific name of the desired channel.

Example

import { Channel, PinataFDK } from "pinata-fdk";

const fdk = new PinataFDK({
  pinata_jwt: `${process.env.PINATA_JWT}`,
  pinata_gateway: "",
});

const name = "pinata"
const res: Channel = await fdk.getChannelByName(name);

Response

{
    "name": "pinata",
    "url": "https://warpcast.com/~/channel/pinata",
    "display_name": "pinata",
    "description": "Build on IPFS and Farcaster at Scale | https://docs.pinata.cloud/farcaster/farcaster-api/getting-started",
    "image_url": "https://i.imgur.com/u4mGk5b.gif",
    "lead_fid": 20591,
    "created_at": 1706890562,
    "host_fids": [
        20591,
        4823,
        6023
    ],
    "follower_count": 494
}

getChannelFollowers

With the getChannelFollowers method you can view a paginated list of a specific channel’s followers on the Farcaster Network.

Params

  • name - The specific name of the desired channel.
  • pageToken - A pagination token to view the next page of channel followers. (Optional)

Example

import { ChannelFollowers, PinataFDK } from "pinata-fdk";

const fdk = new PinataFDK({
  pinata_jwt: `${process.env.PINATA_JWT}`,
  pinata_gateway: "",
});

const name = "pinata"
const pageToken = "eyJwYWdlIjoxLCJsaW1pdCI6MTAwfQ"
const res: ChannelFollowers = await fdk.getChannelFollowers(name, pageToken);

Response

{
    "followers": [
        {
            "fid": 269317,
            "followed_at": 1710359017
        },
        {
            "fid": 325467,
            "followed_at": 1710357737
        }
        ...
    ],
    "next_page_token": "eyJwYWdlIjoyLCJsaW1pdCI6MTAwfQ"
}