Files
hub-monorepo/packages/hub-nodejs
Shane da Silva cc2f5a4fae Add syncing/replication example for Postgres (#938)
Provide a working end-to-end example of syncing data from hubs to a
Postgres database.

This should work with no additional dependencies besides what you
install with `yarn install` and Docker.
2023-05-05 09:56:48 -07:00
..
2023-04-27 14:36:13 -07:00
2023-04-27 14:36:13 -07:00

@farcaster/hub-nodejs

A lightweight, fast Typescript interface for Farcaster Hubs. Designed to work with Hubble and any other Hub that implements the Farcaster protocol.

Features

  • Call any Hub endpoint from a NodeJS environment.
  • Serializes and deserializes Farcaster protobufs into Javascript objects.
  • Has helpers to create and sign Farcaster messages.
  • Written entirely in TypeScript, with strict types for safety.

Read the documentation, see more examples or get started with the guide below.

Installation

Install @farcaster/hub-nodejs with the package manager of your choice

npm install @farcaster/hub-nodejs
yarn add @farcaster/hub-nodejs
pnpm install @farcaster/hub-nodejs

Quickstart

Fetching Data from Hubs

import { getSSLHubRpcClient } from '@farcaster/hub-nodejs';

(async () => {
  const client = getSSLHubRpcClient('testnet1.farcaster.xyz:2283');

  const castsResult = await client.getCastsByFid({ fid: 8928 });

  castsResult.map((casts) => casts.messages.map((cast) => console.log(cast.data?.castAddBody?.text)));

  client.close();
})();

Contributing

Please see our contributing guidelines before making a pull request.

License

MIT License