0

i'm trying to create variables for each of the listed data from a json file in swiftUI, for stocks was easy to create because the data is clear to interrupt. for example, i've created variables for each quote that is listed in the API documentation.

 The data set from the API documentation is 
    https://www.alphavantage.co/query? 
    function=GLOBAL_QUOTE&symbol=IBM&apikey=demo


  
"Global Quote": {
    "01. symbol": "IBM",
    "02. open": "125.4300",
    "03. high": "126.3200",
    "04. low": "124.9100",
    "05. price": "125.1000",
    "06. volume": "5916789",
    "07. latest trading day": "2021-10-29",
    "08. previous close": "125.8400",
    "09. change": "-0.7400",
    "10. change percent": "-0.5880%"
         }
      }


The variables in stocks that i've created is 



     import Foundation 
     struct Qoute: Codable {
     var symbol: String
     var open: String
     var high: String
     var low: String
     var price: String
     var change: String
     var changePrecent: String
     } 

However I am having trouble creating variables for an API with the time interval for each crypto this is the data

       "Meta Data": {
    "1. Information": "Crypto Intraday (5min) Time 
     Series",
    "2. Digital Currency Code": "ETH",
    "3. Digital Currency Name": "Ethereum",
    "4. Market Code": "USD",
    "5. Market Name": "United States Dollar",
    "6. Last Refreshed": "2021-10-31 15:40:00",
    "7. Interval": "5min",
    "8. Output Size": "Compact",
    "9. Time Zone": "UTC"
       },
       "Time Series Crypto (5min)": {
        "2021-10-31 15:40:00": {
        "1. open": "4206.86000",
        "2. high": "4208.46000",
        "3. low": "4202.29000",
        "4. close": "4202.30000",
        "5. volume": 214 

 MY Swift Code

         import fundation 
          struct CryptoIntradeDay: Codable {
          var symbol: String
          var market: String
         var interval: String


      }

But I don't think those are all of the values that I am wanting to receive back from this API. I would like to get the results for price, open, high, low, interval, but I am not sure that i'm reading this API file correctly, or if I am simply using the wrong API for the data that I would like to receive back. The website for the API is, https://www.alphavantage.co/documentation/

The file that I am getting this data set from is https://www.alphavantage.co/query?function=CRYPTO_INTRADAY&symbol=ETH&market=USD&interval=5min&apikey=demo

2
  • Note that the duplicate question isn't an exact match but it should be close enough for you to solve this. Commented Oct 31, 2021 at 16:10
  • This is a very useful tool! thank you Commented Oct 31, 2021 at 16:14

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.