Skip to content

Commit

Permalink
adds fetchUserChannels, updates fetchReactionsForCast types parameter…
Browse files Browse the repository at this point in the history
…, and depreciates limit notes for fetchTrendingChannels

adds fetchUserChannels, updates fetchReactionsForCast types parameter, and depreciates limit notes for fetchTrendingChannels
  • Loading branch information
Shreyaschorge authored Apr 12, 2024
2 parents eb80c2e + 4af826a commit 84b2040
Show file tree
Hide file tree
Showing 7 changed files with 189 additions and 16 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.16.1",
"version": "1.17.0",
"description": "SDK to interact with Neynar APIs (https://docs.neynar.com/)",
"main": "./build/index.js",
"types": "./build/index.d.ts",
Expand Down
33 changes: 31 additions & 2 deletions src/neynar-api/neynar-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1248,6 +1248,36 @@ export class NeynarAPIClient {
);
}

/**
* Fetches channels that a user follows. This method retrieves a list of channels that a user follows,
*
* @param {number} fid - The FID of the user whose followed channels are being fetched.
* @param {Object} [options] - Optional parameters for the function.
* @param {number} [options.limit] - Number of results to retrieve (default 25, max 100)
* @param {string} [options.cursor] - The cursor for pagination.
*
* @returns {Promise<ChannelListResponse>} A promise that resolves to an ChannelListResponse object,
*
*
* @example
* // Example: Fetch the channels that DWR follows
*
* client.fetchUserChannels(3,{limit: 5}).then(response => {
* console.log('DWR channel follows:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/user-channels).
*/
public async fetchUserChannels(
fid: number,
options?: {
limit?: number;
cursor?: string;
}
): Promise<ChannelListResponse> {
return await this.clients.v2.fetchUserChannels(fid, options);
}

/**
* Searches for users based on a query. This method is used to find users by usernames or other
* identifiable information. The search can be contextualized to the viewer specified by `viewerFid`.
Expand Down Expand Up @@ -1824,11 +1854,10 @@ export class NeynarAPIClient {
* containing the reactions associated with the user's casts.
*
* @example
*
* import { ReactionsType } from "@neynar/nodejs-sdk";
*
* // Example: Fetch a casts reactions
* client.fetchReactionsForCast("0xfe90f9de682273e05b201629ad2338bdcd89b6be", ReactionsType.All, {
* client.fetchReactionsForCast("0xfe90f9de682273e05b201629ad2338bdcd89b6be",ReactionsType.All, {
* limit: 50,
* // cursor: "nextPageCursor" // Omit this parameter for the initial request
* }).then(response => {
Expand Down
40 changes: 38 additions & 2 deletions src/neynar-api/v2/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,42 @@ export class NeynarV2APIClient {
return response.data;
}

/**
* Fetches channels that a user follows. This method retrieves a list of channels that a user follows,
*
* @param {number} fid - The FID of the user whose followed channels are being fetched.
* @param {Object} [options] - Optional parameters for the function.
* @param {number} [options.limit] - Number of results to retrieve (default 25, max 100)
* @param {string} [options.cursor] - The cursor for pagination.
*
* @returns {Promise<ChannelListResponse>} A promise that resolves to an ChannelListResponse object,
*
*
* @example
* // Example: Fetch the channels that DWR follows
*
* client.fetchUserChannels(3,{limit: 5}).then(response => {
* console.log('DWR channel follows:', response);
* });
*
* For more information, refer to the [Neynar documentation](https://docs.neynar.com/reference/user-channels).
*/
public async fetchUserChannels(
fid: number,
options?: {
limit?: number;
cursor?: string;
}
): Promise<ChannelListResponse> {
const response = await this.apis.user.userChannels(
this.apiKey,
fid,
options?.limit,
options?.cursor
);
return response.data;
}

