Getting started

Get started with the Twitter developer platform

Twitter is what is happening now. What do you want to build with the Twitter platform? Twitter’s developer platform offers many APIs, tools, and resources that enable you to harness the power of Twitter's open, global and real-time communication network.

What do you want to build?

All of these use cases can be implemented with a Twitter API, or in many cases a combination of APIs.

In the following section, we'll describe the families of APIs that make up the Twitter platform and outline the first steps for building with the Twitter platform: gaining API access, learning more about our APIs, and having code examples for getting started. 

 

First steps

Twitter's developer tools and APIs

Twitter’s developer platform includes numerous API endpoints and tools to help you build an app and solution on Twitter. Please review our full set of developer APIs and tools on our Products Overview page. These tools include the following:

  • Standard APIs
  • Premium APIs
  • Enterprise APIs
  • Ads APIs
  • Twitter for websites
     

Creating a Twitter app

Integrating with nearly all of the Twitter APIs requires the creation of a Twitter app and the generation of consumer keys and access tokens. The only exception to this are the enterprise search, batched historical, and streaming APIs. 

Visit the developer portal with an approved developer account to create a Twitter app and generate your authentication tokens. These include 'consumer' tokens and secrets for app authentication, and 'access' tokens and secrets for user/account authentication. For more information on Twitter authentication, click here

Once you establish access to the API, some next steps include revisitng our documentation, and exploring example code.
 

Dig into our documentation 

There is a vast amount of technical resources here at developer.twitter.com. Here is a quick orientation and advice for finding the material you need to get started:

  • The sidebar on the left serves as your directory to the many aspects of the Twitter platform. For example, all of the APIs that deliver Tweets are organized under that section, and everything you need to get started with advertising on Twitter is under the Ads section.
  • Our tutorial section covers a wide variety of topics to help you accomplish different tasks using the Twitter developer platform. Learn more about real-time streaming, building customer service tools, working with our Ads platform, and geo-referencing Twitter data. 
  • With premium and enterprise products, check out the guides and API reference for additional details about each product. 
  • Have a technical question? Check out our community forum. There’s a good chance our community has an answer for you. Visit our developer forums to review topics, ask questions, and learn from others.
     

Find some example code and libraries

There are many libraries and utilities in different programming languages that can help you to get started.
Once you’ve established access, making API requests is super simple.

  • Quickly make your first API request with a HTTP wrapper called twurl. twurl is a command-line application that can be used to make authenticated requests to Twitter APIs. Use twurl in order to confirm access to the API by making a call to any API endpoint. Additional details can be found in the twurl tutorial.

Check out the TwitterDev Github repositories. There you will find example search API clients written in Python and Ruby, example chatbots, and utilities for getting started with the webhook-based Account Activity API.

  • Review our standard API Github repositories on this page.


 

Next steps

The following sections provide more getting started information for many common Twitter use cases.

Integrate Tweets into your app or website  

Tweets help tell many of the stories told on the web. Stories of all types discussed and told using related Tweets. 

Embedding on the web

Our publisher tool Twitter for Websites makes it easy to tell the best stories with Tweets on the web. You can also use our publishing portal to easily get the code to embed Tweets and timelines, or create buttons.

To embed a Tweet on the web, click the “more” menu (•••) and choose “Embed this Tweet”. You can copy and paste a blob of HTML into your template or content management system. To embed an entire column timeline, click the column settings icon and tap “Share”: “Embed Timeline”. Learn how to customize embedded Tweets or embedded timelines by checking out the documentation.

Discover & curate Tweets

Often a first step when displaying Tweets is searching for and curating collections of Tweets of interest. Use TweetDeck to find and curate content, and bring relevant, even real-time, engaging content to your users.  Open up TweetDeck to start finding and organizing Tweets. You can create searches for trending hashtags or interesting topics, and then filter the results by engagement, location, and users. Read our getting started documentation if you're new to the tool, and dig into advanced features to learn how to wrangle Tweets with lists and collections. TweetDeck can be your Twitter content hub, with many columns of timelines or saved Tweets for use in your products.

Many Twitter integrations curate and surface Tweets of interest by making requests to one of the many Tweet APIs. These APIs deliver Tweets in real-time or search from the continual archive of Tweets posted since March 2006. To learn more about real-time streaming of Twitter data, click here. To learn more about searching the Tweet archive, click here.
 

Post Tweets and Direct Messages from your app or website

One of the most common uses of the standard API family are the endpoints used to post Tweets. To learn more about the API method to post a Tweet, click here. We also have methods for posting Retweets, favoriting Tweets, deleting Tweets, and other common actions. 

Direct Messages have become an essential part of the Twitter platform. These private messages are commonly used to drive customer service solutions on Twitter and, along with the Account Activity API, are used to build chatbots. To learn more about our Direct Message API, click here

