blob: 0d034abfe2704865fe9ba1f7c9a912b07222fee0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
Document: WR-006 P. Webb
2024.11.12
Export your Farcaster posts
Body
I recently decided to quit Farcaster for several reasons. You can
read about them in the `elon-mind-virus.txt` post. Anyhoo, here's the
Deno script I made, adapted from Neynar's Node.js archiver script[1]:
```ts
/*** IMPORT ------------------------------------------- ***/
import { appendFile } from "node:fs";
import { NeynarAPIClient } from "npm:@neynar/nodejs-sdk";
/*** UTILITY ------------------------------------------ ***/
const client = new NeynarAPIClient("YOUR_NEYNAR_API_KEY");
const fid = 16152; /// your Farcaster FID
const dumpCast = (cast) => {
const data = `${JSON.stringify(cast)}\n`;
appendFile(`${fid}_export.ndjson`, data, (err) => {
if (err)
throw err;
console.log(`${cast.hash} processed`);
});
};
const fetchAndDump = async(fid, cursor) => {
const data = await client.fetchAllCastsCreatedByUser(fid, {
cursor,
limit: 150
});
data.result.casts.map(dumpCast);
if (data.result.next.cursor === null)
return; /// if no cursor, fin
await fetchAndDump(fid, data.result.next.cursor);
};
/*** PROGRAM ------------------------------------------ ***/
fetchAndDump(fid);
/*** deno run --allow-env --allow-net --allow-write export_farcaster.ts ***/
```
This will only export your public posts, not your DMs. If you don't
want to pay Neynar[2], you can use these[3] projects[4].
References
[1] <https://github.com/neynarxyz/farcaster-examples/blob/6922ac07fe7b601e3b1712a7f9c54a396dad66f8/archiver-script/index.js>
[2] <https://neynar.com>
[3] <https://github.com/iammatthias/fcau>
[4] <https://github.com/vrypan/fario>
|