Over a million developers have joined DZone.

Amateur Radio Homebrew (Part 2): Understanding Twitter’s API Rate Limits

DZone 's Guide to

Amateur Radio Homebrew (Part 2): Understanding Twitter’s API Rate Limits

As we continue to work on our homemade radio, while integrating Twitter, let's dive into Twitter's REST API and rate limiting and how work with both of them.

· IoT Zone ·
Free Resource

Here's a quick update on my project to build an Amateur Radio Packet to Twitter bridge (see here for the first post).

I’ve moved the Node.js code to a Raspberry Pi 3. So far I have up and running:

Twitter provides an incredibly useful REST-based API to integrate with their service, but understandably, your usage is ‘rate limited’ so you’re not retrieving vast amounts of data or flooding the service with spam Tweets.

To understand their rate limit approach, see this article.

For limits on POSTs, for example for creating new Tweets, you can check this out

As per the above article, POSTs are limited 2,400 per day, or 100/hour. This means that if your app could potentially use the POST APIs more often than 100 times per hour, you need to build some limiting logic into your app so you don’t exceed this threshold.

The rate limits for the /GET REST APIs are here, although, for my application, I’m not relying heavily on GETs — the majority of the calls are POSTS.

Twitter’s API prevents you from posting duplicate Tweets (see here), although they don’t publish how much time needs to elapse before an identical post is no longer consider a duplicate (see here). This wasn’t something I was planning on handling, but given the repetitive nature of some packet transmissions, BEACON packets for example, and packets sent for ID, this has to be a necessary feature of my app. Otherwise, in the worst case, it would be attempting to tweet a station's BEACON packet every minute continuously.

To handle this, I’m storing each Tweet sent with additional tracking stats, like the time the last tweet was sent. Using this timestamp, I can then calculate the elapsed time between now and the time the last tweet was sent to make sure enough time has elapsed before I attempt to Tweet the packet again.

This is still a work in progress and there’s still some tweaking to do on the duplicate post detection and rate limiting, but while testing, you can see the tweets sent from my Twitter account @KK6DCT_Packet.

Here’s an example of the packets currently being tweeted:

Image title

iot ,rest api ,twitter api ,rate limiting ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}