Posting Tweets and sending Direct Messages with photos and videos is another common activity on Twitter. To do this, you first need to upload the media to Twitter. In response, you will receive a media ID which you reference when posting the Tweet or sending the Direct Message. 
 

Advertise on the Twitter network

Twitter’s Ads API endpoints provide developers a programmatic way to create and manage Twitter Ads campaigns. In addition, these endpoints provide a means to access features like Audiences, Creatives, Targeting, etc. Our tutorials page contains all the necessary information around the Ads entity hierarchy as well as a basic getting started guide.

Apply for Ads API access

In order to be able to use any of the Ads API endpoints, first create a Twitter app and apply for access here. Feel free to play around in our sandbox environment as well.

Check out our SDKs

The Python and Ruby SDKs provide a frictionless means to integrate with the Ads API directly in your application.

If you’re an expert on the Ads API feel free to help out others as well! Questions? See our developer forums.
 

Listen in real-time for Tweets of interest 

Twitter is a real-time communication network, with very little latency. Many Twitter integrations depend on the ability to stream Tweets in real-time using HTTP streaming. 

If you are building a service that requires reliable, full-fidelity, real-time streams of Tweets, the enterprise tier offers the PowerTrack API. PowerTrack enables you to build filters that are applied to the Twitter firehose to deliver your Tweets of interest. To learn more about real-time streaming, and enterprise-level reliability features, click here

If you are interested in experimenting with streaming real-time Tweets and don't yet need complete data and enterprise-level reliability, the standard API offers this streaming endpoint.  

If your service does not demand absolute real-time listening, you should consider one of the historical APIs. For example, if you can wait at least 30 seconds for a new Tweet to become available, then one of our search Tweet APIs may be a better fit. 
 

Search the Tweet archive

Public conversations have been happening on the Twitter platform since early 2006. With our set of historical APIs, Twitter data has informed an amazing variety of research. When it comes to filtering and collecting Tweets, our search APIs are by far the most commonly used tools. With these search APIs, a single query is submitted, and the API responds with a first 'page' of results, providing a 'next' token that is used to paginate through the results as needed. 

Our premium family of search APIs provides a 30-day product, and also a full-archive product, that as the name implies, makes available any publicly available Tweet posted since March 2006. Search queries can be created using any of these premium operators. If you are new to our search APIs, click here to see a developer's guide to integrating the premium search API.

Our enterprise family of search APIs also provide 30-day and full-archive endpoints. These endpoints also support our set of premium operators. Again, the main difference between the premium and enterprise tiers is that the enterprise tier comes with direct account management support, and dedicated technical support to help with integration strategy. To apply for access to the enterprise APIs, click here

Our standard tier of APIs also provides a 7-day search endpoint that does not provide full-fidelity data and supports a smaller set of query operators.

Also, the enterprise set of APIs also provides a batch historical product. This product is built to deliver Tweets at scale by supporting up to 1,000 queries in a single batch job. Depending on the length of your search period, the job may take minutes, hours, or even days to compile its dataset that is made available via file downloads when it completes. 

Both the full-archive search and the batch historical products make available the entire public archive of Tweets. To help understand which product is most appropriate for your historical research, click here
 

Measure and listen for Twitter engagement

The enterprise family of APIs includes the Engagement API. The Engagement API provides three different endpoints for query-based access to organic impressions and engagement data for Tweets from authorized/owned accounts, as well as engagement metrics for Favorites, Retweets, and Replies for any public Tweet.

To get started with the Engagement API, see our developer's guide. To read a blog post on using the Engagement API to measure campaign success, complete with developer notes, click here
 

Get started with Twitter Data objects

The data provided by Twitter APIs are made up of data objects and their attributes rendered in JavaScript Object Notation (JSON). To learn more about Tweet metadata, see this introduction to Tweet JSON objects.

The following documentation provides 'data dictionaries' to help you understand the many attributes that make up Twitter Tweets, Users, and other objects.

Tweet object

Tweets are the basic atomic building block of all things Twitter. Click here to learn more about the Tweet object and its data fields.

User object

The user object contains public Twitter account metadata and describes the author of the Tweet. Click here to learn more.

Twitter entities and extended entities

Both the entities and extended entities objects encompass common Tweet elements such as media (photo, video, GIF), hashtags, URLs, mentions, and even polls. Click here to learn more.

Geospatial objects

When posting Tweets, users have the option to geotag their Tweet with an exact location or a Twitter Place. User accounts can also have geospatial metadata associated with them. Click here to learn more.

Was this document helpful?

ありがとうございます

フィードバックをお寄せいただき、ありがとうございます。お役に立てたなら幸いです!

Thank you for the feedback. How could we improve this document?

Thank you for the feedback. Your comments will help us improve our documents in the future.