Skip to main content

Link User Farcaster ID to AlfaFrens Address and Channel

The getUserByFid endpoint allows you to retrieve the AlfaFrens address and channel for a specific user using their Farcaster ID. This guide will walk you through how to use this endpoint.

Endpoint

GET https://alfafrens.com/api/v0/getUserByFid?fid={fid}

Parameters

  • fid: The Farcaster ID of the user you want to retrieve information for.

Example Request

To retrieve the AlfaFrens address and channel for a user with the Farcaster ID 9507, you would use the following request:

GET https://alfafrens.com/api/v0/getUserByFid?fid=9507

Example Response

The response from this endpoint includes information about the user's AlfaFrens address, Farcaster ID, handle, and channel address. Here is an example of what the response looks like:

{
"userAddress": "0x59D7EB03449949eDf55133b477599207F54Cc1ce",
"fid": "9507",
"handle": "0xfran",
"channeladdress": "0x1308e16eb155c405577366eb1c94cf8c00019b35"
}

Retrieving User Information

User Address

The userAddress field contains the AlfaFrens address of the user. You can access it directly from the response:

const userAddress = response.userAddress;

Channel Address

The channeladdress field contains the channel address associated with the user. You can access it directly from the response:

const channelAddress = response.channeladdress;

Handle

The handle field contains the user's handle. You can access it directly from the response:

const handle = response.handle;

Example Code

JavaScript

Here is an example of how you might retrieve and process the user information in JavaScript:

async function getUserInfoByFid(fid) {
const response = await fetch(`https://alfafrens.com/api/v0/getUserByFid?fid=${fid}`);
const data = await response.json();

const userAddress = data.userAddress;
const channelAddress = data.channeladdress;
const handle = data.handle;

return { userAddress, channelAddress, handle };
}

const fid = 9507;

getUserInfoByFid(fid).then(userInfo => {
console.log('User Address:', userInfo.userAddress);
console.log('Channel Address:', userInfo.channelAddress);
console.log('Handle:', userInfo.handle);
});

This code fetches the user's AlfaFrens address, channel address, and handle using their Farcaster ID.

Further Information

For more details on the API, including additional usage examples and response formats, please refer to the full API documentation.


Happy coding with AlfaFrens API!