@standard-crypto/farcaster-js-neynar
Version:
A tool for interacting with Farcaster via Neynar APIs.
134 lines (133 loc) • 6.49 kB
TypeScript
import { Cast, User, CastApi, UserApi, VerificationApi, NotificationsApi, ReactionsApi, FollowsApi, ErrorRes, Reaction, ReactionWithCastMeta, VerificationResponseResult, ReactionsAndRecastsNotification, Recaster } from './openapi/index.js';
import { AxiosError, AxiosInstance } from 'axios';
import { Logger } from '../logger.js';
import type { SetRequired } from 'type-fest';
export declare class NeynarV1APIClient {
private readonly logger;
readonly apis: {
user: UserApi;
cast: CastApi;
verification: VerificationApi;
notifications: NotificationsApi;
reactions: ReactionsApi;
follows: 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 casts in a given thread. See [Neynar documentation](https://docs.neynar.com/reference/get-all-casts-in-thread)
* Note that the parent provided by the caller is included in the response.
*/
fetchCastsInThread(threadParentHash: string, viewerFid?: number): Promise<Cast[] | null>;
/**
* Gets all casts (including replies and recasts) created by the specified user. See [Neynar documentation](https://docs.neynar.com/reference/get-all-casts-from-user)
*
*/
fetchCastsForUser(fid: number, options?: {
parentUrl?: string;
viewerFid?: number;
pageSize?: number;
}): AsyncGenerator<Cast, void, undefined>;
/**
* Gets recent casts created by the specified user. See [Neynar documentation](https://docs.neynar.com/reference/get-recent-casts-from-protocol)
*
*/
fetchRecentCasts(options?: {
viewerFid?: number;
pageSize?: number;
}): AsyncGenerator<Cast, void, undefined>;
/**
* A list of users in reverse chronological order based on sign up. See [Neynar documentation](https://docs.neynar.com/reference/get-recent-users-from-protocol)
*/
fetchRecentUsers(options?: {
viewerFid?: number;
pageSize?: number;
}): AsyncGenerator<User, void, undefined>;
/**
* Fetch all likes by a given user. See [Neynar documentation](https://docs.neynar.com/reference/get-user-cast-likes)
*/
fetchUserCastLikes(fid: number, options?: {
viewerFid?: number;
pageSize?: number;
}): AsyncGenerator<ReactionWithCastMeta, void, undefined>;
/**
* Gets the specified user via their FID (if found). See [Neynar documentation](https://docs.neynar.com/reference/get-user-information-by-fid)
*/
lookupUserByFid(fid: number, viewerFid?: number): Promise<User | null>;
/**
* Gets the specified user via their username (if found). See [Neynar documentation](https://docs.neynar.com/reference/get-user-information-by-username)
*/
lookupUserByUsername(username: string, viewerFid?: number): Promise<User | null>;
/**
* Gets the custody address for the specified user via their username (if found). See [Neynar documentation](https://docs.neynar.com/reference/get-custody-address)
*/
fetchCustodyAddressForUser(fid: number): Promise<string | null>;
/**
* Gets all known verifications of a user. See [Neynar documentation](https://docs.neynar.com/reference/get-user-verifications)
*/
fetchUserVerifications(fid: number): Promise<VerificationResponseResult | null>;
/**
* Checks if a given Ethereum address has a Farcaster user associated with it.
* Note: if an address is associated with multiple users, the API will return
* the user who most recently published a verification with the address
* (based on when Warpcast received the proof, not a self-reported timestamp).
* See [Neynar documentation](https://docs.neynar.com/reference/get-user-by-verification)
*/
lookupUserByVerification(address: string): Promise<User | null>;
/**
* Gets a list of mentions and replies to the user’s casts in reverse chronological order. See [Neynar documentation](https://docs.neynar.com/reference/get-user-mentions-and-replies)
*/
fetchMentionAndReplyNotifications(fid: number, options?: {
viewerFid?: number;
pageSize?: number;
}): AsyncGenerator<Cast, void, undefined>;
/**
*Get a list of likes and recasts to the users’s casts in reverse chronological order. See [Neynar documentation](https://docs.neynar.com/reference/get-user-likes-and-recasts)
*/
fetchUserLikesAndRecasts(fid: number, options?: {
viewerFid?: number;
pageSize?: number;
}): AsyncGenerator<ReactionsAndRecastsNotification, void, undefined>;
/**
* Lists a given cast's likes. See [Neynar documentation](https://docs.neynar.com/reference/get-all-like-reactions-for-a-cast)
*/
fetchCastLikes(castHash: string, options?: {
viewerFid?: number;
pageSize?: number;
}): AsyncGenerator<Reaction, void, undefined>;
/**
* Get All Reactions For a Cast. See [Neynar documentation](https://docs.neynar.com/reference/get-cast-reactions)
*/
fetchCastReactions(castHash: string, options?: {
viewerFid?: number;
pageSize?: number;
}): AsyncGenerator<Reaction, void, undefined>;
/**
* Get the list of users who have recasted a specific cast. See [Neynar documentation](https://docs.neynar.com/reference/get-list-of-recasters)
*/
fetchRecasters(castHash: string, options?: {
viewerFid?: number;
pageSize?: number;
}): AsyncGenerator<Recaster, void, undefined>;
/**
* Get all users that follow the specified user. See [Neynar documentation](https://docs.neynar.com/reference/get-list-of-followers)
*/
fetchUserFollowers(fid: number, viewerFid?: number): Promise<User[]>;
/**
* Get all users the specified user is following. See [Neynar documentation](https://docs.neynar.com/reference/get-list-of-following)
*/
fetchUserFollowing(fid: number, viewerFid?: number): Promise<User[]>;
}