In the last few months, I often connected my Java applications to remote REST APIs: Facebook Graph API, private servers, Twitter API, etc. Each time I have to write a lot of boilerplate code to build the requests, handle the errors, map the responses to my own Java objects, etc.

That is the reason why I worked as a side project on APIPixie. APIPixie is a Java library which enables you to set up a communication with a distant REST API in minutes.

How to use it?

After including the library in your project, you just have to annotate your model with @APIEntity and @APIId:

@APIEntity
public class Message {
	private Long id;
	private String text;
 
	// Getters and setters
}

You can then directly connect to the distant API!

// Create an APIPixie instance
APIPixie pixie = new APIPixie("http://api.mydistantservice.com");
 
// Retrieve an APIService for your object
APIService<Message> msgService = pixie.getService(Message.class);
 
// Start communicating with the distant API
Message msg = msgService.get(42L);
 
// Now do stuff with the object!
String text = msg.getText();

That’s it! You just saved a precious time :)

You can find more information and code snippets on the Github project.

Coming soon

First of all, I will soon publish this library on Maven Central Repository, that’ll be easier to use.

Then I still have a lot to do to make APIPixie an easier to use library: improve the doc, add some examples, handle the specific date formats, enable the developper to use different names for its model and the distant resource, etc.

Finally, I’d love to hear your feedback on the Github project on on Twitter. You can also contribute to the project if you are interested in using it!

APIPixie: https://github.com/vdurmont/apipixie