<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sumedh Patkar</title>
    <description>The latest articles on DEV Community by Sumedh Patkar (@sumedhpatkar).</description>
    <link>https://dev.to/sumedhpatkar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F407733%2F1550ea00-d68b-4d9b-af71-8df2a5e8b452.jpeg</url>
      <title>DEV Community: Sumedh Patkar</title>
      <link>https://dev.to/sumedhpatkar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sumedhpatkar"/>
    <language>en</language>
    <item>
      <title>How to create a Twitter Bot using Node.js and Heroku</title>
      <dc:creator>Sumedh Patkar</dc:creator>
      <pubDate>Sat, 25 Jul 2020 14:39:49 +0000</pubDate>
      <link>https://dev.to/sumedhpatkar/how-i-created-a-twitter-bot-using-node-js-and-heroku-368b</link>
      <guid>https://dev.to/sumedhpatkar/how-i-created-a-twitter-bot-using-node-js-and-heroku-368b</guid>
      <description>&lt;p&gt;Making a twitter bot is one of the many use cases of using the Twitter API. A bot can be used to enhance your business, assist customers through automated replies, automate retweets for specific terms, and a lot more. &lt;br&gt;
This article is about how I created &lt;a href="https://twitter.com/datasciencebot_" rel="noopener noreferrer"&gt;&lt;code&gt;The Data Science Bot&lt;/code&gt;&lt;/a&gt; using Node.js.&lt;/p&gt;
&lt;h1&gt;
  
  
  Table Of Contents
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Apply for Twitter developer account&lt;/li&gt;
&lt;li&gt;Create app on twitter&lt;/li&gt;
&lt;li&gt;Setup dev environment&lt;/li&gt;
&lt;li&gt;Write code in nodejs&lt;/li&gt;
&lt;li&gt;Deploy to heroku&lt;/li&gt;
&lt;li&gt;How to avoid duplication of retweets&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvqmfaofwi3rqvcvenkcw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvqmfaofwi3rqvcvenkcw.gif" alt="Let's start"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;    &lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Step 1: Apply for Twitter Developer Account&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This is the most important and perhaps the most difficult step according to me.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Login into &lt;a href="https://twitter.com" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Go to &lt;a href="https://developer.twitter.com/en/apply-for-access" rel="noopener noreferrer"&gt;developers.twitter.com&lt;/a&gt; and click on 'Apply for a Developer account'&lt;/li&gt;
&lt;li&gt;Select the type of application i.e. student/business/hobbyist, etc.&lt;/li&gt;
&lt;li&gt;Mention the purpose of your application.
Be as specific as you can over here.
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Make sure you have read the &lt;a href="https://developer.twitter.com/en/developer-terms/agreement-and-policy" rel="noopener noreferrer"&gt;Developer Agreement and Policy&lt;/a&gt;, &lt;a href="https://help.twitter.com/en/rules-and-policies/twitter-automation" rel="noopener noreferrer"&gt;Automation rules&lt;/a&gt; and &lt;a href="https://help.twitter.com/en/rules-and-policies/twitter-rules" rel="noopener noreferrer"&gt;The Twitter Rules&lt;/a&gt; thoroughly before applying.&lt;/p&gt;

&lt;p&gt;Failing to meet these conditions will cause your application to be rejected&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Read the full article&lt;/strong&gt; on &lt;a href="https://dev.to/sumedhpatkar/beginners-guide-how-to-apply-for-a-twitter-developer-account-1kh7"&gt;How to apply for a twitter developer Account&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;    &lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Step 2: Create app on twitter&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Once your twitter developer account access has been approved.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create an APP on &lt;a href="https://developer.twitter.com/en/apps" rel="noopener noreferrer"&gt;apps.twitter.com&lt;/a&gt;.&lt;br&gt;
Fill in the required details.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate API keys. Click on your apps details and navigate to &lt;code&gt;Keys and tokens&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjqg8e9bg11aj5mbjh8q2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjqg8e9bg11aj5mbjh8q2.png" alt="Generate Keys"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Warning&lt;/strong&gt; (Don't reveal the API keys in any case).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;    &lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Step 3: Setup Development Environment&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Make sure you have Node.js and npm installed on your PC.&lt;/p&gt;

