Neynar Documentation

Documentation Index

Fetch the complete documentation index at: /llms.txt

Use this file to discover all available pages before exploring further.

Register new account

cURL

curl --request POST \
  --url https://api.neynar.com/v2/farcaster/user/ \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: NEYNAR_API_DOCS' \
  --header 'x-wallet-id: <x-wallet-id>' \
  --data '
{
  "deadline": 123,
  "fid": 123,
  "requested_user_custody_address": "<string>",
  "signature": "<string>",
  "fname": "<string>",
  "metadata": {
    "bio": "<string>",
    "display_name": "<string>",
    "pfp_url": "<string>",
    "url": "<string>",
    "username": "<string>",
    "verified_accounts": {
      "github": "<string>",
      "x": "<string>"
    }
  }
}
'

Python

import requests

url = "https://api.neynar.com/v2/farcaster/user/"

payload = {
    "deadline": 123,
    "fid": 123,
    "requested_user_custody_address": "<string>",
    "signature": "<string>",
    "fname": "<string>",
    "metadata": {
        "bio": "<string>",
        "display_name": "<string>",
        "pfp_url": "<string>",
        "url": "<string>",
        "username": "<string>",
        "verified_accounts": {
            "github": "<string>",
            "x": "<string>"
        }
    }
}
headers = {
    "x-wallet-id": "<x-wallet-id>",
    "x-api-key": "NEYNAR_API_DOCS",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)

JavaScript (Fetch)

const options = {
  method: 'POST',
  headers: {
    'x-wallet-id': '<x-wallet-id>',
    'x-api-key': 'NEYNAR_API_DOCS',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    deadline: 123,
    fid: 123,
    requested_user_custody_address: '<string>',
    signature: '<string>',
    fname: '<string>',
    metadata: {
      bio: '<string>',
      display_name: '<string>',
      pfp_url: '<string>',
      url: '<string>',
      username: '<string>',
      verified_accounts: {github: '<string>', x: '<string>'}
    }
  })
};

fetch('https://api.neynar.com/v2/farcaster/user/', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));

PHP

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.neynar.com/v2/farcaster/user/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'deadline' => 123,
    'fid' => 123,
    'requested_user_custody_address' => '<string>',
    'signature' => '<string>',
    'fname' => '<string>',
    'metadata' => [
        'bio' => '<string>',
        'display_name' => '<string>',
        'pfp_url' => '<string>',
        'url' => '<string>',
        'username' => '<string>',
        'verified_accounts' => [
                'github' => '<string>',
                'x' => '<string>'
        ]
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "x-api-key: NEYNAR_API_DOCS",
    "x-wallet-id: <x-wallet-id>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

Complete Flow with Wallet Id

const response = await fetch('https://api.neynar.com/v2/farcaster/user', {
  method: 'POST',
  headers: {
    'x-api-key': 'YOUR_NEYNAR_API_KEY',
    'x-wallet-id': 'your-wallet-id',  // REQUIRED
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    fid: 12345,
    fname: 'alice',
    signature: '0x1234...', // EIP-712 signature from user
    requested_user_custody_address: '0xabcd...',
    timestamp: Math.floor(Date.now() / 1000),
    deadline: Math.floor(Date.now() / 1000) + 3600
  })
});

const result = await response.json();
console.log('Account registered:', result);

Error Handling

Error: Missing Wallet ID

{
  "code": "RequiredField",
  "message": "x-wallet-id header is required"
}

Error: FID Expired

{
  "code": "FidExpired",
  "message": "The FID has expired. Please fetch a new FID and try again within 10 minutes."
}

Error: Invalid Signature

{
  "code": "InvalidSignature",
  "message": "The provided signature is invalid or does not match the custody address."
}

Error: Insufficient Wallet Balance

{
  "code": "InsufficientFunds",
  "message": "Wallet does not have enough balance to complete this transaction."
}