Skip to content

Commit

Permalink
Feature/retrieve feed based on channel ids
Browse files Browse the repository at this point in the history
Feature/retrieve feed based on channel ids
  • Loading branch information
Shreyaschorge authored Dec 29, 2023
2 parents 57db720 + 7971b48 commit 0dc1a4f
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@neynar/nodejs-sdk",
"version": "1.4.1",
"version": "1.5.0",
"description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand Down
36 changes: 36 additions & 0 deletions src/neynar-api/neynar-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,7 @@ export class NeynarAPIClient {
* @param {string} [options.channelId] Used when filter_type=channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [options.embedUrl] - Used when filter_type=embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [options.withRecasts] - Whether to include recasts in the response. True by default.
* @param {boolean} [options.withReplies] - Include replies in the response, false by default
* @param {number} [options.limit] - Number of results to retrieve, with a default of 25 and a maximum of 100.
* @param {string} [options.cursor] - Pagination cursor for fetching specific subsets of results.
*
Expand All @@ -1157,11 +1158,46 @@ export class NeynarAPIClient {
limit?: number;
cursor?: string;
withRecasts?: boolean;
withReplies?: boolean;
}
): Promise<FeedResponse> {
return await this.clients.v2.fetchFeed(feedType, options);
}

/**
* Retrieves a feed based on specific channel IDs. This method allows for fetching casts from
* selected channels, optionally including recasts and replies.
*
* @param {Array<string>} channelIds - An array of channel IDs for which the feed is to be retrieved.
* @param {Object} [options] - Optional parameters for customizing the feed.
* @param {boolean} [options.withRecasts] - Whether to include recasts in the response. True by default.
* @param {boolean} [options.withReplies] - Whether to include replies in the response. False by default.
* @param {number} [options.limit] - Number of results to retrieve (default 25, max 100).
* @param {string} [options.cursor] - Pagination cursor for the next set of results.
*
* @returns {Promise<FeedResponse>} A promise that resolves to a `FeedResponse` object,
* containing the feed for the specified channel IDs.
*
* @example
* // Example: Retrieve feed for specific channels, including recasts and replies
* client.fetchFeedByChannelIds(['neynar', 'farcaster'], { withRecasts: true, withReplies: true, limit: 30 }).then(response => {
* console.log('Channel Feed:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/feed-channels).
*/
public async fetchFeedByChannelIds(
channelIds: string[],
options?: {
withRecasts?: boolean;
withReplies?: boolean;
limit?: number;
cursor?: string;
}
): Promise<FeedResponse> {
return await this.clients.v2.fetchFeedByChannelIds(channelIds, options);
}

// ------------ Reaction ------------

