![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
tweets-to-json
Advanced tools
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.
This was originally built for an easy way to provide external data to Hugo data templates.
Note: according to user_timeline docs it "can only return up to 3,200 of a user's most recent Tweets". YMMV. Read also about Twitter's rate limits.
Bearer token
key for your app from Twitter Developer Portal and add it to TWITTER_BEARER_TOKEN
environment variable.tweets-to-json-config.js
with searchParams
and exportFn
(see example below)When 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 last.
With yarn
or npm
:
yarn tweets-to-json -h
Usage: tweets-to-json [options]
Options:
-o, --output-file <filepath> specify where to output the tweets (default: "./tweets.json")
-V, --version output the version number
-h, --help display help for command
Full example of tweets-to-json.config.js
:
const dayjs = require('dayjs')
module.exports = {
searchParams: {
screen_name: 'uninen',
exclude_replies: true,
trim_user: true,
tweet_mode: 'extended',
count: 100,
},
exportFn: (result) => {
const tags = []
const mentions = []
const media = []
const urls = []
if (result.entities.hashtags && result.entities.hashtags.length > 0) {
for (const tag of result.entities.hashtags) {
tags.push(tag.text)
}
}
if (
result.entities.user_mentions &&
result.entities.user_mentions.length > 0
) {
for (const user of result.entities.user_mentions) {
mentions.push(user.screen_name)
}
}
if (result.entities.media && result.entities.media.length > 0) {
for (const obj of result.entities.media) {
media.push({
url: obj.media_url_https,
tco_url: obj.url,
})
}
}
if (result.entities.urls && result.entities.urls.length > 0) {
for (const url of result.entities.urls) {
urls.push({
tco_url: url.url,
url: url.expanded_url,
})
}
}
return {
id: result.id_str,
text: result.full_text,
urls: urls,
tags: tags,
media: media,
mentions: mentions,
timestamp: dayjs(result.created_at).unix(),
}
},
}
All contributions are welcome! Please follow the code of conduct when interacting with others.
Follow @Uninen on Twitter.
FAQs
Save your tweets into a JSON file.
The npm package tweets-to-json receives a total of 8 weekly downloads. As such, tweets-to-json popularity was classified as not popular.
We found that tweets-to-json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.