PHPackages                             iaewing/laravel-opensky - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. iaewing/laravel-opensky

ActiveLibrary[API Development](/categories/api)

iaewing/laravel-opensky
=======================

Laravel package for OpenSky Network API integration

1.3.1(2mo ago)014MITPHPPHP ^8.1

Since Jun 26Pushed 2mo agoCompare

[ Source](https://github.com/iaewing/laravel-opensky)[ Packagist](https://packagist.org/packages/iaewing/laravel-opensky)[ RSS](/packages/iaewing-laravel-opensky/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (14)Versions (8)Used By (0)

Laravel OpenSky Package
=======================

[](#laravel-opensky-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/dec7021a40532ec82a3bcd3414378191b2f0ee0ae45f168d4d7f17c9f9f56093/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69616577696e672f6c61726176656c2d6f70656e736b792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/iaewing/laravel-opensky)[![Total Downloads](https://camo.githubusercontent.com/9996cdf985d58f944e27360955b2909493ee3d1eccd81502de79e2cc7b349b35/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69616577696e672f6c61726176656c2d6f70656e736b792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/iaewing/laravel-opensky)

A Laravel package for easy integration with the [OpenSky Network API](https://openskynetwork.github.io/opensky-api/rest.html). This package provides a simple and elegant way to access real-time and historical aviation data.

**Note**: This package is for research and non-commercial purposes only, as per OpenSky Network's terms of use. For commercial usage, contact OpenSky Network directly.

Features
--------

[](#features)

- **Complete API Coverage**: Supports all OpenSky Network REST API endpoints
- **Laravel Integration**: Native Laravel service provider and facade
- **Type-Safe DTOs**: Strongly typed data transfer objects for all API responses
- **Caching Support**: Built-in response caching to reduce API calls
- **Rate Limiting**: Respects OpenSky API rate limits
- **Authentication**: Support for both anonymous and authenticated requests
- **Comprehensive Testing**: Full test coverage with PHPUnit

Requirements
------------

[](#requirements)

- **PHP**: 8.1 or higher
- **Laravel**: 9.x or higher

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require iaewing/laravel-opensky
```

The package will automatically register its service provider in Laravel 9+.

Optionally, publish the configuration file to customize cache settings, timeouts, or other options:

```
php artisan vendor:publish --tag=opensky-config
```

**Note**: Publishing the config is optional. The package works with default settings using only environment variables.

Configuration
-------------

[](#configuration)

Add your OpenSky credentials to your `.env` file. OpenSky supports two authentication methods:

### Option 1: OAuth2 Client Credentials (Recommended)

[](#option-1-oauth2-client-credentials-recommended)

```
OPENSKY_CLIENT_ID=your_client_id
OPENSKY_CLIENT_SECRET=your_client_secret
OPENSKY_CACHE_ENABLED=true
OPENSKY_CACHE_TTL=60
```

### Option 2: Legacy Basic Authentication (Being Deprecated)

[](#option-2-legacy-basic-authentication-being-deprecated)

```
OPENSKY_USERNAME=your_username
OPENSKY_PASSWORD=your_password
OPENSKY_CACHE_ENABLED=true
OPENSKY_CACHE_TTL=60
```

**Note**: For new accounts created after March 2025, you must use OAuth2. Legacy basic authentication only works for older accounts.

Authentication Methods
----------------------

[](#authentication-methods)

The OpenSky Network API supports two authentication methods:

### 1. OAuth2 Client Credentials Flow (Recommended)

[](#1-oauth2-client-credentials-flow-recommended)

This is the modern, secure authentication method required for all new accounts created after March 2025:

1. Log in to your OpenSky account at
2. Visit the Account page and create a new API client
3. Retrieve your `client_id` and `client_secret`
4. Add them to your `.env` file:

```
OPENSKY_CLIENT_ID=your_client_id
OPENSKY_CLIENT_SECRET=your_client_secret
```

### 2. Legacy Basic Authentication (Being Deprecated)

[](#2-legacy-basic-authentication-being-deprecated)

This method uses your OpenSky username and password directly. It only works for legacy accounts created before March 2025:

```
OPENSKY_USERNAME=your_opensky_username
OPENSKY_PASSWORD=your_opensky_password
```

**Important Notes:**

- The username/password refer to your OpenSky Network account credentials (not just any random credentials)
- New accounts must use OAuth2
- Legacy basic auth is being phased out
- You need an OpenSky Network account to access authenticated endpoints
- The package automatically prefers OAuth2 over basic auth when both are configured

### Anonymous Access

[](#anonymous-access)

Some endpoints work without authentication but have stricter rate limits:

- Only current data (no historical data)
- 400 API credits per day
- 10-second resolution instead of 5-second

Licensing and Terms of Use
--------------------------

[](#licensing-and-terms-of-use)

This package respects OpenSky Network's terms of use:

- **Research &amp; Non-Commercial Use**: Free with API rate limits
- **Commercial Use**: Requires separate licensing from OpenSky Network
- **Attribution Required**: When publishing research, cite the OpenSky paper:

    > Matthias Schäfer, Martin Strohmeier, Vincent Lenders, Ivan Martinovic and Matthias Wilhelm. "Bringing Up OpenSky: A Large-scale ADS-B Sensor Network for Research". In Proceedings of the 13th IEEE/ACM International Symposium on Information Processing in Sensor Networks (IPSN), pages 83-94, April 2014.

For commercial usage or higher rate limits, contact OpenSky Network directly at

Usage
-----

[](#usage)

### Basic Usage with Facade

[](#basic-usage-with-facade)

```
use OpenSky\Laravel\Facades\OpenSky;

// Get all current state vectors
$states = OpenSky::getAllStateVectors();

// Get state vectors in a specific area (bounding box)
$states = OpenSky::getAllStateVectors(
    lamin: 45.8389,  // Switzerland
    lomin: 5.9962,
    lamax: 47.8229,
    lomax: 10.5226
);

// Get flights in a time interval (max 1 hour)
$flights = OpenSky::getFlightsInTimeInterval(
    begin: now()->subHour()->timestamp,
    end: now()->timestamp
);
```

### Dependency Injection

[](#dependency-injection)

```
use OpenSky\Laravel\Client\OpenSkyClient;

class FlightController extends Controller
{
    public function __construct(private OpenSkyClient $openSky)
    {
    }

    public function index()
    {
        $states = $this->openSky->getAllStateVectors();

        return view('flights.index', compact('states'));
    }
}
```

Available Methods
-----------------

[](#available-methods)

### State Vectors

[](#state-vectors)

```
// Get all state vectors (rate limited for anonymous users)
$states = OpenSky::getAllStateVectors(?int $time, ?array $icao24, ?float $lamin, ?float $lomin, ?float $lamax, ?float $lomax, ?int $extended);

// Get your own state vectors (requires authentication)
$states = OpenSky::getOwnStateVectors(?array $serials);
```

### Flights

[](#flights)

```
// Get flights in time interval (max 1 hour)
$flights = OpenSky::getFlightsInTimeInterval(int $begin, int $end);

// Get flights by aircraft (max 30 days)
$flights = OpenSky::getFlightsByAircraft(string $icao24, int $begin, int $end);

// Get arrivals by airport (max 7 days)
$flights = OpenSky::getArrivalsByAirport(string $airport, int $begin, int $end);

// Get departures by airport (max 7 days)
$flights = OpenSky::getDeparturesByAirport(string $airport, int $begin, int $end);
```

### Tracks

[](#tracks)

```
// Get track by aircraft
$track = OpenSky::getTrackByAircraft(string $icao24, int $time = 0);
```

Data Transfer Objects
---------------------

[](#data-transfer-objects)

The package returns strongly typed DTOs for all API responses:

### StateVectorResponse

[](#statevectorresponse)

```
$states = OpenSky::getAllStateVectors();

echo $states->time; // Unix timestamp
foreach ($states->states as $state) {
    echo $state->icao24;        // Aircraft identifier
    echo $state->callsign;      // Flight callsign
    echo $state->originCountry; // Country of origin
    echo $state->latitude;      // Current latitude
    echo $state->longitude;     // Current longitude
    echo $state->baroAltitude;  // Barometric altitude
    echo $state->velocity;      // Ground speed
    echo $state->onGround;      // Is aircraft on ground
    // ... and more properties
}
```

### FlightResponse

[](#flightresponse)

```
$flights = OpenSky::getFlightsInTimeInterval($begin, $end);

foreach ($flights->flights as $flight) {
    echo $flight->icao24;
    echo $flight->callsign;
    echo $flight->estDepartureAirport;
    echo $flight->estArrivalAirport;
    echo $flight->firstSeen;
    echo $flight->lastSeen;
}
```

### TrackResponse

[](#trackresponse)

```
$track = OpenSky::getTrackByAircraft('3c4b26');

echo $track->icao24;
echo $track->callsign;
echo $track->startTime;
echo $track->endTime;

foreach ($track->path as $waypoint) {
    echo $waypoint->time;
    echo $waypoint->latitude;
    echo $waypoint->longitude;
    echo $waypoint->baroAltitude;
    echo $waypoint->trueTrack;
    echo $waypoint->onGround;
}
```

Examples
--------

[](#examples)

### Real-time Flight Tracking

[](#real-time-flight-tracking)

```
// Get all aircraft currently over Germany
$states = OpenSky::getAllStateVectors(
    lamin: 47.3024,
    lomin: 5.8662,
    lamax: 55.0581,
    lomax: 15.0419
);

foreach ($states->states as $aircraft) {
    if (!$aircraft->onGround && $aircraft->velocity > 100) {
        echo "Flight {$aircraft->callsign} at {$aircraft->baroAltitude}m altitude\n";
    }
}
```

### Airport Traffic Analysis

[](#airport-traffic-analysis)

```
// Get all departures from Frankfurt Airport in the last hour
$flights = OpenSky::getDeparturesByAirport(
    'EDDF',
    now()->subHour()->timestamp,
    now()->timestamp
);

$flightCount = $flights->flights->count();
echo "Frankfurt had {$flightCount} departures in the last hour\n";
```

### Aircraft Route Tracking

[](#aircraft-route-tracking)

```
// Track a specific aircraft's route
$track = OpenSky::getTrackByAircraft('3c4b26', now()->subHour()->timestamp);

$route = $track->path->map(function ($waypoint) {
    return [
        'lat' => $waypoint->latitude,
        'lng' => $waypoint->longitude,
        'alt' => $waypoint->baroAltitude,
        'time' => date('H:i:s', $waypoint->time)
    ];
});

// Use $route for map visualization
```

Configuration Options
---------------------

[](#configuration-options)

After publishing the config file (`php artisan vendor:publish --tag=opensky-config`), you can customize these settings in `config/opensky.php`:

```
return [
    // API endpoint
    'base_url' => env('OPENSKY_BASE_URL', 'https://opensky-network.org/api'),

    // Authentication (set in .env file)
    'username' => env('OPENSKY_USERNAME'),
    'password' => env('OPENSKY_PASSWORD'),
    'client_id' => env('OPENSKY_CLIENT_ID'),
    'client_secret' => env('OPENSKY_CLIENT_SECRET'),
    'oauth_token_url' => env('OPENSKY_OAUTH_TOKEN_URL', 'https://auth.opensky-network.org/auth/realms/opensky-network/protocol/openid-connect/token'),

    // Request timeout
    'timeout' => env('OPENSKY_TIMEOUT', 30),

    // Rate limiting
    'rate_limit' => [
        'enabled' => env('OPENSKY_RATE_LIMIT_ENABLED', true),
        'anonymous_per_day' => 400,
        'authenticated_per_day' => 4000,
        'active_feeder_per_day' => 8000,
    ],

    // Response caching
    'cache' => [
        'enabled' => env('OPENSKY_CACHE_ENABLED', true),
        'ttl' => env('OPENSKY_CACHE_TTL', 60), // seconds
        'store' => env('OPENSKY_CACHE_STORE', 'default'),
        'prefix' => 'opensky:',
    ],
];
```

Rate Limiting
-------------

[](#rate-limiting)

The OpenSky API has different rate limits based on API credits:

- **Anonymous users**: 400 API credits per day
- **Authenticated users**: 4000 API credits per day
- **Active feeders**: 8000 API credits per day

Credit usage varies by request:

- Small areas (0-25 sq deg): 1 credit
- Medium areas (25-100 sq deg): 2 credits
- Large areas (100-400 sq deg): 3 credits
- Global requests (&gt;400 sq deg): 4 credits

The package respects these limits and provides caching to reduce API calls.

Error Handling
--------------

[](#error-handling)

The package throws `OpenSkyException` for API errors:

```
use OpenSky\Laravel\Exceptions\OpenSkyException;

try {
    $states = OpenSky::getAllStateVectors();
} catch (OpenSkyException $e) {
    Log::error('OpenSky API error: ' . $e->getMessage());
}
```

Testing
-------

[](#testing)

This package uses [Pest](https://pestphp.com) for testing:

```
composer test

# Run tests with coverage
./vendor/bin/pest --coverage

# Run specific test file
./vendor/bin/pest tests/Unit/OpenSkyClientTest.php

# Run with verbose output
./vendor/bin/pest --verbose
```

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

Credits
-------

[](#credits)

- Built for the [OpenSky Network](https://opensky-network.org/) API
- Inspired by the need for easy aviation data access in Laravel applications

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

OAuth Token Caching
-------------------

[](#oauth-token-caching)

When using OAuth2 authentication, the package automatically caches access tokens to improve performance:

- **Token Lifetime**: OAuth2 tokens are valid for 30 minutes
- **Cache Duration**: Tokens are cached for 25 minutes (5 minutes before expiry)
- **Automatic Refresh**: New tokens are automatically requested when the cached token expires
- **Cache Key**: Uses a hash of your client\_id to ensure uniqueness
- **Cache Store**: Uses the same cache store configured for API responses

This means you won't need to authenticate on every API call, significantly improving performance for applications making frequent requests.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance83

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~48 days

Recently: every ~71 days

Total

7

Last Release

85d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/650ba3a550c4b7bd25e3a5e0db297bf32f9cd1a774df77a10f3021e883f30fa7?d=identicon)[iaewing](/maintainers/iaewing)

---

Top Contributors

[![iaewing](https://avatars.githubusercontent.com/u/19676786?v=4)](https://github.com/iaewing "iaewing (16 commits)")

---

Tags

apilaravelaviationOpenSkyflight-tracking

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/iaewing-laravel-opensky/health.svg)

```
[![Health](https://phpackages.com/badges/iaewing-laravel-opensky/health.svg)](https://phpackages.com/packages/iaewing-laravel-opensky)
```

###  Alternatives

[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k108.5M885](/packages/laravel-socialite)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.6k3](/packages/defstudio-telegraph)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
