JTwitter - the Java library for the Twitter API

JTwitter - the Java library for the Twitter API

Robust & easy to use. Over 100,000 downloads and many successful apps. As used by coders, companies & in several university courses.

JTwitter is a small library providing easy access to the Twitter API. Set and get your status, manage your network of friends, message friends, maintain lists, etc. Lots of features - if you can do it at twitter.com, you can do it with JTwitter. Includes work-arounds for rough-edges in the Twitter API to make coding easiser and more robust. Also has support for Klout and other Twitter eco-system sites.

The latest version of the library can be downloaded:

Alternatively, if you are familiar with git, use the JTwitter repository on GitHub.

The recent versions fix a couple of issues with changes and bugs in the Twitter API. If you are using an older version, please download the new version.

The source code is included inside the jar file. It is also available online here: [Twitter.java]

JTwitter is very easy to use. Example usage:

// 1. Get authorised
// On Android: use AndroidTwitterLogin
// On the desktop...
// Make an oauth client (you'll want to change this bit)
OAuthSignpostClient oauthClient = new OAuthSignpostClient(JTWITTER_OAUTH_KEY, 
JTWITTER_OAUTH_SECRET, "oob");
// Open the authorisation page in the user's browser. On a desktop, we can do that like this:
oauthClient.authorizeDesktop();
// get the pin
String v = oauthClient.askUser("Please enter the verification PIN from Twitter");
oauthClient.setAuthorizationCode(v);
// Store the authorisation token details for future use
String[] accessToken = client.getAccessToken();
// Next time we can use new OAuthSignpostClient(OAUTH_KEY, OAUTH_SECRET, 
//	accessToken[0], accessToken[1]) to avoid authenticating again.

// 2. Make a Twitter object
Twitter twitter = new Twitter("my-name", oauthClient);
// Print Daniel Winterstein's status
System.out.println(twitter.getStatus("winterstein"));
// Set my status
twitter.setStatus("Messing about in Java");

You'll find the code is fully documented, and mostly self-explanatory. The javadoc is also available online here: [javadoc], with the change-log (including credits to contributors) here: change log.

Android support included

JTwitter works with Android. There are some good tutorials on the web. See the AndroidTwitterLogin class to get started.

OAuth support included

JTwitter has only one dependency: an OAuth library. We recommend Signpost, which is included in the .zip download.
OAuth support is also available (in the src-extra directory) in the flavours:

  1. OAuthScribeClient which requires the Scribe OAuth library and the Apache commons codec. (documentation).
  2. OAuthHttpClient.java, which requires the Java OAuth library and its considerable dependencies.

C# / .NET version

Thanks to Patrick Schidler, JTwitter has been ported to C# and is available for the .Net framework. NTwitter is available here: http://ntwitter.codeplex.com/.

Feedback

There is a low-volume mailing list for JTwitter. This is the best place to post bugs, feedback, and let me know how you're using JTwitter. You can also contact me directly on .

Copyright and License

CC-GNU LGPL Developed by Daniel Winterstein. This code is copyright (c) Winterwell Associates Ltd, 2008-2012 and ThinkTank Mathematics Ltd, 2007, except where otherwise stated. It is released as open-source under the LGPL license. This code comes with no warranty or support.

You must let your users know that you are using the JTwitter library, which they can get the source code for. A credit on your home page with a link-back to this page, e.g. built using JTwitter, is the recommended way to do this. Your own code can be licensed commercially and you do not have to release the source code.

Donation

JTwitter is an open source project and completely free of charge. If you feel JTwitter has helped you, please consider making a donation.
Sodash logo
The Smart Social Dashboard
Advert: Winterwell are proud to be behind Sodash, the Twitter & social media platform for organisations. Packed with features to make your Twitter use faster and more effective.