/**
Expand Down
46 changes: 46 additions & 0 deletions src/neynar-api/v2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ export class NeynarV2APIClient {
* @param {string} [options.channelId] Used when filter_type=channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [options.embedUrl] - Used when filter_type=embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [options.withRecasts] - Whether to include recasts in the response. True by default.
* @param {boolean} [options.withReplies] - Include replies in the response, false by default
* @param {number} [options.limit] - Number of results to retrieve, with a default of 25 and a maximum of 100.
* @param {string} [options.cursor] - Pagination cursor for fetching specific subsets of results.
*
Expand All @@ -706,6 +707,7 @@ export class NeynarV2APIClient {
limit?: number;
cursor?: string;
withRecasts?: boolean;
withReplies?: boolean;
}
): Promise<FeedResponse> {
const _fids = options?.fids?.join(",");
Expand All @@ -720,6 +722,50 @@ export class NeynarV2APIClient {
options?.channelId,
options?.embedUrl,
options?.withRecasts,
options?.withReplies,
options?.limit,
options?.cursor
);
return response.data;
}

/**
* Retrieves a feed based on specific channel IDs. This method allows for fetching casts from
* selected channels, optionally including recasts and replies.
*
* @param {Array<string>} channelIds - An array of channel IDs for which the feed is to be retrieved.
* @param {Object} [options] - Optional parameters for customizing the feed.
* @param {boolean} [options.withRecasts] - Whether to include recasts in the response. True by default.
* @param {boolean} [options.withReplies] - Whether to include replies in the response. False by default.
* @param {number} [options.limit] - Number of results to retrieve (default 25, max 100).
* @param {string} [options.cursor] - Pagination cursor for the next set of results.
*
* @returns {Promise<FeedResponse>} A promise that resolves to a `FeedResponse` object,
* containing the feed for the specified channel IDs.
*
* @example
* // Example: Retrieve feed for specific channels, including recasts and replies
* client.fetchFeedByChannelIds(['neynar', 'farcaster'], { withRecasts: true, withReplies: true, limit: 30 }).then(response => {
* console.log('Channel Feed:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/feed-channels).
*/
public async fetchFeedByChannelIds(
channelIds: string[],
options?: {
withRecasts?: boolean;
withReplies?: boolean;
limit?: number;
cursor?: string;
}
): Promise<FeedResponse> {
const _channelIds = channelIds.join(",");
const response = await this.apis.feed.feedChannels(
this.apiKey,
_channelIds,
options?.withRecasts,
options?.withReplies,
options?.limit,
options?.cursor
);
Expand Down
134 changes: 127 additions & 7 deletions src/neynar-api/v2/openapi-farcaster/apis/feed-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ export const FeedApiAxiosParamCreator = function (configuration?: Configuration)
* @param {string} [channelId] Used when filter_type&#x3D;channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [embedUrl] Used when filter_type&#x3D;embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @param {boolean} [withReplies] Include replies in the response, false by default
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
feed: async (apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
feed: async (apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, withReplies?: boolean, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'apiKey' is not null or undefined
assertParamExists('feed', 'apiKey', apiKey)
// verify required parameter 'feedType' is not null or undefined
Expand Down Expand Up @@ -101,6 +102,74 @@ export const FeedApiAxiosParamCreator = function (configuration?: Configuration)
localVarQueryParameter['with_recasts'] = withRecasts;
}

if (withReplies !== undefined) {
localVarQueryParameter['with_replies'] = withReplies;
}

if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}

if (cursor !== undefined) {
localVarQueryParameter['cursor'] = cursor;
}

if (apiKey != null) {
localVarHeaderParameter['api_key'] = String(apiKey);
}



setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Retrieve feed based on channel ids
* @param {string} apiKey API key required for authentication.
* @param {string} channelIds comma separated list of channel ids e.g. neynar,farcaster
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @param {boolean} [withReplies] Include replies in the response, false by default
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
feedChannels: async (apiKey: string, channelIds: string, withRecasts?: boolean, withReplies?: boolean, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'apiKey' is not null or undefined
assertParamExists('feedChannels', 'apiKey', apiKey)
// verify required parameter 'channelIds' is not null or undefined
assertParamExists('feedChannels', 'channelIds', channelIds)
const localVarPath = `/farcaster/feed/channels`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

if (channelIds !== undefined) {
localVarQueryParameter['channel_ids'] = channelIds;
}

if (withRecasts !== undefined) {
localVarQueryParameter['with_recasts'] = withRecasts;
}

if (withReplies !== undefined) {
localVarQueryParameter['with_replies'] = withReplies;
}

if (limit !== undefined) {
localVarQueryParameter['limit'] = limit;
}
Expand Down Expand Up @@ -146,13 +215,30 @@ export const FeedApiFp = function(configuration?: Configuration) {
* @param {string} [channelId] Used when filter_type&#x3D;channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [embedUrl] Used when filter_type&#x3D;embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @param {boolean} [withReplies] Include replies in the response, false by default
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, withReplies?: boolean, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FeedResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.feed(apiKey, feedType, filterType, fid, fids, parentUrl, channelId, embedUrl, withRecasts, withReplies, limit, cursor, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Retrieve feed based on channel ids
* @param {string} apiKey API key required for authentication.
* @param {string} channelIds comma separated list of channel ids e.g. neynar,farcaster
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @param {boolean} [withReplies] Include replies in the response, false by default
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FeedResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.feed(apiKey, feedType, filterType, fid, fids, parentUrl, channelId, embedUrl, withRecasts, limit, cursor, options);
async feedChannels(apiKey: string, channelIds: string, withRecasts?: boolean, withReplies?: boolean, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<FeedResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.feedChannels(apiKey, channelIds, withRecasts, withReplies, limit, cursor, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
}
Expand All @@ -177,13 +263,29 @@ export const FeedApiFactory = function (configuration?: Configuration, basePath?
* @param {string} [channelId] Used when filter_type&#x3D;channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [embedUrl] Used when filter_type&#x3D;embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @param {boolean} [withReplies] Include replies in the response, false by default
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options?: any): AxiosPromise<FeedResponse> {
return localVarFp.feed(apiKey, feedType, filterType, fid, fids, parentUrl, channelId, embedUrl, withRecasts, limit, cursor, options).then((request) => request(axios, basePath));
feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, withReplies?: boolean, limit?: number, cursor?: string, options?: any): AxiosPromise<FeedResponse> {
return localVarFp.feed(apiKey, feedType, filterType, fid, fids, parentUrl, channelId, embedUrl, withRecasts, withReplies, limit, cursor, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Retrieve feed based on channel ids
* @param {string} apiKey API key required for authentication.
* @param {string} channelIds comma separated list of channel ids e.g. neynar,farcaster
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @param {boolean} [withReplies] Include replies in the response, false by default
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
feedChannels(apiKey: string, channelIds: string, withRecasts?: boolean, withReplies?: boolean, limit?: number, cursor?: string, options?: any): AxiosPromise<FeedResponse> {
return localVarFp.feedChannels(apiKey, channelIds, withRecasts, withReplies, limit, cursor, options).then((request) => request(axios, basePath));
},
};
};
Expand All @@ -207,13 +309,31 @@ export class FeedApi extends BaseAPI {
* @param {string} [channelId] Used when filter_type&#x3D;channel_id can be used to fetch all casts under a channel. Requires feed_type and filter_type
* @param {string} [embedUrl] Used when filter_type&#x3D;embed_url can be used to fetch all casts with an embed url that contains embed_url. Requires feed_type and filter_type
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @param {boolean} [withReplies] Include replies in the response, false by default
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof FeedApi
*/
public feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, withReplies?: boolean, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
return FeedApiFp(this.configuration).feed(apiKey, feedType, filterType, fid, fids, parentUrl, channelId, embedUrl, withRecasts, withReplies, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Retrieve feed based on channel ids
* @param {string} apiKey API key required for authentication.
* @param {string} channelIds comma separated list of channel ids e.g. neynar,farcaster
* @param {boolean} [withRecasts] Include recasts in the response, true by default
* @param {boolean} [withReplies] Include replies in the response, false by default
* @param {number} [limit] Number of results to retrieve (default 25, max 100)
* @param {string} [cursor] Pagination cursor.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof FeedApi
*/
public feed(apiKey: string, feedType: FeedType, filterType?: FilterType, fid?: number, fids?: string, parentUrl?: string, channelId?: string, embedUrl?: string, withRecasts?: boolean, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
return FeedApiFp(this.configuration).feed(apiKey, feedType, filterType, fid, fids, parentUrl, channelId, embedUrl, withRecasts, limit, cursor, options).then((request) => request(this.axios, this.basePath));
public feedChannels(apiKey: string, channelIds: string, withRecasts?: boolean, withReplies?: boolean, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
return FeedApiFp(this.configuration).feedChannels(apiKey, channelIds, withRecasts, withReplies, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}
}
Loading

0 comments on commit 0dc1a4f

Please sign in to comment.