{"id":19462925,"url":"https://github.com/uninen/tweets-to-json","last_synced_at":"2026-05-12T13:44:18.069Z","repository":{"id":43353849,"uuid":"321465621","full_name":"Uninen/tweets-to-json","owner":"Uninen","description":"Save your tweets into a JSON file using Twitter API","archived":false,"fork":false,"pushed_at":"2023-12-15T20:14:46.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"trunk","last_synced_at":"2025-02-25T12:49:48.983Z","etag":null,"topics":["api","json","tweets","twitter"],"latest_commit_sha":null,"homepage":"https://gitlab.com/uninen/tweets-to-json","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Uninen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-14T20:32:26.000Z","updated_at":"2020-12-16T22:25:47.000Z","dependencies_parsed_at":"2025-02-25T12:49:36.946Z","dependency_job_id":"fa2403d4-8734-49e8-9844-1ad00aabcdab","html_url":"https://github.com/Uninen/tweets-to-json","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Uninen/tweets-to-json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uninen%2Ftweets-to-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uninen%2Ftweets-to-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uninen%2Ftweets-to-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uninen%2Ftweets-to-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Uninen","download_url":"https://codeload.github.com/Uninen/tweets-to-json/tar.gz/refs/heads/trunk","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Uninen%2Ftweets-to-json/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32942142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-12T09:19:52.626Z","status":"ssl_error","status_checked_at":"2026-05-12T09:17:33.438Z","response_time":102,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","json","tweets","twitter"],"created_at":"2024-11-10T18:06:41.412Z","updated_at":"2026-05-12T13:44:18.049Z","avatar_url":"https://github.com/Uninen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Save your tweets into a JSON file using Twitter API. You can run it programatically (for example with GitLab or GitHub CI) to automatically keep a JSON archive of your tweets.\n\nThis was originally built for an easy way to provide external data to Hugo data templates.\n\nNote: this script is not intended for huge datasets, it handles all tweets in memory. According to [user_timeline docs](https://developer.twitter.com/en/docs/twitter-api/v1/tweets/timelines/api-reference/get-statuses-user_timeline) it \"can only return up to 3,200 of a user's most recent Tweets\". YMMV. Read also [about Twitter's rate limits](https://developer.twitter.com/en/docs/rate-limits).\n\n## Configuration\n\n1. Get `Bearer token` key for your app from [Twitter Developer Portal](https://developer.twitter.com/en/portal/dashboard) and add it to `TWITTER_BEARER_TOKEN` environment variable (or to `.env` file in the root of your project)\n2. Create `tweets-to-json-config.js` with `searchParams` and `exportFn` (see example below)\n\n## Usage\n\nWhen you run `tweets-to-json` first time, a `tweets.json` file (can be overrided) is created in the same directory and all your tweets are saved into it. Subsequent invocations will check the file, take the latest tweets ID, and only query for tweets after that ID. The tweets are saved in order, latest tweet first.\n\nIf you run this from CI, you might find `--fail-when-zero` flag handy as it returns error code 1 when there are no tweets.\n\n```\nUsage: tweets-to-json -o \u003cfilepath\u003e [options]\n\nOptions:\n  -o, --output-file \u003cfilepath\u003e  specify where to output the tweets (default: \"./tweets.json\")\n  --fail-when-zero              return exit status 1 if no new tweets are found\n  -V, --version                 output the version number\n  -h, --help                    display help for command\n```\n\n## Example configuration\n\nFull example of `tweets-to-json.config.js`:\n\n```js\nconst dayjs = require('dayjs')\n\nmodule.exports = {\n  searchParams: {\n    screen_name: 'uninen',\n    exclude_replies: true,\n    trim_user: true,\n    tweet_mode: 'extended',\n    count: 100,\n  },\n  exportFn: (result) =\u003e {\n    const tags = []\n    const mentions = []\n    const media = []\n    const urls = []\n\n    if (result.entities.hashtags \u0026\u0026 result.entities.hashtags.length \u003e 0) {\n      for (const tag of result.entities.hashtags) {\n        tags.push(tag.text)\n      }\n    }\n    if (\n      result.entities.user_mentions \u0026\u0026\n      result.entities.user_mentions.length \u003e 0\n    ) {\n      for (const user of result.entities.user_mentions) {\n        mentions.push(user.screen_name)\n      }\n    }\n    if (result.entities.media \u0026\u0026 result.entities.media.length \u003e 0) {\n      for (const obj of result.entities.media) {\n        media.push({\n          url: obj.media_url_https,\n          tco_url: obj.url,\n        })\n      }\n    }\n    if (result.entities.urls \u0026\u0026 result.entities.urls.length \u003e 0) {\n      for (const url of result.entities.urls) {\n        urls.push({\n          tco_url: url.url,\n          url: url.expanded_url,\n        })\n      }\n    }\n\n    return {\n      id: result.id_str,\n      text: result.full_text,\n      urls: urls,\n      tags: tags,\n      media: media,\n      mentions: mentions,\n      timestamp: dayjs(result.created_at).unix(),\n    }\n  },\n}\n```\n\n## Contributing\n\nAll contributions are welcome! Please follow the [code of conduct](https://www.contributor-covenant.org/version/2/0/code_of_conduct/) when interacting with others.\n\n[This project lives on GitLab](https://gitlab.com/uninen/tweets-to-json) and is mirrored on GitHub.\n\n[Follow @Uninen](https://twitter.com/uninen) on Twitter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funinen%2Ftweets-to-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funinen%2Ftweets-to-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funinen%2Ftweets-to-json/lists"}