Solution 1 :

Firstly JSON is a standard data format. PHP is a backend programming language. Basically the URL is returning JSON Format. You have to call the endpoint with an apikey. Because if you call now the api by a client call f.e with the jquery’s AJAX request:

$.get("<url>", function(data){
console.log(data)
})

You will get this information:

error: 
responseText: "{↵    "Information": "The **demo** API key is for demo purposes only. Please claim your free API key at (https://www.alphavantage.co/support/#api-key) to explore our full API offerings. It takes fewer than 20 seconds, and we are committed to making it free forever."↵}"

After adding you apikey you are able to receive your data.

Please read this:
for asynchronous calls to an endpoint: https://api.jquery.com/jquery.get/

how to work with json: https://www.w3schools.com/js/js_json_intro.asp

you will get a stringified json, to work with it you have to parse it, to work with it as an object. https://www.w3schools.com/js/js_json_parse.asp

Problem :

I’m trying to work with the alphavantage API to fetch the currency exchange data.

This is the query URI I’m using:

https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=USD&to_currency=JPY&apikey=demo

Below is the data the API returns:

{
    "Realtime Currency Exchange Rate": {
        "1. From_Currency Code": "USD",
        "2. From_Currency Name": "United States Dollar",
        "3. To_Currency Code": "JPY",
        "4. To_Currency Name": "Japanese Yen",
        "5. Exchange Rate": "108.99000000",
        "6. Last Refreshed": "2020-01-28 14:35:01",
        "7. Time Zone": "UTC",
        "8. Bid Price": "108.99000000",
        "9. Ask Price": "108.99000000"
    }
}

How would I query for this data in PHP?

By