Search Unity

How do I get an API from a third party to read into Unity?

Discussion in 'Scripting' started by mojojojo, Oct 4, 2015.

  1. mojojojo

    mojojojo

    Joined:
    Dec 16, 2009
    Posts:
    138
    I'm completely green and never tried this or even learned any coding to this so my questions may sound dumb. So please if you could, answer as if teaching a third grader how to program. I want to take real-time data from an api developed for bus schedules and pull that data into Unity. I've heard of Unity's WWW form but I'm not sure how that works with the website's API. So the website gives me a url and some of it's code for it's classes in various forms. Do I need to install something and add a "Using.xyz" to the Unity script? Does the WWW take everything from the url given such that I can use the API's data as a new class just by using the WWW? How does this all work and compile?
     
  2. Duugu

    Duugu

    Joined:
    May 23, 2015
    Posts:
    241
    This depends on the type of API you're trying to work with. But basically you're using the WWW class so send HTTP requests to a server and parse the received data.
    You don't need to install something.
    Calling API functions is just a matter of sending the appropriate (see the API documentation) HTTP request.
    This tutorial shows how to get and parse data (XLM/JSON ... if your API delivers other data types you'll have to ask google on the parsing part).