Documentation

Here you can find sample code to implement our API.


import UIKit
import Alamofire
class IndianRailAPI: UIViewController {
    //make a closure which keeps a check on the status of data download
    typealias DonwloadComplete = () -> ()
    override func viewDidLoad() {
        super.viewDidLoad()
        self.downloadIndianRailAPIData {
            //update the UI with Parsed data here
        }
    }
    func downloadIndianRailAPIData(completed: @escaping DonwloadComplete){
    //Download the API related JSON and Parse it for required info here
    //API_URL to get data from
    let TRAIN_ROUTE_URL = "http://indianrailapi.com/api/v1/trainroute/apikey/ your api key /trainno/12723/"
    let API_URL = URL(string: TRAIN_ROUTE_URL)
    //Using the Alamofire Pod the pull the data
    Alamofire.request(API_URL!).responseJSON { (response) in
    let result = response.result
    //print the JSON data being received
    print(result.value!)
    if let dict = result.value as? Dictionary
        {
            if let train = dict["Train"] as? Dictionary
            {
            if let trainName = train["Name"] as? String{
            print(trainName)
            }
        }
    }
    //connection close when tasks complete
    completed()
    }
    }
    }
Contributed By : N Visakeswaran
Note: If you are too beginner in development, you can use our services in Rs. 500.(Only for paid users.) (C#.Net, VB.Net, JQuery, AngularJS Only.)
Developers are requested to contact at admin@indianrailapi.com with sample code to become support members. Sample code must be uploaded in github, google drive and so on.