Hello.

I’m using the standard search API to search for tweets.

I have noticed that only about 50% of the returned tweets have an URL associated with them… It’s rather important for me to receive the URLs to the tweets so I am wondering what the problem is? Why are there some tweets that have the URL missing? Have they been deleted from Twitter or what is going on?

It could be one of several things:

Your query is returning tweets that do not have a url - that depends on what you’re searching for.

The tweets are truncated: Changelog | Twitter Developer Platform - adding tweet_mode=extended should give you the full_text and all entities.

Tweets composed as Twitter Ads have links that do not appear in the json: there is no way to get these urls unless you use the access token from the account that created these. But you can detect if a tweet is an Ad by checking the source property.

1 Like

Thank you for your response!

Regarding the first point “your query is returning tweets that do not have a url”… Do you know what kind of tweets those are? I thought all tweets had to have an url

I’m also having trouble detecting if a tweet is an Ad… The source property is very similar between all the tweets:

“<a href="http://twitter.com" rel="nofollow">Twitter Web Client”

Sometimes says “Twitter for Android” or “Twitter for IPhone” also, doesn’t seem like there is anything flagging it as an Ad

Thank you for your help

Can you provide example Tweet IDs, and JSON samples, that explain what you mean, and what you expect?

Hey there Andy and thank you for chipping in.

For example when I request the following:

https://api.twitter.com/1.1/search/tweets.json?result_type=recent&count=100&lang=en+OR+is&q=icelandair

I get a couple of tweets without any URL (in the entities node)…

Example IDs: 1131047959657758721, 1131220397582692354, 1131213853369556995

To be completely clear I’m talking about the URLs to the original Tweet… not URLs that are being tweeted about

It seems like I only get the URL to the tweets when the tweets are truncated (because that’s when the url appears at the end of the “text” node…

So… if tweets are not truncated, is there no way to get the URL to the tweet?

No, this is not included in the Tweet object JSON data. However, there’s a very straightforward formula for calculating the canonical URL, documented here (thanks, once again, to @IgorBrigadir!)

It’s on our list to add this to our documentation, but this is still in the backlog at this time.

1 Like

Thank you! this thread can be closed