Solved Pull data from URL

  • Thread starter Deleted member 5254
  • Start date
  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.
D

Deleted member 5254

So, I know that you can Check for data on a website... such as a version number, but can you pull part of said data back into a variable?

For example, I have a website that loads this data
code_language.skript:
{"status":"success","symbol":"AAPL","last":{"price":169.59,"size":100,"exchange":4,"timestamp":1522972796700}}
From that I need to pull the "price" and put it into a variable.

Is that possible?
 
I used SkQuery to get the info from the website, and set it into a variable, (I was advised not to use SkQuery, but it works for me)
Then I used skript-json to copy the web info into a json variable
code_language.skript:
set {_stock.%arg-2%} to text from "https://api.polygon.io/v1/last/stocks/%arg-2%?apiKey={@apikey}"
copy json from {_stock.%arg-2%} to {json::*}
Then used the json variable like this
code_language.skript:
{json::last::price}
In my message to the player
 
Status
Not open for further replies.