JTwitter - the Java library for the Twitter API
JTwitter - the Java library for the Twitter API
Robust & easy to use. Over 200,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:
- All you need: jtwitter.jar + source & test code + dependencies: [jtwitter-3.8.6.zip]
- Just the jar: [jtwitter.jar v3.8.6]. In which case you will also need an OAuth library - we recommend Signpost: [signpost jar]
Alternatively, if you are familiar with git, use the JTwitter repository on GitHub.
Please do NOT use the version on Maven -- this is out of date, and we are lost in Maven/Sonatype bureaucracy.
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 the keys here)
OAuthSignpostClient oauthClient = new OAuthSignpostClient(OAuthSignpostClient.JTWITTER_OAUTH_KEY,
OAuthSignpostClient.JTWITTER_OAUTH_SECRET, "oob");
// Open the authorisation page in the user's browser.
// On a website or web-app, this is done with a redirect.
// 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 = oauthClient.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.- OAuthScribeClient which requires the Scribe OAuth library and the Apache commons codec. (documentation).
- 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. Look for NTwitter.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
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.The Smart Social Dashboard