UNPKG

@standard-crypto/farcaster-js-neynar

Version:

A tool for interacting with Farcaster via Neynar APIs.

101 lines (100 loc) 4.52 kB
import { CastApi, SignerApi, Signer, Cast, PostCastResponseCast, ReactionApi, OperationResponse, FollowsApi, BulkFollowResponse, EmbeddedCast, ErrorRes, FeedApi, UserApi, CastWithInteractions, SearchedUser } from './openapi/index.js'; import { AxiosError, AxiosInstance } from 'axios'; import { Logger } from '../logger.js'; import type { SetRequired } from 'type-fest'; export declare class NeynarV2APIClient { private readonly logger; readonly apis: { signer: SignerApi; feed: FeedApi; cast: CastApi; user: UserApi; reaction: ReactionApi; follow: FollowsApi; }; /** * Instantiates a NeynarV1APIClient * * Note: A Wallet must be provided if the API client is to mint new AuthTokens */ constructor(apiKey: string, { logger, axiosInstance, }?: { logger?: Logger; axiosInstance?: AxiosInstance; }); /** * Utility for parsing errors returned by the Neynar API servers. Returns true * if the given error is caused by an error response from the server, and * narrows the type of `error` accordingly. */ static isApiErrorResponse(error: any): error is SetRequired<AxiosError<ErrorRes>, 'response'>; /** * Fetches an existing Signer. See [Neynar documentation](https://docs.neynar.com/reference/get-signer) * for more details. * */ fetchSigner(signerUuid: string): Promise<Signer | null>; /** * Creates and registers a Signer for an fid. See Neynar documentation[1](https://docs.neynar.com/reference/create-signer),[2](https://docs.neynar.com/reference/register-app-fid) * for more details. */ createSigner(developerMnemonic: string, deadline?: number): Promise<Signer>; /** * Get reverse chronological feed for a user based on their follow graph. See [Neynar documentation](https://docs.neynar.com/reference/get-feed) */ fetchFeed(fid: number, options?: { feedType?: 'filter' | 'following'; filterType?: 'fids' | 'parent_url'; fids?: string; parentUrl?: string; pageSize?: number; }): AsyncGenerator<CastWithInteractions, void, undefined>; /** * Gets information about an individual cast. See [Neynar documentation](https://docs.neynar.com/reference/get-cast) */ fetchCast(castHash: string): Promise<Cast | null>; /** * Gets information about an array of casts. See [Neynar documentation](https://docs.neynar.com/reference/get-array-of-casts) */ fetchCasts(castHashes: string[]): Promise<Cast[] | null>; /** * Publishes a cast for the currently authenticated user. See [Neynar documentation](https://docs.neynar.com/reference/post-a-cast) */ publishCast(signerUuid: string, text: string, options?: { embeds?: EmbeddedCast[]; replyTo?: string; }): Promise<PostCastResponseCast>; /** * Delete a cast. See [Neynar documentation](https://docs.neynar.com/reference/delete-a-cast) */ deleteCast(signerUuid: string, castHash: string): Promise<void>; /** * Search for Usernames. See [Neynar documentation](https://docs.neynar.com/reference/search-usernames) */ searchUsernames(query: string, viewerFid: number): Promise<SearchedUser[] | null>; /** * Update User Profile. See [Neynar documentation](https://docs.neynar.com/reference/update-user-profile) */ updateUserProfile(signerUuid: string, updates: { bio?: string; pfp_url?: string; url?: string; username?: string; display_name?: string; }): Promise<OperationResponse | null>; /** * React to a cast. See [Neynar documentation](https://docs.neynar.com/reference/post-a-reaction) */ reactToCast(signerUuid: string, reaction: 'like' | 'recast', castHash: string): Promise<OperationResponse>; /** * Remove a reaction to a cast. See [Neynar documentation](https://docs.neynar.com/reference/delete-a-reaction) */ removeReactionToCast(signerUuid: string, reaction: 'like' | 'recast', castHash: string): Promise<OperationResponse>; /** * Follow users. See [Neynar documentation](https://docs.neynar.com/reference/follow-a-user) */ followUsers(signerUuid: string, fids: number[]): Promise<BulkFollowResponse>; /** * Unfollow users. See [Neynar documentation](https://docs.neynar.com/reference/unfollow-a-user) */ unfollowUsers(signerUuid: string, fids: number[]): Promise<BulkFollowResponse>; }