I try to get individual information from this API:

<https://power.larc.nasa.gov/cgi-bin/v1/DataAccess.py?request=execute&identifier=SinglePoint&parameters=DNR,DIFF,ALLSKY_SFC_SW_DWN&userCommunity=SSE&tempAverage=CLIMATOLOGY&outputList=ASCII&lat=40.39&lon=-3.74&user=anonymous>"

So far I am able to print in the console the API result. I'd like to extract from it the latitude, longitude (even though I can obtain these 2 from the CoreLocation library, I still want to get them from the API) and the content inside the properties->parameter part (ALLSKY\_SFC\_SW\_DWN, DIFF and DNR). And extract this info is where I am stuck. 

I've tried to get the individual elements of the API but I can only get the full API content and not the individual ones (which later I want to put in arrays). I tried using this notation:

```
if let features = ((NASAjsonResult["features"] as? NSArray)?[0] as? NSDictionary)?["geometry"] as? String {
     print("This is features: \(features)"                              
} else {
     print("ERROR for getting 'features'")
}

```

But I always get the "Error" message.

```
import UIKit
import CoreLocation

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, CLLocationManagerDelegate {

//MARK: - Variables and constants
let locationManager = CLLocationManager()
var latit = 0.0
var longit = 0.0
var latitString = ""
var longitString = ""
var locationArray:[String] = []

//MARK: - Labels, tables, maps, etc. on tableView
@IBOutlet var tableView: UITableView!

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 10
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = UITableViewCell(style: UITableViewCell.CellStyle.default, reuseIdentifier: "Cell")

    return cell

}

//MARK: - ViewDidLoad()
override func viewDidLoad() {
    super.viewDidLoad()

    // For use when the app is open & in the background
    locationManager.requestAlwaysAuthorization()

    //For use when the app is open
    locationManager.requestWhenInUseAuthorization()

    //Once we have the permission of using the location:
    if CLLocationManager.locationServicesEnabled(){

        locationManager.delegate = self
        locationManager.startUpdatingLocation()
        locationManager.desiredAccuracy = kCLLocationAccuracyBest
        locationManager.startUpdatingLocation()

    }

    tableView.delegate = self
    tableView.dataSource = self

}

//MARK: - Detect location
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {

    if let location = locations.first{

        latit = location.coordinate.latitude
        longit = location.coordinate.longitude
        print("Latitude: \(String(format: "%.4f", latit)), Longitude: \(String(format: "%.4f", longit))")
        latitString = String(format: "%.4f", latit)
        longitString = String(format: "%.4f", longit)
        print("Lat Str: \(latitString) | Lon Str: \(longitString)")

        //Adding elements to array.
        self.locationArray.append(latitString)//String(format: "%.4f", latit))
        self.locationArray.append(longitString)//String(format: "%.4f", longit))

        print(locationArray)

        //MARK: - Using NASA API to get DNI, GHI and DHI
        if let NASAurl = URL(string: "https://power.larc.nasa.gov/cgi-bin/v1/DataAccess.py?request=execute&identifier=SinglePoint&parameters=DNR,DIFF,ALLSKY_SFC_SW_DWN&userCommunity=SSE&tempAverage=CLIMATOLOGY&outputList=ASCII&lat=\(latitString)&lon=\(longitString)&user=anonymous"){

            print("This is NASA's url: \(NASAurl)")

            let task = URLSession.shared.dataTask(with: NASAurl) { (data, response, error) in

                if error != nil{

                    print(error!)

                }else{

                    if let urlContent = data{

                        do{

                            let NASAjsonResult = try JSONSerialization.jsonObject(with: urlContent, options: JSONSerialization.ReadingOptions.mutableContainers) as! [String:Any]
                            print("This is NASA jsonResult: \(NASAjsonResult)")

                            if let features = ((NASAjsonResult["features"] as? NSArray)?[0] as? NSDictionary)?["geometry"] as? String {

                                print("This is features: \(features)")

                            }else {print("ERROR for features")}

                        }catch{

                            print("NASA JSON Processing Failed.")

                        }

                    }

                }

            }

            task.resume()

        }

    }

}

}

```

This project is far from being finished and I know it still has a lot of bugs, but for now I only want to focus on getting the information from the API. 

Thanks in advance again!