API

From UniFly Documentation

We have recently decided to open our API for customization of personal websites. For this you will need to gain an API Key, this can be gained by visiting our Discord Server, and Submitting a Ticket. - Note you must have a Crew Centre Account before we can create your API account.

API LINK:

https://unifly.gg/api.php?apikey=&endpoint=

This will enable you to obtain a json that can be used to enter specific information to your website.

Usage and Limitations

Your API key will be limited to: 500 uses per hour, and 5000 uses per day. If you go over this limit you will receive an error message:


{

  "message": "API Key has reached it's limit for the current hour."

}

Or


{

  "message": "API Key has reached it's limit for the current day."

}

Valid Endpoints

These endpoints are subject to change.

  • &endpoint=status = This shows your current api usage, and api account status.
  • &endpoint=airportInfo&icao=ICAO = Gets the Airport Information for a specific ICAO.
  • &endpoint=distanceToAirport&name=NAME&icao=ICAO&unit=UNIT = Gets the distance to an airport from the user's current location.
  • &endpoint=flightplan&name=NAME&unit=UNIT = Gets a Flight Plan Information for the users current flight.

VALUES FOR ENDPOINTS

  • NAME = The user's Nickname that is flying.
  • ICAO = An Airport ICAO Code.
  • UNIT = N/K (Distance Unit in NM, KM)

EXAMPLE PHP/CURL CODE

You can use the following code to in a PHP script to access our API interface.

$url = "https://unifly.gg/api.php?apikey=YOURAPIKEY&endpoint=ENDPOINT STRING";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$http_text = curl_exec($ch);
$data = json_decode($http_text, true);
$message = $data[0]['message'];
if(isset($message)){
echo "API Error: " . $message;
} else {
// API IS WORKING SUCCESSFULLY!
$value = $data[0]['valueinapi'];
echo $value;
}