PHPackages                             projectsaturnstudios/nws - 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. projectsaturnstudios/nws

ActiveLibrary[API Development](/categories/api)

projectsaturnstudios/nws
========================

National Weather Service (NWS) integration for Laravel applications.

0.7.0(7mo ago)221MITPHPPHP ^8.2

Since Sep 27Pushed 7mo agoCompare

[ Source](https://github.com/projectsaturnstudios/nws)[ Packagist](https://packagist.org/packages/projectsaturnstudios/nws)[ RSS](/packages/projectsaturnstudios-nws/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (6)Versions (2)Used By (0)

Laravel NWS (National Weather Service) Package
==============================================

[](#laravel-nws-national-weather-service-package)

A Laravel package for integrating with the National Weather Service API. Get weather forecasts, current conditions, and alerts directly from the source - no API key required!

Features
--------

[](#features)

- 🌤️ **Current Weather &amp; Forecasts** - Get detailed weather information
- ⚡ **Weather Alerts** - Real-time warnings, watches, and advisories
- 🎯 **Location-based** - Support for coordinates and addresses
- 🚀 **Laravel Native** - Built with Laravel HTTP Client and Facades
- 💾 **Smart Caching** - Configurable caching for optimal performance
- 🔧 **Builder Pattern** - Fluent, chainable API for easy usage
- 📊 **Rich Data** - Strongly typed DTOs using Spatie Laravel Data

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

[](#installation)

```
composer require projectsaturnstudios/nws
```

Publish the configuration file:

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

Quick Start
-----------

[](#quick-start)

### Using the Facade

[](#using-the-facade)

```
use ProjectSaturnStudios\NWS\Support\Facades\NWS;

// Get current weather for Tampa
$weather = NWS::forTampa()->getCurrentWeather();

// Get 7-day forecast for any location
$forecast = NWS::location(40.7128, -74.0060)->getForecast();

// Get weather alerts for Florida
$alerts = NWS::getAlertsForArea('FL');
```

### Using the Builder Pattern

[](#using-the-builder-pattern)

```
use ProjectSaturnStudios\NWS\NationalWeatherService;

$nws = NationalWeatherService::make()
    ->location(27.9506, -82.4572)  // Tampa coordinates
    ->units('us');                  // US customary units

$currentWeather = $nws->getCurrentWeather();
$hourlyForecast = $nws->getHourlyForecast();
$alerts = $nws->getAlerts();
```

API Methods
-----------

[](#api-methods)

### Weather Data

[](#weather-data)

```
// Get current conditions and forecast
$weather = NWS::location($lat, $lon)->getCurrentWeather();

// Get 7-day forecast
$forecast = NWS::location($lat, $lon)->getForecast();

// Get hourly forecast
$hourly = NWS::location($lat, $lon)->getHourlyForecast();

// Get point information (grid coordinates, office, etc.)
$point = NWS::location($lat, $lon)->getPoint();
```

### Weather Alerts

[](#weather-alerts)

```
// Get alerts for a state/area
$alerts = NWS::getAlertsForArea('FL');

// Get alerts for a specific zone
$alerts = NWS::getAlertsForZone('FLZ151');

// Get alerts for coordinates
$alerts = NWS::location($lat, $lon)->getAlerts();

// Filter severe alerts
$severeAlerts = $alerts->getSevereAlerts();
$activeAlerts = $alerts->getActiveAlerts();
```

### Configuration Options

[](#configuration-options)

```
// Set units (us or si)
$nws = NWS::make()->units('si');

// Enable experimental features
$nws = NWS::make()->withFeatureFlags([
    'forecast_temperature_qv',
    'forecast_wind_speed_qv'
]);
```

Response Data
-------------

[](#response-data)

All responses are strongly typed using Spatie Laravel Data:

```
$forecast = NWS::forTampa()->getForecast();

// Access forecast periods
foreach ($forecast->periods as $period) {
    echo $period->name;                    // "This Afternoon"
    echo $period->temperature;             // 89
    echo $period->shortForecast;           // "Partly Sunny"
    echo $period->detailedForecast;        // Full description
    echo $period->probabilityOfPrecipitation->value; // 20
}

// Helper methods
$todaysPeriods = $forecast->getTodaysPeriods();
$currentPeriod = $forecast->getCurrentPeriod();
```

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

[](#configuration)

The package includes comprehensive configuration options:

```
// config/nws.php
return [
    'base_url' => 'https://api.weather.gov',
    'user_agent' => 'Your App Name (contact@example.com)',
    'timeout' => 30,
    'cache' => [
        'enabled' => true,
        'ttl' => [
            'forecasts' => 1800,  // 30 minutes
            'alerts' => 300,      // 5 minutes
            'points' => 86400,    // 24 hours
        ],
    ],
    'default_location' => [
        'latitude' => 27.9506,   // Tampa
        'longitude' => -82.4572,
    ],
];
```

Caching
-------

[](#caching)

The package automatically caches API responses based on configuration:

- **Points/Offices**: 24 hours (rarely change)
- **Forecasts**: 30 minutes (updated regularly)
- **Observations**: 10 minutes (current conditions)
- **Alerts**: 5 minutes (time-sensitive)

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

[](#error-handling)

The package includes automatic retry logic for temporary failures:

```
try {
    $weather = NWS::forTampa()->getCurrentWeather();
} catch (\Exception $e) {
    // Handle API errors
    logger()->error('Weather API failed', ['error' => $e->getMessage()]);
}
```

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

[](#requirements)

- PHP 8.2+
- Laravel 10+
- Guzzle HTTP Client (via Laravel HTTP Client)

About the NWS API
-----------------

[](#about-the-nws-api)

The National Weather Service API is:

- **Free** - No API key required
- **Authoritative** - Direct from the source
- **Comprehensive** - Forecasts, observations, alerts
- **Reliable** - Government-maintained infrastructure

License
-------

[](#license)

MIT License. See LICENSE file for details.

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

[](#contributing)

Contributions welcome! Please see CONTRIBUTING.md for guidelines.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance62

Regular maintenance activity

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

233d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2169021b88d520bd58d9a37f51fa55058af7adbf7362c8cade65b261d644874c?d=identicon)[projectsaturnstudios](/maintainers/projectsaturnstudios)

---

Top Contributors

[![projectsaturnstudios](https://avatars.githubusercontent.com/u/10563160?v=4)](https://github.com/projectsaturnstudios "projectsaturnstudios (1 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/projectsaturnstudios-nws/health.svg)

```
[![Health](https://phpackages.com/badges/projectsaturnstudios-nws/health.svg)](https://phpackages.com/packages/projectsaturnstudios-nws)
```

###  Alternatives

[moe-mizrak/laravel-openrouter

Laravel package for OpenRouter (A unified interface for LLMs)

153107.2k2](/packages/moe-mizrak-laravel-openrouter)

PHPackages © 2026

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