Need Help With HTTP connection to an API

Discussion in 'Programming' started by Drturtlebot, Aug 30, 2019.

  1. Drturtlebot

    Drturtlebot Member

    Joined:
    Jun 22, 2019
    Posts:
    3
    Hello, Im trying to make a HTTP request to an api and then display the data but im unsure on how to do it with the specific file. Any Ideas? Im trying to get the "Meta Data\6. Time Zone" words as a string from https://www.alphavantage.co/query?f...NTRADAY&symbol=MSFT&interval=5min&apikey=demo any clues?
    [​IMG]
    Trying to read that so it would display US/Eastern,
    Also learning so that i can expand it to the rest of the list
     
  2. Binsk

    Binsk Member

    Joined:
    Jun 22, 2016
    Posts:
    648
    Show us your GM code for what you've tried so far.
     
  3. Homunculus

    Homunculus Member

    Joined:
    Jun 20, 2016
    Posts:
    853
    Well this looks like a JSON file, you should be able to read everything using json_decode and reading a couple of values from the resulting ds_map
     
  4. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,793
    This isn't difficult at all once you learn how to work down a JSON hierarchy. Here the path is just "Meta Data" > "6. Time Zone".

    Assuming that you already have it decoded to json_data, this is all you need:
    Code:
    var metadata = json_data[? "Meta Data"];
    var timezone = metadata[? "6. Time Zone"];
    Or if you have the utility script from this post, it's a one-liner:
    Code:
    var timezone = json_get(json_data, "Meta Data", "6. Time Zone");
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice