t.co Link Wrapper FAQ

Updated on Tue, 2013-06-11 07:39

Links will be wrapped when Twitter receives a tweet using POST statuses/update or a direct message using POST direct_messages/new. The wrapped link will be contained in the response to a successful request. You don't need to make any extra API calls.

The maximum length of t.co URLs will change over time. Issue a request daily to GET help/configuration and examine the fields short_url_length and short_url_length_https to determine the current maximum length of wrapped URLs. We do not expect these values to change often.

It's important to note that you won't necessarily know the length of a t.co URL before posting. Consider the short_url_length field a maximum possible length for a t.co-wrapped link. When designing a tweet entry box, it's best to consider all URLs as equalling the maximum possible short_url_length.

Counting characters in Tweets remains mostly the same.

  • If you are not using the opt-in features, only links shorter in length than a t.co URL will be wrapped by t.co. All links t.co-length or longer should be considered as t.co's maximum length. For example, if help/configuration reports 20 characters as the maximum length, and a user posts a link that is 125 characters long, it should be considered as 20 characters long instead. If they post a link that is 18 characters long, it's still only 18 characters long.
  • If you are using the opt-in features, all URLs regardless of length should be considered to be the maximum length reported to you by help/configuration.
  • HTTPS-based URLs take an additional character for the additional "s" in the protocol aspect of the URL. You can better control the link tweeting experience by using the opt-in features offered today. Always use the values in GET help/configuration for best results.

    My application or users already use URL shorteners. Will this break URL shortening and can my users opt-out?

    URL shorteners will continue working with Twitter as they always have. While users won't be able to opt-out of using t.co, developer use of Tweet Entities insures that users always see links with more meaningful semantics.

    Use Tweet Entities, which will soon be included by default on API responses, to detect the character position of URLs relative to tweet text, unwrapped URLs, and a suggested shortened display (like that used on Twitter.com). See this example from tmhOAuth for an example of consuming Tweet Entities in PHP.

    Will my application break if I do nothing?

    No. If you have not implemented entities support, your users may see only t.co links instead of more descriptive indications. Taking advantage of the opt-in features today insures protection against future changes.

    Will there be a URL shortening or resolution API?

    Not at this time. URLs are wrapped automatically at time of tweet or direct message submission. Resolved URLs are only available in the context of tweet or direct message content as part of the entities response accompanying the content.

    At the time of writing, HTTP-based t.co links are 20 chars long. This will increase with time, with the next increase around mid-August. Be sure to check the GET help/configuration endpoint to get the current max t.co link length.

    Link wrapping provides an opportunity to learn how users engage with links contained in tweets. After the full t.co rollout is complete and our analytics has crystallized, we'll be offering a set of APIs that developers can leverage to enrich their applications with gathered data.

    When a HTTPS-based URL is passed while link wrapping is enabled using POST statuses/update or POST direct_messages/new, a HTTPS-based t.co link will be produced. HTTPS-based t.co links are one character longer than standard t.co links to account for the protocol change. GET help/configuration will indicate the current length of both HTTPS and non-HTTPS t.co URLs.

    Why did help/configuration begin returning 20 character lengths but t.co still wraps at 19?

    The lengths reported by GET help/configuration as maximums. It's possible you can get a t.co link that is less characters long than the maximum.