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)

Posted on Dec 11, 2017 3:06 AM

Reply
13 replies

Dec 12, 2017 3:54 AM in response to peterpotboiler

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

Dec 11, 2017 4:16 AM in response to Yellowbox

Thanks for your reply, the answers to your questions are as follows :

  • your version of Numbers (Menu > About Numbers);

    version 4.3.1 (5249)

  • your Operating system (Menu > Apple > About this Mac);

    macOS 10.12.6 (16G1036)

  • your overall aim;

    To create a Numbers sheet which has a LIVE data feed from a website URL

  • a screenshot of where you are up to;

    N/A

  • the formula that you are using.

    This is maybe what I am looking for ?

Dec 11, 2017 6:13 AM in response to SGIII

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

Dec 12, 2017 1:29 AM in response to SGIII

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

Dec 21, 2017 8:07 AM in response to SGIII

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.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

The Apple Numbers Application - Cell data from URL

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.