URL shortening of the user.url field



The user object documentation gived this example for the url field:

“url”: “https://dev.twitter.com

While going through tens of thousand of user profiles who generate content for our app, we’ve found that clean URLs like the one in the example are rarely the case. Most often, the url field contains an https:/t.co/... URL, yet sometimes also an http://t.co/... URL.

What is the logic here? Can this be documented?


All URLs are t.co on twitter - you should check the user object json for entities eg:

  "entities": {
    "url": {
      "urls": [
          "url": "https://t.co/FGl7VOULyL",
          "expanded_url": "https://developer.twitter.com/",
          "display_url": "developer.twitter.com",

The docs to t.co are here: https://developer.twitter.com/en/docs/basics/tco

I’m actually surprised there’s no t.co wrapper for https://twitter.com/briankrebs http://krebsonsecurity.com but i guess it’s an old profile.

Also, if people manually put in a bit.ly or some other shortener you’ll have to follow those redirects yourself.