https://openapibox.com/api/airportsapi/YOUR-API-KEY/getInfo?iso_country=BD&name=Hazrat&ident=VGZR&type=large_airport&continent=AS&gps_code=VGHS&iata_code=DAC&scheduled_service=yes&local_code=&filter[]=id&filter[]=ident&filter[]=name&filter[]=type&filter[]=latitude_deg&filter[]=longitude_deg
<?php
$endpoint = 'https://openapibox.com/api/airportsapi/YOUR-API-KEY/get';
$params = [
'ident' => 'VGZR',
'name' => 'Hazrat Shahjalal International Airport',
'type' => 'large_airport',
'continent' => 'AS',
'iso_country' => 'BD',
'gps_code' => 'VGHS',
'iata_code' => 'DAC',
'scheduled_service' => 'yes',
'local_code' => '',
'filter[]' => ['id', 'ident', 'name', 'type', 'latitude_deg', 'longitude_deg'],
];
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => $endpoint,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($params),
]);
$response = curl_exec($curl);
if ($response === false) {
echo 'cURL error: ' . curl_error($curl);
} else {
echo htmlentities($response);
}
curl_close($curl);
?>
<?php
use GuzzleHttp\Client;
$client = new Client();
$endpoint = 'https://openapibox.com/api/airportsapi/YOUR-API-KEY/get';
$params = [
'ident' => 'VGZR',
'name' => 'Hazrat Shahjalal International Airport',
'type' => 'large_airport',
'continent' => 'AS',
'iso_country' => 'BD',
'gps_code' => 'VGHS',
'iata_code' => 'DAC',
'scheduled_service' => 'yes',
'local_code' => '',
'filter' => ['id', 'ident', 'name', 'type', 'latitude_deg', 'longitude_deg'],
];
try {
$response = $client->post($endpoint, [
'form_params' => $params,
]);
$statusCode = $response->getStatusCode();
$body = $response->getBody()->getContents();
echo "Response Code: $statusCode\n";
echo "Response Body:\n";
echo htmlentities($body);
} catch (\GuzzleHttp\Exception\RequestException $e) {
echo 'Request failed: ' . $e->getMessage();
if ($e->hasResponse()) {
echo "\n" . $e->getResponse()->getBody();
}
}
?>
const endpoint = "https://openapibox.com/api/airportsapi/YOUR-API-KEY/get";
const params = {
ident: 'VGZR',
name: 'Hazrat Shahjalal International Airport',
type: 'large_airport',
continent: 'AS',
iso_country: 'BD',
gps_code: 'VGHS',
iata_code: 'DAC',
scheduled_service: 'yes',
local_code: '',
filter: ['id', 'ident', 'name', 'type', 'latitude_deg', 'longitude_deg'],
};
async function fetchAirports() {
try {
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams(params),
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const data = await response.json();
console.log('API Response:', data);
} catch (error) {
console.error('Error fetching airports:', error.message);
}
}
fetchAirports();
import requests
endpoint = "https://openapibox.com/api/airportsapi/YOUR-API-KEY/get"
params = {
'ident': 'VGZR',
'name': 'Hazrat Shahjalal International Airport',
'type': 'large_airport',
'continent': 'AS',
'iso_country': 'BD',
'gps_code': 'VGHS',
'iata_code': 'DAC',
'scheduled_service': 'yes',
'local_code': '',
'filter[]': ['id', 'ident', 'name', 'type', 'latitude_deg', 'longitude_deg'],
}
try:
response = requests.post(endpoint, data=params)
if response.status_code == 200:
data = response.json()
print('API Response:', data)
else:
print(f'Error: {response.status_code} - {response.text}')
except requests.exceptions.RequestException as e:
print(f'Error making request: {e}')
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
)
// Struct to represent the parameters
type Params struct {
Ident string `json:"ident,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Continent string `json:"continent,omitempty"`
IsoCountry string `json:"iso_country,omitempty"`
GpsCode string `json:"gps_code,omitempty"`
IataCode string `json:"iata_code,omitempty"`
ScheduledService string `json:"scheduled_service,omitempty"`
LocalCode string `json:"local_code,omitempty"`
Filter []string `json:"filter[]"`
}
func main() {
// Define the API endpoint
endpoint := "https://openapibox.com/api/airportsapi/YOUR-API-KEY/get"
// Optional parameters
params := Params{
Ident: "VGZR", // Optional: Airport identifier (e.g., 'VGZR')
Name: "Hazrat Shahjalal International Airport", // Optional: Name of the airport
Type: "large_airport", // Optional: Type of airport (e.g., 'large_airport')
Continent: "AS", // Optional: Continent (e.g., 'AS' for Asia)
IsoCountry: "BD", // Optional: ISO country code (e.g., 'BD' for Bangladesh)
GpsCode: "VGHS", // Optional: GPS code of the airport
IataCode: "DAC", // Optional: IATA code of the airport
ScheduledService: "yes", // Optional: Scheduled service availability (e.g., 'yes')
LocalCode: "", // Optional: Local code of the airport
Filter: []string{"id", "ident", "name", "type", "latitude_deg", "longitude_deg"}, // Optional: Fields to filter
}
// Convert params to JSON
data, err := json.Marshal(params)
if err != nil {
log.Fatalf("Error marshaling params: %v", err)
}
// Create a new POST request with the parameters as JSON
req, err := http.NewRequest("POST", endpoint, bytes.NewBuffer(data))
if err != nil {
log.Fatalf("Error creating request: %v", err)
}
// Set appropriate headers
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
// Send the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Fatalf("Error sending request: %v", err)
}
defer resp.Body.Close()
// Check if the request was successful
if resp.StatusCode != http.StatusOK {
log.Printf("Error: %v\n", resp.Status)
body, _ := ioutil.ReadAll(resp.Body)
log.Printf("Response body: %s", body)
return
}
// Parse the JSON response
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalf("Error reading response body: %v", err)
}
// Print the response
fmt.Println("API Response:", string(body))
}