/**
* Fetches bulk user information based on multiple Ethereum addresses. This function is particularly
* useful for retrieving user details associated with both custody and verified Ethereum addresses.
Expand Down Expand Up @@ -1502,7 +1538,7 @@ export class NeynarV2APIClient {
* import { ReactionsType } from "@neynar/nodejs-sdk";
*
* // Example: Fetch a casts reactions
* client.fetchCastReactions("0xfe90f9de682273e05b201629ad2338bdcd89b6be", ReactionsType.All, {
* client.fetchCastReactions("0xfe90f9de682273e05b201629ad2338bdcd89b6be",ReactionsType.All, {
* limit: 50,
* // cursor: "nextPageCursor" // Omit this parameter for the initial request
* }).then(response => {
Expand Down Expand Up @@ -1803,7 +1839,7 @@ export class NeynarV2APIClient {
* @param {'1d' | '7d' | '30d'} [timeWindow] - The time window for trending analysis. Options are '1d' (one day),
* '7d' (seven days), or '30d' (thirty days).
* @param {Object} [options] - Optional parameters to tailor the request.
* @param {number} [options.limit=25] - The number of channel details to fetch per request. Defaults to 25, with a maximum allowable value of 100.
* @param {number} [options.limit=10] - The number of channel details to fetch per request. Defaults to 10, with a maximum allowable value of 25.
* @param {string} [options.cursor] - Pagination cursor for the next set of results.
* Omit this parameter for the initial request to start from the first page.
*
Expand Down
18 changes: 8 additions & 10 deletions src/neynar-api/v2/openapi-farcaster/apis/reaction-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,17 @@ export const ReactionApiAxiosParamCreator = function (configuration?: Configurat
* @summary Fetches reactions for a given cast
* @param {string} apiKey API key required for authentication.
* @param {string} hash
* @param {ReactionsType} types comma seperated list of reactions to fetch (likes or recasts or all)
* @param {string} [types] Customize which reaction types the request should search for. This is a comma-separated string that can include the following values: \&#39;likes\&#39; and \&#39;recasts\&#39;. By default api returns both. To select multiple types, use a comma-separated list of these values.
* @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}
*/
reactionsCast: async (apiKey: string, hash: string, types: ReactionsType, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
reactionsCast: async (apiKey: string, hash: string, types?: string, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'apiKey' is not null or undefined
assertParamExists('reactionsCast', 'apiKey', apiKey)
// verify required parameter 'hash' is not null or undefined
assertParamExists('reactionsCast', 'hash', hash)
// verify required parameter 'types' is not null or undefined
assertParamExists('reactionsCast', 'types', types)
const localVarPath = `/farcaster/reactions/cast`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand Down Expand Up @@ -286,13 +284,13 @@ export const ReactionApiFp = function(configuration?: Configuration) {
* @summary Fetches reactions for a given cast
* @param {string} apiKey API key required for authentication.
* @param {string} hash
* @param {ReactionsType} types comma seperated list of reactions to fetch (likes or recasts or all)
* @param {string} [types] Customize which reaction types the request should search for. This is a comma-separated string that can include the following values: \&#39;likes\&#39; and \&#39;recasts\&#39;. By default api returns both. To select multiple types, use a comma-separated list of these values.
* @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 reactionsCast(apiKey: string, hash: string, types: ReactionsType, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ReactionsCastResponse>> {
async reactionsCast(apiKey: string, hash: string, types?: string, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ReactionsCastResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.reactionsCast(apiKey, hash, types, limit, cursor, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
Expand Down Expand Up @@ -348,13 +346,13 @@ export const ReactionApiFactory = function (configuration?: Configuration, baseP
* @summary Fetches reactions for a given cast
* @param {string} apiKey API key required for authentication.
* @param {string} hash
* @param {ReactionsType} types comma seperated list of reactions to fetch (likes or recasts or all)
* @param {string} [types] Customize which reaction types the request should search for. This is a comma-separated string that can include the following values: \&#39;likes\&#39; and \&#39;recasts\&#39;. By default api returns both. To select multiple types, use a comma-separated list of these values.
* @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}
*/
reactionsCast(apiKey: string, hash: string, types: ReactionsType, limit?: number, cursor?: string, options?: any): AxiosPromise<ReactionsCastResponse> {
reactionsCast(apiKey: string, hash: string, types?: string, limit?: number, cursor?: string, options?: any): AxiosPromise<ReactionsCastResponse> {
return localVarFp.reactionsCast(apiKey, hash, types, limit, cursor, options).then((request) => request(axios, basePath));
},
/**
Expand Down Expand Up @@ -412,14 +410,14 @@ export class ReactionApi extends BaseAPI {
* @summary Fetches reactions for a given cast
* @param {string} apiKey API key required for authentication.
* @param {string} hash
* @param {ReactionsType} types comma seperated list of reactions to fetch (likes or recasts or all)
* @param {string} [types] Customize which reaction types the request should search for. This is a comma-separated string that can include the following values: \&#39;likes\&#39; and \&#39;recasts\&#39;. By default api returns both. To select multiple types, use a comma-separated list of these values.
* @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 ReactionApi
*/
public reactionsCast(apiKey: string, hash: string, types: ReactionsType, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
public reactionsCast(apiKey: string, hash: string, types?: string, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
return ReactionApiFp(this.configuration).reactionsCast(apiKey, hash, types, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}

Expand Down
98 changes: 98 additions & 0 deletions src/neynar-api/v2/openapi-farcaster/apis/user-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { BulkFollowResponse } from '../models';
// @ts-ignore
import { BulkUsersResponse } from '../models';
// @ts-ignore
import { ChannelListResponse } from '../models';
// @ts-ignore
import { ErrorRes } from '../models';
// @ts-ignore
import { FollowReqBody } from '../models';
Expand Down Expand Up @@ -579,6 +581,60 @@ export const UserApiAxiosParamCreator = function (configuration?: Configuration)



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

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Returns a list of all channels with their details that a fid follows.
* @summary Retrieve all channels that a given fid follows.
* @param {string} apiKey API key required for authentication.
* @param {number} fid The fid of the user.
* @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}
*/
userChannels: async (apiKey: string, fid: number, limit?: number, cursor?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'apiKey' is not null or undefined
assertParamExists('userChannels', 'apiKey', apiKey)
// verify required parameter 'fid' is not null or undefined
assertParamExists('userChannels', 'fid', fid)
const localVarPath = `/farcaster/user/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 (fid !== undefined) {
localVarQueryParameter['fid'] = fid;
}

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};
Expand Down Expand Up @@ -804,6 +860,20 @@ export const UserApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.userBulkByAddress(apiKey, addresses, addressTypes, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Returns a list of all channels with their details that a fid follows.
* @summary Retrieve all channels that a given fid follows.
* @param {string} apiKey API key required for authentication.
* @param {number} fid The fid of the user.
* @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 userChannels(apiKey: string, fid: number, limit?: number, cursor?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ChannelListResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.userChannels(apiKey, fid, limit, cursor, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
* Search for Usernames
* @summary Search for Usernames
Expand Down Expand Up @@ -964,6 +1034,19 @@ export const UserApiFactory = function (configuration?: Configuration, basePath?
userBulkByAddress(apiKey: string, addresses: string, addressTypes?: string, options?: any): AxiosPromise<{ [key: string]: Array<User>; }> {
return localVarFp.userBulkByAddress(apiKey, addresses, addressTypes, options).then((request) => request(axios, basePath));
},
/**
* Returns a list of all channels with their details that a fid follows.
* @summary Retrieve all channels that a given fid follows.
* @param {string} apiKey API key required for authentication.
* @param {number} fid The fid of the user.
* @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}
*/
userChannels(apiKey: string, fid: number, limit?: number, cursor?: string, options?: any): AxiosPromise<ChannelListResponse> {
return localVarFp.userChannels(apiKey, fid, limit, cursor, options).then((request) => request(axios, basePath));
},
/**
* Search for Usernames
* @summary Search for Usernames
Expand Down Expand Up @@ -1147,6 +1230,21 @@ export class UserApi extends BaseAPI {
return UserApiFp(this.configuration).userBulkByAddress(apiKey, addresses, addressTypes, options).then((request) => request(this.axios, this.basePath));
}

/**
* Returns a list of all channels with their details that a fid follows.
* @summary Retrieve all channels that a given fid follows.
* @param {string} apiKey API key required for authentication.
* @param {number} fid The fid of the user.
* @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 UserApi
*/
public userChannels(apiKey: string, fid: number, limit?: number, cursor?: string, options?: AxiosRequestConfig) {
return UserApiFp(this.configuration).userChannels(apiKey, fid, limit, cursor, options).then((request) => request(this.axios, this.basePath));
}

/**
* Search for Usernames
* @summary Search for Usernames
Expand Down
12 changes: 12 additions & 0 deletions src/neynar-api/v2/openapi-farcaster/models/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export interface Channel {
* @memberof Channel
*/
'created_at'?: number;
/**
* Number of followers the channel has.
* @type {number}
* @memberof Channel
*/
'follower_count'?: number;
/**
*
* @type {string}
Expand All @@ -71,6 +77,12 @@ export interface Channel {
* @memberof Channel
*/
'lead'?: User;
/**
*
* @type {Array<User>}
* @memberof Channel
*/
'hosts'?: Array<User>;
}

export const ChannelObjectEnum = {
Expand Down
2 changes: 1 addition & 1 deletion src/oas
Submodule oas updated 1 files
+53 −5 src/v2/spec.yaml

0 comments on commit 84b2040

Please sign in to comment.