Try the search, it's linked to some great forums

Thursday, June 20, 2013

JSON / RestKit API Notes

These are notes for installing and using REST (Representational State Transfer).  REST is an API that allows you to translate Web services into coreData within an iPhone app and back the other way.
At its core, RestKit is a system for binding your application's data model with a remote object representation retrieved via HTTP. RKGist tutorial RayWenderlich


CocoaPods - Is an library management tool used in Xcode in conjunction with REST.  It creates a Podfile textfile that creates the dependancies that you specify there.  It is built with the commandline tool.  These following Ray Wenderlich tutorials are great introductions;
open -e Podfile - opens the Podfile in textEdit for libraries & dependencies
pod install - installs new dependencies

SimpleURLConnections.xcodeProj -> Apple's demo using NSURLConnection GET (download) PUT/POST (upload) commands to create a very simple network connection to a server.

Cloning a repository for a GitHub project
  1. Open a terminal and change to the directory where you want the code
  2. Clone the repo by typing git clone git://github.com/dcgrigsby/luckynumbers.git
 git clone git://github repository URL - creates a clone of the project in the directory that you are in

Let's do a simple JSON tutorial first.
JSON - JavaScript Object Notation is a widely used framework for parsing data off the web.  Using this tutorial;
Apple now has it's own JSON implementation called - NSJSONSerialization class

A good source of data in either XML or JSON is The Geonames, geographical database with over 8 million entries. You can join their web service, and access huge data sets including WikaPedia.
Here some links you could find useful: username = clamb
GeoNames User Manual : http://www.geonames.org/manual.html
GeoNames Blog : http://geonames.wordpress.com
GeoNames Forum : http://forum.geonames.org
GeoNames Mailinglist : http://groups.google.com/group/geonames

3rd Party Framework that provides a wrapper class:
http://www.infinite-loop.dk/developer/ilgeonames/

Some examples of XML requests;
Returns all zipcode place names within 10km of zip code=95062 (Santa Cruz):http://api.geonames.org/findNet providesarbyPostalCodes?postalcode=95062&country=US&radius=10&username=clamb
Example for a tourism hierarchy, islands for the Canaries:
http://api.geonames.org/children?geonameId=2593110&username=clamb&hierarchy=tourism
Result : returns a list of wikipedia entries as xml document near Santa Cruz:
http://api.geonames.org/findNearbyWikipedia?lat=37&lng=-122&username=clamb