Back to APIs list

Twitter API examples & templates

Use these vals as a playground to view and fork Twitter API examples and templates on Val Town. Run any example below or find templates that can be used as a pre-built solution.
Akash11 avatar
Akash11
twitterAlert
Cron
Forked from valdottown/templateTwitterAlert
1
stevekrouse avatar
stevekrouse
twitterAlert
Cron
Twitter/๐• keyword alerts Custom notifications for when you, your company, or anything you care about is mentioned on Twitter. If you believe in Twitter/๐•-driven development, you want to get notified when anyone is talking about your tech, even if they're not tagging you. To get this Twitter Alert bot running for you, fork this val and modify the query and where the notification gets delivered. 1. Query Change the keywords for what you want to get notified for and the excludes for what you don't want to get notified for. You can use Twitter's search operators to customize your query, for some collection of keywords, filtering out others, and much more! 2. Notification Below I'm sending these mentions to a public channel in our company Discord, but you can customize that to whatever you want, @std/email, Slack, Telegram, whatever. Twitter Data & Limitations The Twitter API has become unusable. This val gets Twitter data via SocialData , an affordable Twitter scraping API. In order to make this val easy for you to fork & use without signing up for another API, I am proxying SocialData via @stevekrouse/socialDataProxy. Val Town Pro users can call this proxy a limited amount per day. If you want to run it more, get your own SocialData API token and pay for it directly.
5
nulo avatar
nulo
archivoTwitterMilei
Cron
An interactive, runnable TypeScript val by nulo
0
alexdphan avatar
alexdphan
twitterSearch
HTTP
An interactive, runnable TypeScript val by alexdphan
1
stevekrouse avatar
stevekrouse
twitterSearch
Script
An interactive, runnable TypeScript val by stevekrouse
2
sarahxc avatar
sarahxc
slackScout
Cron
Slack scout sends a slack notification every time your keywords are mentioned on Twitter, Hacker News, or Reddit. Get notified whenever you, your company, or topics of interest are mentioned online. Built with Browserbase . Inspired by f5bot.com . Full code tutorial . Getting Started To run Slack Scout, youโ€™ll need a Browserbase API key Slack Webhook URL: setup here Twitter Developer API key Browserbase Browserbase is a developer platform to run, manage, and monitor headless browsers at scale. Weโ€™ll use Browserbase to navigate to, and scrape our different news sources. Weโ€™ll also use Browserbaseโ€™s Proxies to ensure we simulate authentic user interactions across multiple browser sessions . Get started with Browserbase for free here . Twitter Weโ€™ve decided to use the Twitter API to include Twitter post results. It costs $100 / month to have a Basic Twitter Developer account. If you decide to use Browserbase, we can lend our token. Comment below for access. Once you have the SLACK_WEBHOOK_URL , BROWSERBASE_API_KEY , and TWITTER_BEARER_TOKEN , input all of these as Val Town Environment Variables . Project created by Sarah Chieng and Alex Phan ๐Ÿ’Œ
15
stevekrouse avatar
stevekrouse
socialDataSearch
Script
Helper function to call SocialData Twitter Search API, via my proxy: @stevekrouse/socialDataProxy
0
valdottown avatar
valdottown
templateTwitterAlert
Cron
Twitter/๐• Keyword Alerts [TEMPLATE] Get custom notifications when you, your company, or anything you care about is mentioned on Twitter/X, even if they don't tag you directly. This template will help you: Search for specific mentions on Twitter/X using customizable keywords. Deliver notifications wherever you'd like (email, Discord, Slack, Telegram, etc). Example This val tracks mentions of "Val Town" and related terms, excluding noise like retweets and irrelevant accounts. Notifications are sent to a Discord webhook but can be easily reconfigured for other platforms. To see exactly how we use this template at Val Town: https://www.val.town/v/stevekrouse/twitterAlert Set Up 1. Fork this Val To use this template, fork this val on the top right corner of this page. 2. View Source Code The CODE box shows you the the full source code of this val, you may need to scroll down to see it. 3. Customize Query Define what you want to search for by modifying query : const query = "\"val.town\" OR \"val.run\" OR \"val town\" -_ValTown_ -is:retweet -from:valenzuelacity -from:val__run"; Refer to Twitter's search operators to fine-tune your query. 4. Test API call Set isProd = false in the code if you are testing, to ensure there are enough tweets to display. Toggle it back to true when you're ready to run this cron job in production and actuall send notifications. 5. Choose Notification Method This template uses a Discord webhook for notifications, but you can update this to your preferred platform by replacing the discordWebhook call with a call to Slack , @std/email , etc. Create a Discord webhook following this guide . Save your Discord Webhook URL in your Val Town environment variables : Key: mentionsDiscord Value: Your Discord webhook URL. Notifications will be sent using this function: await discordWebhook({ url: Deno.env.get("mentionsDiscord"), content, }); ๐ŸŽ‰ Congrats! You now have a val running that ensures you never miss another Twitter/X mention. ๐ŸŽ‰ NOTE: Usage Limits This val uses the SocialData API for Twitter data: Proxies via Val Town's SocialDataProxy : Limited to 10 cents per day for Val Town Pro users . This API is only for Pro users. Need more calls? Sign up for your own SocialData API token and configure the socialDataSearch function.
0
buttondown avatar
buttondown
twitterAlert
Cron
Forked from stevekrouse/twitterAlert
0
charmaine avatar
charmaine
socialDataUpdate
HTTP
Forked from charmaine/twitterRecentMentions
0
eseidel avatar
eseidel
twitterAlert
Cron
Forked from stevekrouse/twitterAlert
0
andreterron avatar
andreterron
twitter
Script
Login with ~~Twitter~~ ๐• Use this val to login with ๐• and save your token into a twitter_token val Usage Fork this val Change the ๐Ÿ”’ privacy to "Unlisted" Navigate to https://developer.twitter.com/en/portal/dashboard to create an OAuth app and save your client id and secret to your secrets page Navigate to https://{your_username}-twitter.web.val.run to authenticate with ๐• And then you'll have your tokens saved to a twitter_token val! Other ~~Twitter~~ ๐• helper vals Refresh your tokens: https://www.val.town/v/andreterron/refreshTwitterToken Fetch user by id: https://www.val.town/v/andreterron/fetchTwitterUser Search posts: https://www.val.town/v/andreterron/searchTweets Write an X post: https://www.val.town/v/andreterron/postTweet
3
charmaine avatar
charmaine
twitterRecentMentions
HTTP
// This val fetches recent tweets about @SnapAR or Lens Studio
3
ted avatar
ted
twitterPoll
Script
An interactive, runnable TypeScript val by ted
0
jamiedubs avatar
jamiedubs
twitterSearch
Script
Forked from stevekrouse/twitterSearch
0
stevekrouse avatar
stevekrouse
populateTwitterDB
Script
Poll Twitter & Populate SQlite database The twitter API (or in this case someone else's wrapper over the twitter API) is finicky, so we just try to get one handle per minute, and shove whatever we get into our database, which could be an error message (this is why handles don't have a unique index).
0