@standard-crypto/farcaster-js / Modules / index / MerkleAPIClient
index.MerkleAPIClient
- checkServerAcceptsAuthToken
- createAuthToken
- createSignerRequest
- deleteCast
- deleteRecast
- fetchCast
- fetchCastLikes
- fetchCastsForUser
- fetchCastsInThread
- fetchCurrentUser
- fetchCustodyAddressForUser
- fetchLatestCastForUser
- fetchMentionAndReplyNotifications
- fetchRecentCasts
- fetchRecentUsers
- fetchSignerRequest
- fetchUserAssetCollections
- fetchUserAssetsInCollection
- fetchUserCastLikes
- fetchUserFollowers
- fetchUserFollowing
- fetchUserVerifications
- followUser
- getOrCreateValidAuthToken
- healthcheck
- lookupUserByFid
- lookupUserByUsername
- lookupUserByVerification
- publishCast
- reactToCast
- recast
- removeReactionToCast
- revokeAllAuthTokens
- revokeAuthToken
- unfollowUser
- unwatchCast
- watchCast
- isApiErrorResponse
• new MerkleAPIClient(walletOrAuthToken?
, «destructured»?
)
Instantiates a MerkleAPIClient
Note: A Wallet must be provided if the API client is to mint new AuthTokens
Name | Type |
---|---|
walletOrAuthToken? |
Wallet | { expiresAt? : number ; secret : string } |
«destructured» |
Object |
› axiosInstance? |
AxiosInstance |
› logger? |
Logger |
src/merkleAPI/MerkleAPIClient.ts:74
• Readonly
apis: Object
Name | Type |
---|---|
assets |
AssetsApi |
auth |
AuthApi |
casts |
CastsApi |
follows |
FollowsApi |
miscellaneous |
MiscellaneousApi |
notifications |
NotificationsApi |
signerRequests |
SignerRequestsApi |
user |
UserApi |
users |
UsersApi |
verifications |
VerificationsApi |
watches |
WatchesApi |
src/merkleAPI/MerkleAPIClient.ts:55
▸ checkServerAcceptsAuthToken(authToken
): Promise
<void
>
Name | Type |
---|---|
authToken |
AuthToken |
Promise
<void
>
src/merkleAPI/MerkleAPIClient.ts:145
▸ createAuthToken(expiryDurationMillis?
, «destructured»?
): Promise
<AuthToken
>
Creates a new auth token from the signing key of the Wallet configured with this API client.
Name | Type | Default value |
---|---|---|
expiryDurationMillis |
number |
TEN_MINUTES_IN_MILLIS |
«destructured» |
Object |
{} |
› checkServerAcceptsToken |
undefined | boolean |
undefined |
Promise
<AuthToken
>
src/merkleAPI/MerkleAPIClient.ts:155
▸ createSignerRequest(publicKey
, name
): Promise
<V2SignerRequestsPost200ResponseResult
>
Creates a SignerRequest. See Warpcast documentation for more details.
Note: Authentication credentials are not required for this API endpoint.
Name | Type |
---|---|
publicKey |
string |
name |
string |
Promise
<V2SignerRequestsPost200ResponseResult
>
src/merkleAPI/MerkleAPIClient.ts:201
▸ deleteCast(castOrCastHash
): Promise
<void
>
Delete a cast
Name | Type |
---|---|
castOrCastHash |
string | Cast |
Promise
<void
>
src/merkleAPI/MerkleAPIClient.ts:240
▸ deleteRecast(castOrCastHash
): Promise
<void
>
Delete a recast
Name | Type |
---|---|
castOrCastHash |
string | Cast |
Promise
<void
>
src/merkleAPI/MerkleAPIClient.ts:254
▸ fetchCast(castOrCastHash
): Promise
<undefined
| Cast
>
Gets information about an individual cast
Name | Type |
---|---|
castOrCastHash |
string | Cast |
Promise
<undefined
| Cast
>
src/merkleAPI/MerkleAPIClient.ts:268
▸ fetchCastLikes(castOrCastHash
, «destructured»?
): AsyncGenerator
<CastReaction
, void
, undefined
>
Lists a given cast's likes
Name | Type |
---|---|
castOrCastHash |
string | Cast |
«destructured» |
Object |
› pageSize |
undefined | number |
AsyncGenerator
<CastReaction
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:436
▸ fetchCastsForUser(user
, «destructured»?
): AsyncGenerator
<Cast
, void
, undefined
>
Gets all casts (including replies and recasts) created by the specified user.
@Note: Deleted cast filtering is applied server-side while recast filtering is applied client-side.
Name | Type |
---|---|
user |
Object |
user.fid |
number |
«destructured» |
Object |
› includeDeletedCasts |
undefined | boolean |
› includeRecasts |
undefined | boolean |
› pageSize |
undefined | number |
AsyncGenerator
<Cast
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:328
▸ fetchCastsInThread(threadParent
, «destructured»?
): AsyncGenerator
<Cast
, void
, undefined
>
Fetches casts in a given thread. Note that the parent provided by the caller is included in the response.
Name | Type |
---|---|
threadParent |
Cast | { hash : string } |
«destructured» |
Object |
› pageSize |
undefined | number |
AsyncGenerator
<Cast
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:295
▸ fetchCurrentUser(): Promise
<User
>
Gets the currently authenticated user
Promise
<User
>
src/merkleAPI/MerkleAPIClient.ts:364
▸ fetchCustodyAddressForUser(userOrUsername
): Promise
<string
>
Name | Type |
---|---|
userOrUsername |
string | User |
Promise
<string
>
src/merkleAPI/MerkleAPIClient.ts:370
▸ fetchLatestCastForUser(user
, includeRecasts?
): Promise
<undefined
| Cast
>
Fetch the latest cast for the user, if there is one
Name | Type | Default value |
---|---|---|
user |
Object |
undefined |
user.fid |
number |
undefined |
includeRecasts |
boolean |
false |
Promise
<undefined
| Cast
>
src/merkleAPI/MerkleAPIClient.ts:389
▸ fetchMentionAndReplyNotifications(«destructured»?
): AsyncGenerator
<NotificationCastMention
| NotificationCastReply
, void
, undefined
>
Name | Type |
---|---|
«destructured» |
Object |
› pageSize |
undefined | number |
AsyncGenerator
<NotificationCastMention
| NotificationCastReply
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:403
▸ fetchRecentCasts(«destructured»?
): AsyncGenerator
<Cast
, void
, undefined
>
A list of the latest casts across all users in reverse chronological order based on timestamp
Name | Type |
---|---|
«destructured» |
Object |
› pageSize |
undefined | number |
AsyncGenerator
<Cast
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:470
▸ fetchRecentUsers(«destructured»?
): AsyncGenerator
<User
, void
, undefined
>
A list of users in reverse chronological order based on sign up.
Name | Type |
---|---|
«destructured» |
Object |
› pageSize |
undefined | number |
AsyncGenerator
<User
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:501
▸ fetchSignerRequest(token
): Promise
<undefined
| SignerRequest
>
Fetches an existing SignerRequest. See Warpcast documentation for more details.
Note: Authentication credentials are not required for this API endpoint.
Name | Type |
---|---|
token |
string |
Promise
<undefined
| SignerRequest
>
src/merkleAPI/MerkleAPIClient.ts:534
▸ fetchUserAssetCollections(user
, «destructured»?
): AsyncGenerator
<AssetCollection
, void
, undefined
>
Fetch all asset collections owned by the specified user.
Name | Type |
---|---|
user |
Object |
user.fid |
number |
«destructured» |
Object |
› pageSize |
undefined | number |
AsyncGenerator
<AssetCollection
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:557
▸ fetchUserAssetsInCollection(user
, collectionId
, «destructured»?
): AsyncGenerator
<Asset
, void
, undefined
>
Fetch all assets owned by a given user for a specific collection.
Name | Type |
---|---|
user |
Object |
user.fid |
number |
collectionId |
string |
«destructured» |
Object |
› pageSize |
undefined | number |
AsyncGenerator
<Asset
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:588
▸ fetchUserCastLikes(user
, «destructured»?
): AsyncGenerator
<CastReaction
, void
, undefined
>
Fetch all likes by a given user.
Name | Type |
---|---|
user |
Object |
user.fid |
number |
«destructured» |
Object |
› pageSize |
undefined | number |
AsyncGenerator
<CastReaction
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:621
▸ fetchUserFollowers(user
, «destructured»?
): AsyncGenerator
<User
, void
, undefined
>
Get all users that follow the specified user
Name | Type |
---|---|
user |
Object |
user.fid |
number |
«destructured» |
Object |
› pageSize |
undefined | number |
AsyncGenerator
<User
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:651
▸ fetchUserFollowing(user
, «destructured»?
): AsyncGenerator
<User
, void
, undefined
>
Get all users the specified user is following.
Name | Type |
---|---|
user |
Object |
user.fid |
number |
«destructured» |
Object |
› pageSize |
undefined | number |
AsyncGenerator
<User
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:682
▸ fetchUserVerifications(user
, «destructured»?
): AsyncGenerator
<Verification
, void
, undefined
>
Name | Type |
---|---|
user |
Object |
user.fid |
number |
«destructured» |
Object |
› pageSize |
undefined | number |
AsyncGenerator
<Verification
, void
, undefined
>
src/merkleAPI/MerkleAPIClient.ts:710
▸ followUser(user
): Promise
<void
>
Follow a user
Name | Type |
---|---|
user |
Object |
user.fid |
number |
Promise
<void
>
src/merkleAPI/MerkleAPIClient.ts:739
▸ getOrCreateValidAuthToken(): Promise
<AuthToken
>
Returns an existing valid auth token if one exists, otherwise provisions a new one from the signing key of the given Wallet.
Note that provisioning a new auth token requires an API round trip.
Promise
<AuthToken
>
src/merkleAPI/MerkleAPIClient.ts:218
▸ healthcheck(): Promise
<{ status
: string
}>
Check the status of the API. Expected status is "ok".
Note: authentication parameters are not required.
Promise
<{ status
: string
}>
src/merkleAPI/MerkleAPIClient.ts:751
▸ lookupUserByFid(fid
): Promise
<undefined
| User
>
Gets the specified user via their FID (if found)
Name | Type |
---|---|
fid |
number |
Promise
<undefined
| User
>
src/merkleAPI/MerkleAPIClient.ts:759
▸ lookupUserByUsername(username
): Promise
<undefined
| User
>
Gets the specified user via their username (if found)
Name | Type |
---|---|
username |
string |
Promise
<undefined
| User
>
src/merkleAPI/MerkleAPIClient.ts:781
▸ lookupUserByVerification(address
): Promise
<undefined
| User
>
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 Merkle received the proof, not a self-reported timestamp).
Name | Type |
---|---|
address |
string |
Promise
<undefined
| User
>
src/merkleAPI/MerkleAPIClient.ts:804
▸ publishCast(text
, replyTo?
, embeds?
): Promise
<Cast
>
Publishes a cast for the currently authenticated user
Name | Type |
---|---|
text |
string |
replyTo? |
Cast | { fid : number ; hash : string } |
embeds? |
string [] |
Promise
<Cast
>
src/merkleAPI/MerkleAPIClient.ts:824
▸ reactToCast(reaction
, cast
): Promise
<CastReaction
>
React to a cast
Name | Type |
---|---|
reaction |
"like" |
cast |
Cast | { castHash : string } |
Promise
<CastReaction
>
src/merkleAPI/MerkleAPIClient.ts:856
▸ recast(castOrCastHash
): Promise
<void
>
Recast a cast
Name | Type |
---|---|
castOrCastHash |
string | Cast |
Promise
<void
>
src/merkleAPI/MerkleAPIClient.ts:881
▸ removeReactionToCast(reaction
, cast
): Promise
<void
>
Remove a reaction to a cast
Name | Type |
---|---|
reaction |
"like" |
cast |
Cast | { castHash : string } |
Promise
<void
>
src/merkleAPI/MerkleAPIClient.ts:897
▸ revokeAllAuthTokens(): Promise
<void
>
Revokes all other auth tokens created for this user, with the exception of the one token still in use by this particular instance.
You may still use this instance after calling this method, but any other applications using Auth Tokens for your user will most likely cease working.
Credit to DavidFurlong for this approach: https://github.com/davidfurlong/farcaster-auth-tokens/blob/a114450a1d511caa044e8ace0674146e1ace2531/revoke-all.ts
Promise
<void
>
src/merkleAPI/MerkleAPIClient.ts:946
▸ revokeAuthToken(authToken
): Promise
<void
>
Name | Type |
---|---|
authToken |
AuthToken |
Promise
<void
>
src/merkleAPI/MerkleAPIClient.ts:915
▸ unfollowUser(user
): Promise
<void
>
Unfollow a user
Name | Type |
---|---|
user |
Object |
user.fid |
number |
Promise
<void
>
src/merkleAPI/MerkleAPIClient.ts:971
▸ unwatchCast(cast
): Promise
<void
>
Unwatch a cast
Name | Type |
---|---|
cast |
Cast | { castHash : string ; casterFid : number } |
Promise
<void
>
src/merkleAPI/MerkleAPIClient.ts:981
▸ watchCast(cast
): Promise
<void
>
Watch a cast
Name | Type |
---|---|
cast |
Cast | { castHash : string ; casterFid : number } |
Promise
<void
>
src/merkleAPI/MerkleAPIClient.ts:1004
▸ Static
isApiErrorResponse(error
): error is WithRequired<AxiosError<ApiErrorResponse, any>, "response">
Utility for parsing errors returned by the Merkle API server. Returns true
if the given error is caused by an error response from the server, and
narrows the type of error
accordingly.
Name | Type |
---|---|
error |
any |
error is WithRequired<AxiosError<ApiErrorResponse, any>, "response">