Twitter defines its platform as "what's happening in the world and what people are talking about right now."

You've got to be on Twitter to understand the strength of this statement. According to the company's Q1 2019 report, 145 million people use the platform daily and 330 million use it at least once a month.

Free Download: 77 Examples of Brilliant Web Design The amount of data that can be generated by such a large population is enough to make any forward-thinking marketer interested in accessing Twitter's API.

Luckily, that's not impossible, nor is it difficult. However, to maximize the use of it, you have to understand how to apply these insights to your business.

But first, it’s worth understanding why marketers are so interested in accessing the Twitter API.


API stands for Application Programming Interface. This software provides "middleman services" between two applications that want to communicate with each other. Any requests you make go to the server first and the response given comes through the same route.

This bridges the gap between the two applications (the one on your phone and the company's software) while providing an extra layer of security. For instance, whenever you use a social media application, you interact with an API. Without direct contact between each other, any potential threats posed by one to the other are abated.

An API also provides a list of commands that can be executed. To use a popular analogy, imagine you're ordering food at a restaurant. You're at the table, ordering from the kitchen. The link between you and the kitchen is the waiter who ensures that the kitchen staff gets all the orders and meals are delivered to the right customers. You're also free to ask them what's available before making your order.

Without the waiter, you'd be pushing your way into the kitchen yourself, trying to get something to eat. That’s where the API plays its role as the middle man between two pieces of software.

The API provides a list of methods the two applications can use to communicate. They include:

  • GET for retrieving data.
  • POST for creating data.
  • PUT for updating data.
  • DELETE for removing data.

Here are some of the features of Twitter's API:

  • There are four main objects: Tweets, Entities, Places, and Users.
  • There are daily restrictions: Calls and changes in the API are restricted by access tokens to protect the platform from abuse.
  • It is based on HTTP (rather than SSL).
  • There are specific measures to adapt the API operation to the social network including library restrictions, generated paging, and specific parameters.

Now that you’re familiar with API’s let’s discuss how you can use Twitter’s.

Here’s what this process looks like, in detail:

1. Open a command prompt terminal.

Before installing anything, make sure you're familiar with how to open a terminal.

On Mac: Go to Finder > Applications > Utilities > Terminal. Alternatively, open Spotlight by pressing CMD + Space and search for "terminal".

On Windows: Open Command Prompt by going to Start and searching for "cmd".

Microsoft stopped mainstream support for Windows 7 in January 2020. But if you're on that or older, use Start > All Programs > Accessories > Command Prompt.

2. Open a Twitter Developer account.

To proceed, you need to have a Twitter developer account. To create one, open the apps management page and create an app. Name it, enter a website URL, and give a 100-word description.

3. Install Ruby then launch Twurl.

To run Twurl, you'll need Ruby. So, make sure to have it installed. Then, follow Twitter's tutorials to install Twurl.

4. Create an API key.

To send API calls, Twitter assigns a unique set of keys to your developer account. To access them, login to your developer account and select Details from your apps management screen.

Click on Keys and Tokens to generate a new, unique, and secret API key. Copy the secret and consumer API keys.

5. Authorize your Twitter app and account.

Run the following command in your terminal to authorize your Twitter app and account:


Note: replace <key> and <secret> with your API keys.

Finally, copy and paste the returned URL to your browser to get a PIN. Then, enter the PIN into your terminal.

You're all set now. For more information, check out Twitter's guidelines on authentication.

Once you access the Twitter API, you'll be able to perform user activities, such as sending messages and media without having to open the application. By using command-line tools like Twurl and cURL, you’ll find more efficiency than you would by using the application directly.

Using a command-line tool, you can use your access to the Twitter API to perform a wide range of tasks. Twurl is one of the best tools for this job. It's built like cURL but has been modified specifically for the Twitter API.

Run the twurl -h command to learn more about using Twurl. For a simple tutorial, run twurl -T or twurl --tutorial.

Then, when you’re ready, below are some ideas for how to use the Twitter API.

Send a tweet.

You can use your new set up to send a tweet using the statuses/update POST endpoint. Twitter’s documentation says this "updates the authenticating current user's status" (i.e. sends a tweet).

Upload a media file.

Using Twurl, you can also upload:

  • Images up to 5MB
  • GIFs up to 15MB
  • Videos up to 15MB

Use the media/upload endpoint as follows:


Respond to a tweet.

To respond to a tweet, use the status/update POST endpoint, just as you would to send a fresh tweet.

Retrieve tweets under a specific hashtag.

To retrieve all tweets with a specific hashtag, use the search/tweets GET endpoint. By default, the results return tweets sent in the previous seven days.

You can use this function to evaluate a past marketing campaign — yours or that of another company. With access to all the tweets shared under a particular hashtag, you can learn a lot about your target audience, including the general mood around the topic.

Find locally trending subjects.

Find out what people in your locale are buzzing about. Use the trends/place GET endpoint. You'll need to provide the Yahoo! Where On Earth ID (WOEID) for your location — use WOEID Lookup to find yours.

Once you know the trending subjects for your audience, you can decide how to use the discussions to promote your brand.

Create bots.

If you want to venture deeper into the world of the Twitter API, you can use all of these and other endpoints to create bots. Then, they can share specific content, show live updates about a particular topic, and remind your staff and followers of an event — among other things.

G2 shares a useful resource to get your feet wet with Twitter bots.

Twitter is a great place to communicate with and learn from your audience. With access to the Twitter API, you can finetune your marketing through in-depth customer (and even competitor) analysis.examples of brilliant homepage, blog, and landing page design

 New Call-to-action

Originally published Mar 19, 2020 4:43:52 PM, updated March 31 2020


Application Programming Interface (API)