-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0f0c9c
commit 2d5b672
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters