rest2mobile: Native APIs for any rest services

Introducing rest2mobile

rest2mobile is Magnet’s first open source effort to share some of our cool technologies with the developer community.

Mobile APIs generation happens to be THE feature that users love most about our Mobile Server. But in fact, this capability is completely independent from our server. We saw right away an opportunity to help every developer generate native code for their own REST services or even any cloud REST services out there.

We spent a few weeks refactoring and extracting the generator and SDKs from our main code base. To maximize the user experience, we created a command line tool as well as IDE plugins. Finally, we open-sourced the whole suite on github. This is how rest2mobile was born.

Native vs REST

At Magnet, we tend to be opinionated about native support and strongly typed APIs.

Why? because even though mobile developers like REST, they still prefer to code in their own language; they also would rather not deal with all the boilerplate code associated with JSON marshaling, HTTP connections or what not.

rest2mobile’s generated native APIs are easy to use. The generated code is minimal, documented and even includes test samples. The SDK is also fairly small. So you really can test, debug, or adapt it any way you want.

rest2mobile also saves you a lot of time. It helps server and mobile teams collaborate and be more productive. Server engineers that implement REST services no longer have to worry about how to expose their new API to mobile developers. For Mobile developers, any REST services that have no pre-existing native support, as it is often the case,  can now be mobilized with no effort.


We posted a few examples on github to show you how to use rest2mobile, but the tool is not a collection of built-in native mobile APIs to play with. Instead, you pick the REST API of your choice.
But how do you describe a REST interface? There are many specifications out there such as WADL, RAMLSwagger, or API blueprint and so far, there is no clear winner.

There may never will be: the truth is that we, developers, tend to be lazy and more practical; we often end up testing a REST service through curl commands and copy-pasted examples found on the web. As a result, most REST APIs are just documented in plain English along with examples.

Specification by Example

This is the exact approach that rest2mobile is taking: you simply specify your REST interface with examples. Enter the url, headers, and payloads and the tool automatically generates the method signatures and the entire object model for Android, iOS and Javascript. The CLI allows you to script, automate and do this for all platforms, while the Android Studio plugin and Xcode plugins provide a nice wizard that acts as a REST client, so you don’t need specify the response payload and the code is generated right inside your app project.

What’s next?

I’ll give a few hands-on tips on rest2mobile in subsequent posts. In the meantime, go ahead and try it . There are so many use cases where rest2mobile can help: we are working on many new features to make it even more powerful and seamless to use.

Don’t hesitate to send your feedback: if you have a question or a request, go to , or simply post an issue on github .

Finally, stay tuned on what’s coming: we will keep exposing more magnet mobile technologies to our developers, including some pretty cool stuff on messaging and mobile persistence.