AppleScript for Cryptocurrency Retrieval
Introduction
AppleScript provides robust automation capabilities within the Apple ecosystem. One of its many applications is retrieving the latest values of cryptocurrencies such as Bitcoin, Ethereum, and others.
Using AppleScript to Fetch Cryptocurrency Values
The following AppleScript snippet leverages the free and open source gist available here to fetch cryptocurrency values:
```applescript use AppleScript version "2.4" use scripting additions set url to "https://min-api.cryptocompare.com/data/price?" & "fsym=" & "BTC" & "&tsym=" & "USD" set url to quoted form of url set HTTPRequest to do shell script "curl -s " & url set response to HTTPRequest as text set result to response's contents set BTCtoUSD to (result as text)'s text item delimiters on run {} tell application "Numbers" activate repeat with i from 2 to length of BTCtoUSD tell cell i of column 2 of table 1 of worksheet 1 of document 1 set value to item i of BTCtoUSD end tell end repeat end tell end run ```To use this script:
- Copy and paste the script into a new AppleScript Editor document.
- Replace "BTC" with the symbol of the cryptocurrency you want to retrieve.
- Run the script.
The cryptocurrency value will be added to the second column of the first table in your active Numbers document.
Additional Resources
For more information about AppleScript and cryptocurrency, refer to the following resources:
Komentar