&lt;p&gt;For Ubuntu, install using the following commands&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;nodejs
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;npm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For other distributions, click &lt;a href="https://nodejs.org/en/" rel="noopener noreferrer"&gt;here&lt;/a&gt; for installation instructions.&lt;/p&gt;

&lt;p&gt;Create a directory named &lt;code&gt;your-botname&lt;/code&gt;.&lt;br&gt;
In my case, I have named it &lt;code&gt;the-datascience-bot&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To initialize the git environment and install the package &lt;code&gt;twit&lt;/code&gt; using &lt;code&gt;npm&lt;/code&gt;, enter the following commands &lt;em&gt;inside&lt;/em&gt; the &lt;code&gt;your-botname&lt;/code&gt; directory: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpiar6f0axdautjbthjjc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fpiar6f0axdautjbthjjc.png" alt="init env"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Congratulations! You have successfully set up your Node.js DEV environment 🎉🎉&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;    &lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Step 4: Code&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Firstly, we have to authenticate &lt;code&gt;twit&lt;/code&gt;.
To do this, we will link our twitter app and code using the generated &lt;em&gt;API keys&lt;/em&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Create a file named &lt;code&gt;config.js&lt;/code&gt;.&lt;br&gt;
Put the following code in your &lt;code&gt;config.js&lt;/code&gt; file&lt;/p&gt;
&lt;h4&gt;
  
  
  config.js
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgfhcsvimg5o28ctkpr61.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fgfhcsvimg5o28ctkpr61.png" alt="config.js"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Put your keys copied from your twitter apps dashboard.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next, we write the code for the bot in a file &lt;code&gt;bot.js&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is the code.  &lt;/p&gt;
&lt;h4&gt;
  
  
  bot.js
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./config&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;twit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;twit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;twit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;retweet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;searchText&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Params to be passed to the 'search/tweets' API endpoint&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;q&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;searchText&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;result_type&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mixed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;count&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;search/tweets&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err_search&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data_search&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;response_search&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;

        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tweets&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;data_search&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;statuses&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;err_search&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tweetIDList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
            &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tweet&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;tweets&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;tweetIDList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tweet&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id_str&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

                &lt;span class="c1"&gt;//more code here later...&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="c1"&gt;// Call the 'statuses/retweet/:id' API endpoint for retweeting EACH of the tweetID&lt;/span&gt;
            &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;tweetID&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;tweetIDList&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;statuses/retweet/:id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;tweetID&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err_rt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data_rt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;response_rt&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
                    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;err_rt&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
                        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n\n&lt;/span&gt;&lt;span class="s2"&gt;Retweeted! ID - &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;tweetID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="p"&gt;}&lt;/span&gt;
                    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;Error... Duplication maybe... &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;tweetID&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error = &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;err_rt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                    &lt;span class="p"&gt;}&lt;/span&gt;
                &lt;span class="p"&gt;})&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error while searching&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;err_search&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Run every 60 seconds&lt;/span&gt;
&lt;span class="nf"&gt;setInterval&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nf"&gt;retweet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#DataScience OR #DataVisualization&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;60000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Let's break it down.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We initialize the twit object using our configuration details from &lt;code&gt;config.js&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The retweet function first calls the &lt;code&gt;search/tweets&lt;/code&gt; API endpoint for the given search query.
In my case, it is &lt;strong&gt;&lt;em&gt;'#DataScience OR #DataVisualization'&lt;/em&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;We pass the following parameters to search API

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;q&lt;/code&gt;: The search query&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;result_type&lt;/code&gt;: &lt;em&gt;'mixed'&lt;/em&gt; for latest as well as popular older tweets&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;count&lt;/code&gt;: number of tweets to retrieve at once&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The retrieved &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON" rel="noopener noreferrer"&gt;JSON&lt;/a&gt; object has the list of tweets having either #DataScience or #DataVisualization in it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-We then pass each of the tweet IDs to the &lt;code&gt;statuses/retweet/:id&lt;/code&gt; API endpoint, which retweets the tweet.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Detailed API reference guides for &lt;a href="https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets" rel="noopener noreferrer"&gt;Search&lt;/a&gt; and &lt;a href="https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-retweet-id" rel="noopener noreferrer"&gt;Retweet&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Test the bot locally using the following command:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node bot.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Your Twitter timeline should show the retweets.&lt;/p&gt;

