{"id":23061800,"url":"https://github.com/rrwen/twitter2pg","last_synced_at":"2026-03-09T01:32:19.061Z","repository":{"id":57382925,"uuid":"110313516","full_name":"rrwen/twitter2pg","owner":"rrwen","description":"Module for extracting Twitter data to PostgreSQL databases","archived":false,"fork":false,"pushed_at":"2017-12-13T01:12:23.000Z","size":1328,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-25T01:57:31.817Z","etag":null,"topics":["access","api","data","database","geo","get","location","media","oauth","pg","post","postgres","postgresql","rest","sample","social","stream","token","tweet","twitter"],"latest_commit_sha":null,"homepage":"https://rrwen.github.io/twitter2pg","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rrwen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-11T03:06:02.000Z","updated_at":"2022-03-01T22:27:14.000Z","dependencies_parsed_at":"2022-09-11T04:10:40.668Z","dependency_job_id":null,"html_url":"https://github.com/rrwen/twitter2pg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rrwen/twitter2pg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrwen%2Ftwitter2pg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrwen%2Ftwitter2pg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrwen%2Ftwitter2pg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrwen%2Ftwitter2pg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rrwen","download_url":"https://codeload.github.com/rrwen/twitter2pg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rrwen%2Ftwitter2pg/sbom","scorecard":{"id":786766,"data":{"date":"2025-08-11","repo":{"name":"github.com/rrwen/twitter2pg","commit":"d7ee06ce5578b98a2d04e9c0809ec4f7f002870c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-23T06:18:15.573Z","repository_id":57382925,"created_at":"2025-08-23T06:18:15.573Z","updated_at":"2025-08-23T06:18:15.573Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30279777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-08T20:45:49.896Z","status":"ssl_error","status_checked_at":"2026-03-08T20:45:49.525Z","response_time":56,"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":["access","api","data","database","geo","get","location","media","oauth","pg","post","postgres","postgresql","rest","sample","social","stream","token","tweet","twitter"],"created_at":"2024-12-16T03:18:32.289Z","updated_at":"2026-03-09T01:32:19.028Z","avatar_url":"https://github.com/rrwen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# twitter2pg\n\nRichard Wen  \nrrwen.dev@gmail.com  \n\n* [Documentation](https://rrwen.github.io/twitter2pg)\n\nModule for extracting Twitter data to PostgreSQL databases.\n\n[![npm version](https://badge.fury.io/js/twitter2pg.svg)](https://badge.fury.io/js/twitter2pg)\n[![Build Status](https://travis-ci.org/rrwen/twitter2pg.svg?branch=master)](https://travis-ci.org/rrwen/twitter2pg)\n[![Coverage Status](https://coveralls.io/repos/github/rrwen/twitter2pg/badge.svg?branch=master)](https://coveralls.io/github/rrwen/twitter2pg?branch=master)\n[![npm](https://img.shields.io/npm/dt/twitter2pg.svg)](https://www.npmjs.com/package/twitter2pg)\n[![GitHub license](https://img.shields.io/github/license/rrwen/twitter2pg.svg)](https://github.com/rrwen/twitter2pg/blob/master/LICENSE)\n[![Twitter](https://img.shields.io/twitter/url/https/github.com/rrwen/twitter2pg.svg?style=social)](https://twitter.com/intent/tweet?text=Module%20for%20extracting%20Twitter%20data%20to%20PostgreSQL%20databases:%20https%3A%2F%2Fgithub.com%2Frrwen%2Ftwitter2pg%20%23nodejs%20%23npm)\n\n## Install\n\n1. Install [PostgreSQL](https://www.postgresql.org/)\n2. Install [Node.js](https://nodejs.org/en/)\n3. Install [twitter2pg](https://www.npmjs.com/package/twitter2pg) via `npm`\n\n```\nnpm install --save twitter2pg\n```\n\nFor the latest developer version, see [Developer Install](#developer-install).\n\n## Usage\n\nThe usage examples show how to get Twitter data into a PostgreSQL table named `twitter_data` with a `tweets` jsonb column:\n\nrow | tweets\n--- | ---\n1 | {...}\n2 | {...}\n3 | {...}\n... | ...\n\nCreate an appropriate PostgreSQL table with [psql](https://www.postgresql.org/docs/current/static/app-psql.html) before running the usage examples:\n\n* `-h`: host address\n* `-p`: port number\n* `-d`: database name\n* `-U`: user name with table creation permissions\n* `-c`: PostgreSQL query\n\n```\npsql -h localhost -p 5432 -d postgres -U postgres -c \"CREATE TABLE twitter_data(tweets jsonb);\"\n```\n\n### REST API\n\n1. Search for tweets with keyword `twitter` using  a GET request\n2. Filter tweets with [jsonata](https://www.npmjs.com/package/jsonata) to only return the array inside `statuses`\n3. Insert the filtered tweets into a PostgreSQL table named `twitter_data`\n4. Each row of the `tweets` column in the `twitter_data` table contains one tweet\n\n```javascript\nvar twitter2pg = require('twitter2pg');\n\noptions = {\n\tpg: {},\n\ttwitter: {},\n\tjsonata: 'statuses' // filter tweets for statuses array only\n};\n\n// (options_twitter) Twitter API options\noptions.twitter = {\n\tmethod: 'get', // get, post, delete, or stream\n\tpath: 'search/tweets', // api path\n\tparams: {q: 'twitter'} // query tweets\n};\n\n// (options_twitter_connection) Twitter API connection keys\noptions.twitter.connection =  {\n\tconsumer_key: '***', // default: process.env.TWITTER_CONSUMER_KEY\n\tconsumer_secret: '***', // default: process.env.TWITTER_CONSUMER_SECRET\n\taccess_token_key: '***', // default: process.env.TWITTER_ACCESS_TOKEN_KEY\n\taccess_token_secret: '***' // default: process.env.TWITTER_ACCESS_TOKEN_SECRET\n};\n\n// (options_pg) PostgreSQL options\n// In query, $1 are the JSON tweets\noptions.pg = {\n\ttable: 'twitter_data',\n\tcolumn: 'tweets',\n\tquery: 'INSERT INTO $options.pg.table($options.pg.column) SELECT * FROM json_array_elements($1);'\n};\n\n// (options_pg_connection) PostgreSQL connection details\noptions.pg.connection = {\n\thost: 'localhost', // default: process.env.PGHOST\n\tport: 5432, // default: process.env.PGPORT\n\tdatabase: 'postgres', // default: process.env.PGDATABASE\n\tuser: 'postgres', // default: process.env.PGUSER\n\tpassword: '***' // default: process.env.PGPASSWORD\n};\n\n// (twitter2pg_rest) Query tweets using REST API into PostgreSQL table\ntwitter2pg(options).catch(err =\u003e {\n\tconsole.error(err.message);\n});\n```\n\n### Stream API\n\n1. Stream tweets to track keyword `twitter`\n2. When a tweet is available, insert the tweet into a PostgreSQL table named `twitter_data`\n3. Each tweet is inserted as one row in the `tweets` column of the `twitter_data` table\n\n```javascript\nvar twitter2pg = require('twitter2pg');\n\noptions = {};\n\n// (options_twitter) Twitter API options\noptions.twitter = {\n\tmethod: 'stream', // get, post, delete, or stream\n\tpath: 'statuses/filter',// api path\n\tparams: {track: 'twitter'} // track tweets\n};\n\n// (options_twitter_connection) Twitter API connection keys\noptions.twitter.connection =  {\n\tconsumer_key: '***', // default: process.env.TWITTER_CONSUMER_KEY\n\tconsumer_secret: '***', // default: process.env.TWITTER_CONSUMER_SECRET\n\taccess_token_key: '***', // default: process.env.TWITTER_ACCESS_TOKEN_KEY\n\taccess_token_secret: '***' // default: process.env.TWITTER_ACCESS_TOKEN_SECRET\n};\n\n// (options_pg) PostgreSQL options\n// In query, $1 are the JSON tweets\noptions.pg = {\n\ttable: 'twitter_data',\n\tcolumn: 'tweets',\n\tquery: 'INSERT INTO $options.pg.table($options.pg.column) VALUES($1);'\n};\n\n// (options_pg_connection) PostgreSQL connection details\noptions.pg.connection = {\n\thost: 'localhost', // default: process.env.PGHOST\n\tport: 5432, // default: process.env.PGPORT\n\tdatabase: 'postgres', // default: process.env.PGDATABASE\n\tuser: 'postgres', // default: process.env.PGUSER\n\tpassword: '***' // default: process.env.PGPASSWORD\n};\n\n// (twitter2pg_stream) Stream tweets into PostgreSQL table\nvar stream = twitter2pg(options);\nstream.on('error', function(error) {\n\tconsole.error(error.message);\n});\n```\n\nSee [Documentation](https://rrwen.github.io/twitter2pg) for more details.\n\n## Contributions\n\n### Report Contributions\n\nReports for issues and suggestions can be made using the [issue submission](https://github.com/rrwen/twitter2pg/issues) interface.\n\nWhen possible, ensure that your submission is:\n\n* **Descriptive**: has informative title, explanations, and screenshots\n* **Specific**: has details of environment (such as operating system and hardware) and software used\n* **Reproducible**: has steps, code, and examples to reproduce the issue\n\n### Code Contributions\n\nCode contributions are submitted via [pull requests](https://help.github.com/articles/about-pull-requests/):\n\n1. Ensure that you pass the [Tests](#tests)\n2. Create a new [pull request](https://github.com/rrwen/twitter2pg/pulls)\n3. Provide an explanation of the changes\n\nA template of the code contribution explanation is provided below:\n\n```\n## Purpose\n\nThe purpose can mention goals that include fixes to bugs, addition of features, and other improvements, etc.\n\n## Description\n\nThe description is a short summary of the changes made such as improved speeds or features, and implementation details.\n\n## Changes\n\nThe changes are a list of general edits made to the files and their respective components.\n* `file_path1`:\n    * `function_module_etc`: changed loop to map\n    * `function_module_etc`: changed variable value\n* `file_path2`:\n    * `function_module_etc`: changed loop to map\n    * `function_module_etc`: changed variable value\n\n## Notes\n\nThe notes provide any additional text that do not fit into the above sections.\n```\n\nFor more information, see [Developer Install](#developer-install) and [Implementation](#implementation).\n\n## Developer Notes\n\n### Developer Install\n\nInstall the latest developer version with `npm` from github:\n\n```\nnpm install git+https://github.com/rrwen/twitter2pg\n```\n  \nInstall from `git` cloned source:\n\n1. Ensure [git](https://git-scm.com/) is installed\n2. Clone into current path\n3. Install via `npm`\n\n```\ngit clone https://github.com/rrwen/twitter2pg\ncd twitter2pg\nnpm install\n```\n\n### Tests\n\n1. Clone into current path `git clone https://github.com/rrwen/twitter2pg`\n2. Enter into folder `cd twitter2pg`\n3. Ensure [devDependencies](https://docs.npmjs.com/files/package.json#devdependencies) are installed and available\n4. Run tests with a `.env` file (see [tests/README.md](tests/README.md))\n5. Results are saved to [tests/log](tests/log) with each file corresponding to a version tested\n\n```\nnpm install\nnpm test\n```\n\n### Documentation\n\nUse [documentationjs](https://www.npmjs.com/package/documentation) to generate html documentation in the `docs` folder:\n\n```\nnpm run docs\n```\n\nSee [JSDoc style](http://usejsdoc.org/) for formatting syntax.\n\n### Upload to Github\n\n1. Ensure [git](https://git-scm.com/) is installed\n2. Inside the `twitter2pg` folder, add all files and commit changes\n3. Push to github\n\n```\ngit add .\ngit commit -a -m \"Generic update\"\ngit push\n```\n\n### Upload to npm\n\n1. Update the version in `package.json`\n2. Run tests and check for OK status (see [tests/README.md](tests/README.md))\n3. Generate documentation\n4. Login to npm\n5. Publish to npm\n\n```\nnpm test\nnpm run docs\nnpm login\nnpm publish\n```\n\n### Implementation\n\nThe module [twitter2pg](https://www.npmjs.com/package/twitter2pg) uses the following [npm](https://www.npmjs.com/) packages for its implementation:\n\nnpm | Purpose\n--- | ---\n[twitter2return](https://www.npmjs.com/package/twitter2return) | Connections to the Twitter API REST and Streaming Application Programming Interfaces (APIs) using [twitter](https://www.npmjs.com/package/twitter), and Filters with [jsonata](https://www.npmjs.com/package/jsonata) before inserting into PostgreSQL\n[pg](https://www.npmjs.com/package/pg) | Insert Twitter data to PostgreSQL tables\n\n```\ntwitter2return   \u003c-- Extract Twitter data from API and Filter JSON data\n    |\n   pg            \u003c-- Insert filtered Twitter data into PostgreSQL table\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frrwen%2Ftwitter2pg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frrwen%2Ftwitter2pg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frrwen%2Ftwitter2pg/lists"}