First hands on the new Twitter API
Tags: api, webdev, tools
Published: 2020-08-26 09:20:09

---
title: First hands on the new Twitter API
published: true
description: The new Twitter API (v2) has been officially released this summer. A new opportunity for Twitter to start again, long after the refocus introduced in 2012 when Twitter blocked most access to the API. Let's see if it's a new eldorado for developers? 
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/0ssj42cf7c36vftcxcpn.jpg
tags: discuss, API, webdev, tools
---

Twitter has officially released its new API, aka version 2. It comes with great premises. Introduced [with an astonishing video](https://blog.twitter.com/developer/en_us/topics/tools/2020/introducing_new_twitter_api.html) and proudly promoted as a rebuild "from the ground up to better support developers", including business, academic researchers, students, and makers.

[![Twitter's developers diversity](https://dev-to-uploads.s3.amazonaws.com/i/2hznwgdx69086t9waj7t.png)](https://blog.twitter.com/developer/en_us/topics/tools/2020/introducing_new_twitter_api.html)

I was really excited to see the new opportunities that it brings. While still in an early access phase, I must say that I'm a bit disappointed so far. Let's see why.

## The great.

The developer portal, including the developer's dashboard, has been fully rebranded. Information is a bit easier to find, more structured. There are many more quickstarts which is really great for a newcomer.

![Twitter Developers Dashboard](https://dev-to-uploads.s3.amazonaws.com/i/8cep2miz0ezhcff4shew.png)

One thing that I've immediately liked is the improved way of filtering data. A bit like in GraphQL, you can ask Twitter which properties you are interested in. 

For example, when asking for tweets, Twitter sends by default the `id` and `text` (content) of the tweet. If you are interested in receiving specific metrics, like the number of retweets, you can ask for that by adding a new parameter. 

This will look like the following:

```
?tweet.fields=created_at,public_metrics
```

It reduces the payload to just what you want - which is always great. Though I'd love to be able to have more granularity. For example, ask for retweets only, and not having all public_metrics. Also, the default fields are mandatory. There's no way to overrides that.



## The meh.

The API still uses OAuth 1.0a for the authentication part. That's probably the first thing that "shocked" me. Most APIs have migrated to OAuth 2.0 for years. It's really surprising that Twitter didn't take the leap when releasing this new version.

OAuth 2.0 has introduced the notion of scopes, which is very familiar today. By keeping OAuth 1.0a, Twitter will not be able to provide granularity to the developer on the user's data.

In other words, by allowing an application, it will always have full access to your data. Which is not something people want anymore. [Twitter says it's on the roadmap though](https://developer.twitter.com/en/products/twitter-api/early-access/guide#oauth2).

Also, Auth 1.0a is far more difficult to use from a developer's perspective. It requires signing each request for example. But, I'm using a tool called[ Pizzly](https://github.com/bearer/pizzly) (that I've participated to build) to help with that.

![Twitter is still using OAuth 1.0a](https://dev-to-uploads.s3.amazonaws.com/i/9t2ip73qz1nru3rsdkbd.png)

More broadly, I haven't seen many innovations with that new API. It's mostly a REST API, with some interesting concepts (e.g. the ”fields” parameters). But some other APIs already have similar concepts in place (Google APIs has used the field parameters for years).

## The ugly.

The API quotas are still very low. An application can't request more than 500,000 tweets per month. I've estimated that when browsing my feed on Twitter, I'm looking at about 50 tweets per session. Per month, that's 50 * 30 = 1500 tweets.

Building an application that just renders a user's feed would stop working at just a few hundred active users. It's really not that much.

I also have this feeling that this new API isn't targetting small developers. For instance, when starting to look at the new Twitter API, I wanted to build a graph of my Twitter timeline to make it looks a bit like GitHub Contributions Graph.

![GitHub Contributions Graph](https://dev-to-uploads.s3.amazonaws.com/i/8hlmhbfmlr1fmp8z9741.png)

There's no such endpoint that lets you do that in the new Twitter API. No endpoint to retrieve tweets of an authenticated user. And the public tweets can be retrieved in the last 7 days only. It's a bit of a shame that Twitter keeps its user's data for itself.

Another example that strengthens this feeling, one of the 6 available endpoints is the [sampled stream](https://developer.twitter.com/en/docs/twitter-api/tweets/sampled-stream/introduction) which delivers "a roughly 1% random sample of publicly available Tweets in real-time". That's kind of awesome! But the amount of data that you need to manage is massive...

## Conclusion

The API is still in an Early Access phase and we can see it.

Not all endpoints are available. As of writing, only 6 endpoints are. And for example, you can't post a new tweet with the version 2; neither manage DMs. So it's really early to get the most of this new API.

Also, tons of great features are still [on the roadmap](https://trello.com/b/myf7rKwV/twitter-developer-platform-roadmap). But I have the overall feeling that the new Twitter API is mostly targetting big players (established companies, academic researchers, etc.).