SkyAPI Tutorial: Design and Examples

SkyAPI Tutorial: Design and Examples

In this tutorial, we will walk you through the design of SkyAPI, an API for skydiving enthusiasts. This API allows skydivers to check available airports, weather conditions, queues for skydiving, and the number of loads (flights) at each airport. Below is a detailed analysis of each endpoint with examples to help you understand how the API works.

1. GET /airports

Purpose

Fetches a list of airports that support skydiving, potentially filtered by user location, radius, or ideal weather conditions.

Method

GET

URL

/api/v1/skydiving/airports

Authentication

Required

Parameters

Sample Request

GET /api/v1/skydiving/airports?location=51.5074,-0.1278&radius=100&weather_conditions=true
Authorization: Bearer <token>

Response

{
    "airports": [
        {
            "id": 1,
            "name": "Skydive London",
            "location": {
                "latitude": 51.505,
                "longitude": -0.09
            },
            "ideal_conditions": true,
            "contact_info": {
                "phone": "+44 123456789",
                "email": "info@skydive-london.com"
            }
        },
        {
            "id": 2,
            "name": "Skydive Bristol",
            "location": {
                "latitude": 51.4545,
                "longitude": -2.5879
            },
            "ideal_conditions": false,
            "contact_info": {
                "phone": "+44 987654321",
                "email": "info@skydive-bristol.com"
            }
        }
    ]
}

Use Case

A skydiver opens the app and wants to find airports within 100 km with ideal weather conditions to plan a skydiving session. This endpoint provides them with available options.

2. GET /airport/{id}

Purpose

Retrieves detailed information about a specific airport, including real-time queue data and load availability.

Method

GET

URL

/api/v1/skydiving/airport/{id}

Authentication

Required

Path Parameter

id: The ID of the airport.

Sample Request

GET /api/v1/skydiving/airport/1
Authorization: Bearer <token>

Response

{
    "airport": {
        "id": 1,
        "name": "Skydive London",
        "location": {
            "latitude": 51.505,
            "longitude": -0.09
        },
        "weather_conditions": {
            "wind_speed": "10 mph",
            "visibility": "Clear",
            "ideal_for_skydiving": true
        },
        "loads": {
            "total_loads_today": 5,
            "next_load_time": "12:30 PM",
            "open_spots": 2
        },
        "queue": [
            {
                "skydiver_id": 23,
                "name": "John Doe",
                "experience_level": "Intermediate",
                "position_in_queue": 1,
                "license_id": "A-12345",
                "type_of_jump": "Tandem",
                "aff_level": 5
            },
            {
                "skydiver_id": 45,
                "name": "Jane Smith",
                "experience_level": "Advanced",
                "position_in_queue": 2,
                "license_id": "B-98765",
                "type_of_jump": "Solo",
                "aff_level": 7
            }
        ]
    }
}

Use Case

A skydiver wants to check the availability at a specific airport (e.g., Skydive London), including current weather, available loads, and the queue for the next jump. The skydiver can see detailed information, such as the type of jump and AFF level, for each person in the queue.

3. GET /airport/{id}/queue

Purpose

Retrieves the current queue of skydivers waiting to jump at the selected airport.

Method

GET

URL

/api/v1/skydiving/airport/{id}/queue

Authentication

Required

Path Parameter

id: The ID of the airport.

Sample Request

GET /api/v1/skydiving/airport/1/queue
Authorization: Bearer <token>

Response

{
    "queue": [
        {
            "skydiver_id": 23,
            "name": "John Doe",
            "experience_level": "Intermediate",
            "position_in_queue": 1,
            "expected_jump_time": "12:45 PM",
            "license_id": "A-12345",
            "type_of_jump": "Tandem",
            "aff_level": 5
        },
        {
            "skydiver_id": 45,
            "name": "Jane Smith",
            "experience_level": "Advanced",
            "position_in_queue": 2,
            "expected_jump_time": "1:00 PM",
            "license_id": "B-98765",
            "type_of_jump": "Solo",
            "aff_level": 7
        }
    ]
}

Use Case

A skydiver checks the current queue to see how many people are ahead of them and their estimated jump time.

4. GET /airport/{id}/loads

Purpose

Retrieves a list of loads (flights) at a specific airport. Each load includes details such as departure time, altitude of the drop, capacity, and a list of skydivers on board.

Method

GET

URL

/api/v1/skydiving/airport/{id}/loads

Authentication

Required

Path Parameter

id: The ID of the airport.

Response

{
    "loads": [
        {
            "load_id": 1,
            "departure_time": "12:30 PM",
            "altitude": 15000,
            "capacity": 5,
            "skydivers": [
                {
                    "skydiver_id": 23,
                    "name": "John Doe",
                    "license_id": "A-12345",
                    "experience_level": "Intermediate"
                },
                {
                    "skydiver_id": 45,
                    "name": "Jane Smith",
                    "license_id": "B-98765",
                    "experience_level": "Advanced"
                }
            ]
        },
        {
            "load_id": 2,
            "departure_time": "1:15 PM",
            "altitude": 13000,
            "capacity": 6,
            "skydivers": [
                {
                    "skydiver_id": 12,
                    "name": "Alice Johnson",
                    "license_id": "C-76543",
                    "experience_level": "Beginner"
                }
            ]
        }
    ]
}

Use Case

A skydiver wants to see detailed information about the upcoming loads (flights) at a specific airport. They can check the departure time, altitude, and capacity of each load, as well as see the list of skydivers who will be on board.