Skip to content

Commit

Permalink
docs: add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Complexlity committed Aug 11, 2024
1 parent f0f0c9c commit 2d5b672
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Uni Farcaster SDK

This is an SDK that combines neynar, airstack to provide a single API without needing to know the underlying apis of both. By default, it should support just passing a hub url and have a default, but in the current implementation, you need either a neynar api key or an airstack api key.

## Installation

```bash
npm install uni-farcaster-sdk
```

## Usage

```js
import uniFarcasterSdk from 'uni-farcaster-sdk'

// Hub
const sdkInstance = uniFarcasterSdk({
//Optional: The sdk would provide a default hub url for your
hubUrl: 'your-hub-url',
})
//NOTE: For now, hub isn't support and you will need to get either airstack or neynar api key

// Neynar
const sdkInstance = uniFarcasterSdk({
neynarApiKey: 'your-neynar-api-key',
activeService: 'neynar',
})
// Airstack
const sdkInstance = uniFarcasterSdk({
airstackApiKey: 'your-airstack-api-key',
activeService: 'airstack',
})

//Both
const sdkInstance = uniFarcasterSdk({
neynarApiKey: 'your-neynar-api-key',
airstackApiKey: 'your-airstack-api-key',
//You have to specify which service you want to use
activeService: 'neynar',
})

//Get Active Service
sdkInstance.getActiveService() //neynar

//Set Active Service
sdkInstance.setActiveService('airstack')
sdkInstance.getActiveService() //airstack

//Get User By Fid
const userFid = 3
const viewerFid = 4
await sdk.getUserByFid(3, 4)
//Viewer Fid is optional and defaults to 213144

//Get User By Username
const userName = 'ds8'
await sdk.getUserByUsername(userName)

//Getting by username doesn't return viewer context when using airstack instance so use getUserByFid when you always need viewerContext

//Get Cast By Url
await sdk.getCastByUrl(castUrl, viewerFid)

//Get Cast By Hash
await sdk.getCastByHash(castHash, viewerFid)
```



4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/Complexlity/uni-farcaster-sdk"
},
"scripts": {
"test:dev": "vitest",
"test": "vitest run",
Expand Down

0 comments on commit 2d5b672

Please sign in to comment.