medialab / gazouilloire

Twitter stream + search API grabber
GNU General Public License v3.0
104 stars 17 forks source link

[resolver] Try and use bit.ly's API to resolve shortened urls faster #20

Open boogheta opened 6 years ago

boogheta commented 6 years ago

The API v3 says we can resolve them 15 by 15 : https://dev.bitly.com/links.html#v3_expand

Although we should check what the rate limit is as it ain't clear for this specific route https://dev.bitly.com/rate_limiting.html

boogheta commented 6 years ago

quick experiments seem to indicate no rate limit on this route (???) and between 1.5 and 2 calls of 15 urls per second, hence a resolving rate of about 25 bitlink per second, seems legit.

boogheta commented 6 years ago
d0=$(date +%s)
count=0
while true; do
  count=$((count+1))
  curl -X POST "https://api-ssl.bitly.com/v3/expand" -d access_token=$BITLY_API_TOKEN -d hash=2pKPIqQ -d hash=2RK2Mtc -d hash=2pKPIqQ -d hash=2RK2Mtc -d hash=2pKPIqQ -d hash=2RK2Mtc -d hash=2pKPIqQ -d hash=2RK2Mtc -d hash=2pKPIqQ -d hash=2RK2Mtc -d hash=2pKPIqQ -d hash=2RK2Mtc -d hash=2pKPIqQ -d hash=2RK2Mtc -d hash=2pKPIqQ                                                                         
  echo $count $(( $(date +%s) - d0))
done
boogheta commented 6 years ago

So it seems to be confirmed: it ran 2 hours (7216 seconds), calling in total the API 12437 times for 15 urls each time without returning an error once, meaning we can call it 1.7 times per second, so resolving indeed about 25 bitlinks per second (approx 90k per hour). Niiiice :)

Yomguithereal commented 6 years ago

Noice