MUA Flights EAPI

(0 reviews)

home

MUA Flights EAPI Documentation

Overview and Purpose of the API

The MUA Flights EAPI is a RESTful API designed to provide access to flight-related data and functionality. It allows users to retrieve a list of flights based on specific criteria and to create new flight records. This API is suitable for applications that require integration with flight data, such as travel booking platforms, airline management systems, or flight tracking applications.

The API supports JSON as the media type for requests and responses, ensuring compatibility with modern web and mobile applications.


Authentication Requirements and Security Details

The MUA Flights EAPI enforces client identification for all requests. This means that every request must include a valid client_id to authenticate and authorize access to the API. Without a valid client_id, requests will be rejected.


Base URL and Environments

The base URL for accessing the MUA Flights EAPI will depend on the environment in which the API is deployed. Ensure you use the correct URL for your environment:

  • Production Environment: https://api.mua-flights.com/v2
  • Sandbox Environment: https://sandbox.api.mua-flights.com/v2

All endpoints described below should be appended to the base URL.


Detailed Endpoint Documentation

1. Get Flights List

Endpoint

GET /flights

Description

Retrieve a list of flights. You can optionally filter the results by destination airport code or airline.

Query Parameters
ParameterTypeRequiredDescriptionAllowed Values
codestringNoDestination airport codeSFO, LAX, PDX, CLE, PDF
airlinestringNoAirline nameunited, delta, american
Request Example
GET /flights?code=SFO&airline=united HTTP/1.1
Host: api.mua-flights.com
Content-Type: application/json
client_id: YOUR_CLIENT_ID
Response
  • Status Code: 200 OK
  • Headers:
    • Content-Type: application/json
  • Body: A list of flight objects.
Response Example
[
  {
    "flightNumber": "UA123",
    "departure": "2023-10-15T10:00:00Z",
    "arrival": "2023-10-15T14:00:00Z",
    "origin": "LAX",
    "destination": "SFO",
    "airline": "united"
  },
  {
    "flightNumber": "DL456",
    "departure": "2023-10-15T12:00:00Z",
    "arrival": "2023-10-15T16:00:00Z",
    "origin": "PDX",
    "destination": "SFO",
    "airline": "delta"
  }
]

2. Post a New Flight

Endpoint

POST /flights

Description

Create a new flight record by providing the flight details in the request body.

Request Body
FieldTypeRequiredDescription
flightNumberstringYesUnique identifier for the flight
departurestringYesDeparture time in ISO 8601 format
arrivalstringYesArrival time in ISO 8601 format
originstringYesOrigin airport code
destinationstringYesDestination airport code
airlinestringYesAirline name
Request Example
POST /flights HTTP/1.1
Host: api.mua-flights.com
Content-Type: application/json
client_id: YOUR_CLIENT_ID

{
  "flightNumber": "AA789",
  "departure": "2023-10-20T08:00:00Z",
  "arrival": "2023-10-20T12:00:00Z",
  "origin": "CLE",
  "destination": "PDF",
  "airline": "american"
}
Response
  • Status Code: 201 Created
  • Headers:
    • Content-Type: application/json
    • Location: URL of the newly created flight resource
  • Body: None
Response Example
HTTP/1.1 201 Created
Content-Type: application/json
Location: https://api.mua-flights.com/v2/flights/AA789

Error Handling and Status Codes

The MUA Flights EAPI uses standard HTTP status codes to indicate the success or failure of API requests. Below is a list of possible status codes and their meanings:

Status CodeDescription
200 OKThe request was successful, and the response contains the requested data.
201 CreatedThe request was successful, and a new resource was created.
400 Bad RequestThe request was invalid or missing required parameters.
401 UnauthorizedThe request did not include a valid client_id.
404 Not FoundThe requested resource could not be found.
500 Internal Server ErrorAn unexpected error occurred on the server.
Example Error Response
{
  "error": "Invalid client_id",
  "message": "The client_id provided is not valid."
}

Best Practices for Implementation

  • Authentication: Always include a valid client_id in your requests to ensure successful authentication.
  • Error Handling: Implement robust error handling in your application to gracefully handle API errors and provide meaningful feedback to users.
  • Rate Limiting: Be mindful of any rate limits imposed by the API. Avoid sending excessive requests in a short period.
  • Data Validation: Validate input data before sending requests to the API to minimize errors and ensure data integrity.
  • Use Query Parameters Wisely: When using the GET /flights endpoint, specify query parameters (code and airline) only when necessary to filter results.

Sample Code Snippets

1. Fetching Flights List (Python)

import requests

url = "https://api.mua-flights.com/v2/flights"
params = {
    "code": "SFO",
    "airline": "united"
}
headers = {
    "Content-Type": "application/json",
    "client_id": "YOUR_CLIENT_ID"
}

response = requests.get(url, headers=headers, params=params)
print(response.json())

2. Creating a New Flight (Python)

import requests

url = "https://api.mua-flights.com/v2/flights"
headers = {
    "Content-Type": "application/json",
    "client_id": "YOUR_CLIENT_ID"
}
data = {
    "flightNumber": "AA789",
    "departure": "2023-10-20T08:00:00Z",
    "arrival": "2023-10-20T12:00:00Z",
    "origin": "CLE",
    "destination": "PDF",
    "airline": "american"
}

response = requests.post(url, headers=headers, json=data)
print(response.status_code)
print(response.headers.get("Location"))

This concludes the documentation for the MUA Flights EAPI. For further assistance, please contact the API support team.


Reviews