Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Ushahidi Java Libraries

Ushahidi Java SDK

A Java wrapper for the Ushahidi API. It's simply a Java library that wraps the raw HTTP calls to the Ushahidi APIs. The goal of this SDK is to ease Ushahidi API integration into your applications and to support all the Ushahidi public and admin APIs that are there. For more information on the Ushahidi API, see;


The Ushahidi Java SDK is built using Apache Ant

Run the following command to build a JAR file of the SDK with all the dependencies. ant dist

And to compile all the source codes, run ant compile


Create UshahidiApi object

The UshahidiApi class allows you to access the various task implemented by this SDK through the object you will create.

UshahidiApi ushahidi = new UshahidiApi("");

//set credentials for the admin APIs
ushahidi.factory.client = new UshahidiHttpClient();
ushahidi.factory.client.setAuthentication(new PasswordAuthentication(
                "username", "password"));

Fetch all categories

Pull all visible categories that have been submitted to the Ushahidi platform

CategoriesTask task = ushahidi.factory.createCategoriesTask();
List<Category> categories = task.all();

Attach news article

Add a news article to an existing report

TagNewsTask task = ushahidi.factory.createTagNewsTask();
Response response = task.tagNews(4, "");

Add comment

Add a comment to an existing report. You need to know the report ID to be able to add the comment

Comment c = new Comment();
c.setAuthor("Foo Bar");
c.setDescription("Some sample comments");

CommentFields comment = new CommentFields();
CommentsTask task = ushahidi.factory.createCommentsTask();
Response response = task.submit(comment);

Submit Report

Submit a new report to the Ushahidi deployment

ReportTask task = ushahidi.factory.createReportTask();
Incident i = new Incident();
i.setTitle("test title");
i.setDescription("test desc");
i.setDate(new Date());

ReportFields fields = new ReportFields();
fields.addPhotos(new File("/sdcard/photo0.jpg"));
Response response = task.submit(fields);


You can find the Javadoc which contains all the relevant documentation on the classes and the packages in the doc directory found in the root folder of the project.

To generate recent version of the Javadoc, run ant javadoc

Clean up

To clean up the generated distribution file and Javadoc in the root folder, run ant clean

Something went wrong with that request. Please try again.