The Apple Numbers Application - Cell data from URL
If I am using the Apple Numbers Application is it possible to populated cells with data provided by via a URL ?
For example a URL that returns JSON.
iMac, Mac OS X (10.6.6)
If I am using the Apple Numbers Application is it possible to populated cells with data provided by via a URL ?
For example a URL that returns JSON.
iMac, Mac OS X (10.6.6)
A script like this works here. Change the names in the first four lines to suit.
Copy-paste into Script Editor. Also make sure Script Editor is checked at System Preferences > Security & Privacy > Privacy > Accessiblity.
With the document open click the triangle 'run' button to retrieve the price.
You could put this script in a menu and attach it to a keyboard shortcut. But note that you have to trigger it manually. If you need constant updating you might be better off with Google Sheets.
SG
set docName to "Untitled.numbers"
set shtName to "Sheet 1"
set tblName to "Table 1"
set cellName to "A1"
set jsnData to do shell script "curl -s " & "https://api.coinmarketcap.com/v1/ticker/bitcoin/"
set text item delimiters to "price_usd"
set usdPrice to jsnData's text item 2's word 1 as number
tell application "Numbers" to set documentdocName'ssheetshtName'stabletblName'scellcellName'svalue to usdPrice
Yes, in general it's possible to retrieve data from a url and populate cells in Numbers, via a script. But, as Ian points out, specifics are needed (what url, what data) before anyone here can post a useful response.
SG
The price can easily be retrieved with a 4-line script. But you don't say where you want to put it.
SG
peterpotboiler wrote:
Into a cell in a Numbers spreadsheet.
Hi Peter,
What cell? What table? What sheet? What document?
SG
Hi Peter,
What are you trying to do?
Please reply with:
More information will lead to a solution 😉.
Regards,
Ian.
Thanks for your reply, the answers to your questions are as follows :
version 4.3.1 (5249)
macOS 10.12.6 (16G1036)
To create a Numbers sheet which has a LIVE data feed from a website URL
N/A
This is maybe what I am looking for ?
I would like to get the 'price_usd' from this URL :
https://api.coinmarketcap.com/v1/ticker/bitcoin/
which returns this data :
[
{
"id": "bitcoin",
"name": "Bitcoin",
"symbol": "BTC",
"rank": "1",
"price_usd": "16595.2",
"price_btc": "1.0",
"24h_volume_usd": "12833700000.0",
"market_cap_usd": "277709470240",
"available_supply": "16734325.0",
"total_supply": "16734325.0",
"max_supply": "21000000.0",
"percent_change_1h": "-0.42",
"percent_change_24h": "10.83",
"percent_change_7d": "45.45",
"last_updated": "1513001353"
}
]
Many Thanks
SG,
Apologies but I don't quiet understand what you are asking me ? ...
In the Apple Numbers application, I would like to put the value obtained by :
1. Calling the following URL https://api.coinmarketcap.com/v1/ticker/bitcoin/
2. Somehow storing the returned JSON (shown above)
3. Parsing out the value in said JSON from the key value pair specified by the key "price_usd"
Into a cell in a Numbers spreadsheet.
Apologies again if I was not specific enough.
Can you provide this 4-line script ?
Many thanks
Peter
Hi SG,
Sorry, I must be missing something here !!!!
Do you want me to specify a cell of a sheet of a document,
before you can give me the 4 lines of code you mentioned ?
If so .... then .... A1, sheet 1, untitled.numbers.
Please, Please, Please help me here, I am VERY confused about what you are asking here ?
Many thanks
Peter
Thank you a lot for this.
I just have a small problem.
The script doesn't let me class usdprice as a number, I have to input as a text.
Whenever the number as more than 1 decimal number, numbers app doesn't put the dot anywhere, just appears an enormous number that doesn't have anything to do with the price I want.
I never programmed in my life, I am just testing to change the logic of the language to see if it works.
Thank you in advance for any help.
Hi SG,
Thanks - That's very cool !!
Very grateful for your assistance.
Merry XMAS
Peter
Perhaps your Mac is set to a region that uses , as the decimal separator? If so you could try temporarily changing to US region to so if that is the problem.
SG
The Apple Numbers Application - Cell data from URL