Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create my own Web API / Web Service

I have been developing iOS apps for a while but they all deal with information that is on the device.

I want to expand my knowledge and the appeal of my apps.

What I need is a good tutorial on how to create my own online SQL database and an API to acces all the information on it.

I have used several APIs (Twitter, Facebook, Google, etc.) so on the iOS side I'm ready.

I would love to implement it using Google App Engine but If you know of beter ways to implement this I am more than glad to hear them; I've heard that Java, .net and Ruby are the best options.

I have found a lot of tutorials online but I know Stack Overflow users have knowledge of great resources that can help me, and other developers, to get up and running faster, easier and learning more.

I think the answers to this question can be a great resource to all developers interested on Wb APIs.

Thank you very much for your help.

like image 588
Zebs Avatar asked Feb 26 '11 08:02

Zebs


People also ask

Can we create web API without MVC?

Web API is a feature of ASP.NET MVC 4. This included with MVC 4 because of their similarities. That doesn't mean you always have to create ASP.NET MVC application for developing Web API. You can use Web API in any number of applications.

Can I make my own REST API?

Creating your own RESTful API can be a great way to build a business around data you've collected or a service you've created, or it can just be a fun personal project that allows you to learn a new skill. Here's a list of 20 tutorials on how to design your own REST API!


1 Answers

IMHO, AppEngine is a great choice, since there is virtually no need to setup/manage it. Also it comes prepackaged with powerful services like datastore, taskqueue, user auth, messaging, etc.. The biggest advantage for me is the Datastore, which is schemaless, so you don't have to constantly update/manage the schema as your app progresses.

The downside is that it has somewhat different programming model so developers from servlet+SQL background tend to struggle with it at first. Since you are new to this it shouldn't be a problem.

All my advices below are Java, as this is what I know. Hopefully others will post answers that present other platforms/languages.

To get this running you will need to:

  1. Setup a web service. Go with REST as this is the most common and easy to setup/use. I tried all major Java REST frameworks and ended up with Resteasy, because it just works and has IMHO the best documentation.

  2. Understand how GAE Datastore works. There are a few APIs to use the Datastore:

    a. Low-level is cumbersome as you need to use it's model classes (Entity) so you'll do a lot of copying between your objects and Entity objects returned by this API.

    b. JDO/JPA are java ORM standards, but they were created for SQL databases and are really shoehorned onto Datastore. I'd advise against using them, because they are just an additional layer on top of low-level and also just try to fool developers that Datastore is a SQL database.

    c. Objectify. This is a 3rd party OSS library, but the author is AFAIK supported by Google. It's a layer on top of low-level, but in a really natural way, so not to obscure Datastore features. I recommend using it.

  3. Authentication. You will want authentication. GAE supports OpenID/OAuth out of the box (just tick federated login option in command panel). Now the tricky part is to get this working with iPhone and other devices:

    a. Require user to enter Google credentials into your iPhone app. Some users are reluctant to do this (me for instance). In this case use iPhone OAuth client.

    b. Open an OpenID login web page in embedded browser: Authenticating with Stack Overflow programmatically

like image 90
Peter Knego Avatar answered Sep 29 '22 11:09

Peter Knego