&lt;p&gt;Try debugging on the console if it doesn't work.&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;    &lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Step 5: Deploy to Heroku&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Create an account on &lt;a href="https://www.heroku.com/" rel="noopener noreferrer"&gt;Heroku&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Create an app named 'your-botname' on Heroku&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdvovig9254f7gue1g5wk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdvovig9254f7gue1g5wk.png" alt="Create new app button"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fi4p8r8uxmkywrnhnfwfm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fi4p8r8uxmkywrnhnfwfm.png" alt="Heroku New App"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Make sure the name of your local project directory is exactly the same as your Heroku project name.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;strong&gt;heroku-cli&lt;/strong&gt; on your pc&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you have an &lt;em&gt;Ubuntu/Debian&lt;/em&gt; based distribution, then use the following command to install &lt;code&gt;heroku-cli&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl https://cli-assets.heroku.com/install-ubuntu.sh | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For other environments, the installation instructions can be found &lt;a href="https://devcenter.heroku.com/articles/heroku-cli" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a file named 'Procfile' having the following code&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Procfile
&lt;/h4&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;worker: node bot.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Login to heroku CLI
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ heroku login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will open a login link on heroku, where you have to enter your password.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deploy to Heroku using these commands
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2km8dhr85p97fjg7ohqj.png" alt="Deploy Heroku commands"&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  &lt;strong&gt;One last step&lt;/strong&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;Start the &lt;code&gt;worker&lt;/code&gt; dyno on Heroku.&lt;/em&gt;&lt;br&gt;
Go to &lt;a href="https://dashboard.heroku.com/apps" rel="noopener noreferrer"&gt;dashboard.heroku.com/apps&lt;/a&gt; and click on your bot app.&lt;/p&gt;

&lt;p&gt;Then, click on configure Dynos&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzms7x1rku1b0yv2ibotg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzms7x1rku1b0yv2ibotg.png" alt="Configure Dynos"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Start the &lt;code&gt;worker&lt;/code&gt; dyno and click on confirm&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foyofou2peuwfggw0ui1y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Foyofou2peuwfggw0ui1y.png" alt="Start worker dyno"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  And your bot is Ready! 🎉🎉
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxted0ahf6jgg2jexdcj7.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxted0ahf6jgg2jexdcj7.gif" alt="bot_dancing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a&gt;&lt;/a&gt;    &lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Step 6: How to avoid duplication of retweets&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Add the following code in the for loop where we wrote &lt;br&gt;
&lt;code&gt;//more code here later..&lt;/code&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Check duplication
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flsewjukfk6qa920ffm4m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Flsewjukfk6qa920ffm4m.png" alt="Check Duplication"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then outside the loop -&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Utility function - Gives unique elements from an array&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;onlyUnique&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;indexOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Get only unique entries&lt;/span&gt;
&lt;span class="nx"&gt;tweetIDList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tweetIDList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;onlyUnique&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The utility function &lt;code&gt;onlyUnique&lt;/code&gt; can be written outside the retweet function as well.&lt;/p&gt;

