Skip to content

Commit

Permalink
add fetchFollowSuggestions and fetchFrameMetaTagsFromUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
Shreyaschorge committed Nov 13, 2024
1 parent 5e2eece commit 691bc2f
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/neynar-api/neynar-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import {
PostCastReqBodyEmbeds,
NeynarFrameUpdateReqBody,
NeynarFrameCreationReqBody,
FetchFrameMetaTagsFromUrl200Response,
} from "./v2/openapi-farcaster";

import {
Expand Down Expand Up @@ -3034,6 +3035,33 @@ export class NeynarAPIClient {
return await this.clients.v2.fetchUserChannelMemberships(fid, options);
}

/**
* Fetch a list of suggested users to follow. Used to help users discover new users to follow
*
* @param {number} fid - FID of the user whose following you want to fetch.
* @param {Object} [options] - Optional parameters for customizing the response
* @param {number} [options.limit] - Number of results to fetch (Default: 25, Maximum: 100)
* @param {number} [options.viewerFid] - Providing this will return a list of users that respects this user's mutes and blocks and includes `viewer_context`.
*
* @returns {Promise<UsersResponse>} A promise that resolves to a `UsersResponse` object
*
* @example
*
* // Example: Fetch follow suggestions for a user
* client.fetchFollowSuggestions(3, {limit: 5}).then(response => {
* console.log('Follow Suggestions:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/fetch-follow-suggestions)
*
*/
public async fetchFollowSuggestions(
fid: number,
options?: { limit?: number; viewerFid?: number }
): Promise<UsersResponse> {
return await this.clients.v2.fetchFollowSuggestions(fid, options);
}

// ------------ Storage ------------

/**
Expand Down Expand Up @@ -3244,6 +3272,29 @@ export class NeynarAPIClient {
return await this.clients.v2.deleteNeynarFrame(uuid);
}

/**
* Fetches the frame meta tags from the URL
*
* @param {string} url - The URL from which to fetch the frame meta tags
*
* @returns {Promise<FetchFrameMetaTagsFromUrl200Response>} A promise that resolves to a `FetchFrameMetaTagsFromUrl200Response` object
*
* @example
* // Example: Fetch frame meta tags from a URL
* const url = 'https://frames.neynar.com/f/862277df/ff7be6a4';
* client.fetchFrameMetaTagsFromUrl(url).then(response => {
* console.log('Frame Meta Tags:', response);
* });
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-frame-meta-tags-from-url)
*
*/
public async fetchFrameMetaTagsFromUrl(
url: string
): Promise<FetchFrameMetaTagsFromUrl200Response> {
return await this.clients.v2.fetchFrameMetaTagsFromUrl(url);
}

/**
* Retrieves a list of frames created by the developer, identified through the provided API key.
* This method is essential for developers to review their frames submitted to the platform.
Expand Down
57 changes: 57 additions & 0 deletions src/neynar-api/v2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ import {
RespondChannelInviteReqBody,
StpApi,
SubscriptionStatus,
FetchFrameMetaTagsFromUrl200Response,
} from "./openapi-farcaster";
import axios, { AxiosError, AxiosInstance } from "axios";
import { silentLogger, Logger } from "../common/logger";
Expand Down Expand Up @@ -3052,6 +3053,38 @@ export class NeynarV2APIClient {
return response.data;
}

/**
* Fetch a list of suggested users to follow. Used to help users discover new users to follow
*
* @param {number} fid - FID of the user whose following you want to fetch.
* @param {Object} [options] - Optional parameters for customizing the response
* @param {number} [options.limit] - Number of results to fetch (Default: 25, Maximum: 100)
* @param {number} [options.viewerFid] - Providing this will return a list of users that respects this user's mutes and blocks and includes `viewer_context`.
*
* @returns {Promise<UsersResponse>} A promise that resolves to a `UsersResponse` object
*
* @example
*
* // Example: Fetch follow suggestions for a user
* client.fetchFollowSuggestions(3, {limit: 5}).then(response => {
* console.log('Follow Suggestions:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/fetch-follow-suggestions)
*
*/
public async fetchFollowSuggestions(
fid: number,
options?: { limit?: number; viewerFid?: number }
): Promise<UsersResponse> {
const response = await this.apis.follows.fetchFollowSuggestions({
fid,
limit: options?.limit,
viewer_fid: options?.viewerFid,
});
return response.data;
}

// ------------ Storage ------------

/**
Expand Down Expand Up @@ -3288,6 +3321,30 @@ export class NeynarV2APIClient {
return response.data;
}

/**
* Fetches the frame meta tags from the URL
*
* @param {string} url - The URL from which to fetch the frame meta tags
*
* @returns {Promise<FetchFrameMetaTagsFromUrl200Response>} A promise that resolves to a `FetchFrameMetaTagsFromUrl200Response` object
*
* @example
* // Example: Fetch frame meta tags from a URL
* const url = 'https://frames.neynar.com/f/862277df/ff7be6a4';
* client.fetchFrameMetaTagsFromUrl(url).then(response => {
* console.log('Frame Meta Tags:', response);
* });
*
* For more information, refer to the [API documentation](https://docs.neynar.com/reference/fetch-frame-meta-tags-from-url)
*
*/
public async fetchFrameMetaTagsFromUrl(
url: string
): Promise<FetchFrameMetaTagsFromUrl200Response> {
const response = await this.apis.frame.fetchFrameMetaTagsFromUrl({ url });
return response.data;
}

/**
* Retrieves a list of frames created by the developer, identified through the provided API key.
* This method is essential for developers to review their frames submitted to the platform.
Expand Down

0 comments on commit 691bc2f

Please sign in to comment.