&lt;p&gt;This will let our bot avoid duplicate retweets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Short explanation of the above code&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Each tweet has a unique property &lt;code&gt;id_str&lt;/code&gt;.&lt;br&gt;
If you retweet someone's tweet, it has a different &lt;code&gt;id_str&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The search API finds both the original tweet and the retweeted ones.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When we call the &lt;code&gt;statuses/retweet/:id&lt;/code&gt; API endpoint, it retweets all of them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To a novice Twitter user, it looks like your bot has retweeted the same stuff two or more times.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Something like this 👇
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftiq4m0fe2mlakuptralq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ftiq4m0fe2mlakuptralq.png" alt="Duplicate retweets"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If tweet text starts with "RT @" then it is a retweeted tweet, with a different &lt;code&gt;id_str&lt;/code&gt; than the original.
We take the &lt;code&gt;id_str&lt;/code&gt; of the &lt;strong&gt;original tweet&lt;/strong&gt; and filter duplicates using the &lt;code&gt;onlyUnique&lt;/code&gt; function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are a lot more things you can do with the API. Check out the API reference(&lt;a href="https://developer.twitter.com/en/docs/api-reference-index" rel="noopener noreferrer"&gt;https://developer.twitter.com/en/docs/api-reference-index&lt;/a&gt;) for more details.&lt;/p&gt;
&lt;h4&gt;
  
  
  Source Code -
&lt;/h4&gt;

&lt;p&gt;The full source code can be accessed here  &lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Sumedh-Patkar" rel="noopener noreferrer"&gt;
        Sumedh-Patkar
      &lt;/a&gt; / &lt;a href="https://github.com/Sumedh-Patkar/the-datascience-bot" rel="noopener noreferrer"&gt;
        the-datascience-bot
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A Twitter bot for retweeting tweets having hashtags #DataScience, #DataVisualization
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;the-datascience-bot&lt;/h1&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/Sumedh-Patkar/the-datascience-botcover_image.jpg"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2FSumedh-Patkar%2Fthe-datascience-botcover_image.jpg" alt="Cover Image"&gt;&lt;/a&gt;
A Twitter bot for retweeting tweets having hashtags #DataScience, #DataVisualization&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/Sumedh-Patkar/the-datascience-bot" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;
 

&lt;h3&gt;
  
  
  &lt;strong&gt;The Data Science Bot&lt;/strong&gt; 🤖
&lt;/h3&gt;

&lt;p&gt;The bot retweets tweets having hashtags &lt;a href="https://twitter.com/search?q=%23DataScience" rel="noopener noreferrer"&gt;#DataScience&lt;/a&gt; and &lt;a href="https://twitter.com/search?q=%23DataVisualization" rel="noopener noreferrer"&gt;#DataVisualization&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the link to my bot &lt;a href="https://twitter.com/datasciencebot_" rel="noopener noreferrer"&gt;https://twitter.com/datasciencebot_&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1280069048202477568-524" src="https://platform.twitter.com/embed/Tweet.html?id=1280069048202477568"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1280069048202477568-524');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1280069048202477568&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;Alright, that's it!&lt;/p&gt;

&lt;p&gt;This was my first tech article on the Developer community.&lt;br&gt;
Any feedback would be greatly appreciated!&lt;/p&gt;

&lt;p&gt;Thanks for reading! 😊&lt;/p&gt;

</description>
      <category>node</category>
      <category>datascience</category>
      <category>twitter</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Beginners Guide - How to apply for a Twitter Developer account</title>
      <dc:creator>Sumedh Patkar</dc:creator>
      <pubDate>Thu, 23 Jul 2020 10:56:45 +0000</pubDate>
      <link>https://dev.to/sumedhpatkar/beginners-guide-how-to-apply-for-a-twitter-developer-account-1kh7</link>
      <guid>https://dev.to/sumedhpatkar/beginners-guide-how-to-apply-for-a-twitter-developer-account-1kh7</guid>
      <description>&lt;p&gt;Twitter is one of the biggest social networks in the world, used by millions of users worldwide, who create around half a billion tweets per day!&lt;/p&gt;

&lt;p&gt;Twitter API provides companies, developers, and users with programmatic access to Twitter public data which users have agreed to share with the world.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For newbies, think of an API as a &lt;em&gt;'middleman service'&lt;/em&gt; which acts as an intermediary between your code and Twitter's Database.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Use Cases:
&lt;/h3&gt;

&lt;p&gt;One can use the Twitter API for enhancing their business, advertising or simply exploring the API.  &lt;/p&gt;

&lt;p&gt;Some use cases are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data Analytics&lt;/li&gt;
&lt;li&gt;Making a twitter bot for automated replies&lt;/li&gt;
&lt;li&gt;Publishing and Curating&lt;/li&gt;
&lt;li&gt;Advertisement campaign &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Detailed information about the Twitter API and use cases &lt;a href="https://help.twitter.com/en/rules-and-policies/twitter-api" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For getting a Developer account, follow these steps - &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create an account on Twitter&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Go to &lt;a href="https://twitter.com/" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; and log in or sign up for an account which you would use for development.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It is recommended to create a &lt;em&gt;separate account&lt;/em&gt; for your twitter application. Especially if you are applying for enhancing your business, for creating a bot or a web-hosted app.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8d6ylx1rsyjr5vofikjg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8d6ylx1rsyjr5vofikjg.png" alt="Signup Twitter"&gt;&lt;/a&gt;   &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Apply for access&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Go to &lt;a href="https://developer.twitter.com/en/apply-for-access" rel="noopener noreferrer"&gt;developers.twitter.com&lt;/a&gt; and click on &lt;strong&gt;&lt;code&gt;Apply&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F68t6hqk5b9g1w35ofuie.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F68t6hqk5b9g1w35ofuie.png" alt="twitter developer first page"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;On the next page, click on &lt;code&gt;Apply for a Developer account&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwmk0wlhrs4t9bl9eczwl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwmk0wlhrs4t9bl9eczwl.png" alt="Apply for a developer account"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Specify the type of application&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In the next step, you will have to enter the purpose of your twitter developer account&lt;/p&gt;

&lt;p&gt;The first category is &lt;code&gt;Professional&lt;/code&gt; which is generally used by business teams to enhance their business process. &lt;/p&gt;

&lt;p&gt;The other 3 categories are &lt;code&gt;Hobbyist&lt;/code&gt;, &lt;code&gt;Student&lt;/code&gt; and &lt;code&gt;Other&lt;/code&gt; which are for Individual developer account&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fb2k6hkqslajp68rsshgp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fb2k6hkqslajp68rsshgp.png" alt="Purpose of app"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Categories of Developer accounts&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;em&gt;Individual&lt;/em&gt; dev account vs &lt;em&gt;Team&lt;/em&gt; dev account
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Focybcjgytr2p1i2fjpqj.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Focybcjgytr2p1i2fjpqj.jpeg" alt="Individual vs Team"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Decide which category your account falls into, and then select the appropriate one.&lt;/p&gt;

&lt;p&gt;If you chose a team developer account, which is for professionals, then you will have to specify your organization's details as seen in the above image.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Specify Intended use&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In this step, you have to specify the use case for your application.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Be as specific as you can while specifying your intended use of the Twitter API&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The more specific you are, the better are your chances of getting approval.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;IMPORTANT❗ READ ALL THE guidelines before applying&lt;/strong&gt;
&lt;/h4&gt;

&lt;blockquote&gt;
&lt;p&gt;Make sure you have read the &lt;a href="https://developer.twitter.com/en/developer-terms/agreement-and-policy" rel="noopener noreferrer"&gt;Developer Agreement and Policy&lt;/a&gt;, &lt;a href="https://help.twitter.com/en/rules-and-policies/twitter-automation" rel="noopener noreferrer"&gt;Automation rules&lt;/a&gt; and &lt;a href="https://help.twitter.com/en/rules-and-policies/twitter-rules" rel="noopener noreferrer"&gt;The Twitter Rules&lt;/a&gt; &lt;strong&gt;thoroughly&lt;/strong&gt; before applying.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu9hbwozxq5izq5mz55d4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu9hbwozxq5izq5mz55d4.png" alt="Developer agreement and policy"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It consists of the &lt;em&gt;DOs&lt;/em&gt; and &lt;em&gt;DON'Ts&lt;/em&gt; of how to use the Twitter API.&lt;/p&gt;

&lt;p&gt;It's a pain in the &lt;em&gt;neck&lt;/em&gt; to read the entire thing, so I have summarized it for you.&lt;/p&gt;

&lt;h4&gt;
  
  
  Summary
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reverse Engineering&lt;/strong&gt; - Don't try to reverse engineer the Twitter API. Do not try to sell, lease, distribute, or provide access to any licensed material to a third-party.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Security&lt;/strong&gt; - Never give away your account's API keys (The ones which you generate after creating an app)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rate limits&lt;/strong&gt; - Don't call the Twitter API endpoints beyond the specified rate limits. In short, &lt;em&gt;don't spam&lt;/em&gt;. The rate limits of individual endpoints can be found in &lt;a href="https://developer.twitter.com/en/docs/api-reference-index" rel="noopener noreferrer"&gt;Twitter API reference&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Location Data&lt;/strong&gt; - This data can only be used to identify the tagged location of Twitter content like tweets, retweets, DMs, and more.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use of Twitter Marks&lt;/strong&gt; - Don't use the Twitter Logo for this account&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automation Guidelines&lt;/strong&gt; - Automated liking, automated bulk following, and automated adding to lists or collections are discouraged.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ Failing to meet these conditions will cause your application to be rejected&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Review, confirm the application, and wait!&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;⚠️ &lt;strong&gt;Note:&lt;/strong&gt; Once you submit your application, it &lt;em&gt;cannot be edited&lt;/em&gt;. So make sure you have reviewed it properly.&lt;br&gt;&lt;br&gt;
Also, &lt;em&gt;take a screenshot&lt;/em&gt; of the 'review application' page, so that you can view it later.&lt;/p&gt;

&lt;p&gt;It usually takes a day or two, or sometimes more, for your application to be reviewed by Twitter.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2q4u6dsil8ubxncmmeeg.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2q4u6dsil8ubxncmmeeg.gif" alt="Now we wait"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;After you receive the E-mail:&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Twitter can send you three types of emails -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Approved developer account&lt;/li&gt;
&lt;li&gt;❌ Application &lt;em&gt;rejected&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;🔶 &lt;em&gt;Review&lt;/em&gt; - They will ask you to review your application since it violates one or more sections of their policies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Filmkfhkhg683ktuez1xk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Filmkfhkhg683ktuez1xk.png" alt="Review application"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the third case, you will have to read which parts of the developer policies are being violated, amend your application so that it complies with those policies, and submit it by replying to the same email.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The screenshot of the 'review application' page which you took will come in handy over here since you can't view it on the website again.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What next?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;If your application gets approved, Congratulations! 😀 🎉 You can now develop apps, improve your skills, and showcase your projects done using the Twitter API.&lt;/p&gt;

&lt;p&gt;If it gets rejected - Hard luck! 🙁 Twitter doesn't specify why they rejected an application. &lt;/p&gt;

&lt;p&gt;That's it. All the best with your application! &lt;br&gt;
And Happy Coding! &lt;/p&gt;

&lt;p&gt;BTW, This is my first article on the Dev Community. 🎉&lt;br&gt;
Please let me know your thoughts  in the comments 😇&lt;/p&gt;

</description>
      <category>twitter</category>
      <category>beginners</category>
    </item>
    <item>
      <title>ELI5: Why was Deno necessary when we had Node.js</title>
      <dc:creator>Sumedh Patkar</dc:creator>
      <pubDate>Sat, 11 Jul 2020 17:46:58 +0000</pubDate>
      <link>https://dev.to/sumedhpatkar/eli5-why-was-deno-necessary-when-we-had-node-js-3fcc</link>
      <guid>https://dev.to/sumedhpatkar/eli5-why-was-deno-necessary-when-we-had-node-js-3fcc</guid>
      <description>&lt;p&gt;Can anyone explain to me like I'm five - Why deno was created when nodejs existed?&lt;/p&gt;

&lt;p&gt;Consider me as a beginner who has written 3-4 server-side programs in node.&lt;/p&gt;

&lt;p&gt;P.S. - Please don't post a link to Ryan Dahl's video&lt;/p&gt;

</description>
      <category>deno</category>
      <category>node</category>
      <category>explainlikeimfive</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Test post</title>
      <dc:creator>Sumedh Patkar</dc:creator>
      <pubDate>Fri, 12 Jun 2020 16:38:30 +0000</pubDate>
      <link>https://dev.to/sumedhpatkar/test-post-2m1a</link>
      <guid>https://dev.to/sumedhpatkar/test-post-2m1a</guid>
      <description>&lt;p&gt;Hey everyone!&lt;/p&gt;

</description>
      <category>hey</category>
    </item>
  </channel>
</rss>
