PHPackages                             devshaded/nvdb-speed-limits - 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. devshaded/nvdb-speed-limits

ActiveLibrary[API Development](/categories/api)

devshaded/nvdb-speed-limits
===========================

Fetch Norwegian speed limits from NVDB API

v1.0.1(1y ago)010[4 PRs](https://github.com/DevShaded/nvdb-speed-limits/pulls)MITPHPPHP ^8.3CI passing

Since Jul 1Pushed 2mo agoCompare

[ Source](https://github.com/DevShaded/nvdb-speed-limits)[ Packagist](https://packagist.org/packages/devshaded/nvdb-speed-limits)[ Docs](https://github.com/devshaded/nvdb-speed-limits)[ GitHub Sponsors](https://github.com/DevShaded)[ RSS](/packages/devshaded-nvdb-speed-limits/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (12)Versions (8)Used By (0)

NVDB Speed Limits for Laravel
=============================

[](#nvdb-speed-limits-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3dd1e6771f999ec5573bcc4da8f86e8a40e8dfbe3c5ead93248a2d7a0616667e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465767368616465642f6e7664622d73706565642d6c696d6974732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/devshaded/nvdb-speed-limits)[![GitHub Tests Action Status](https://camo.githubusercontent.com/b06c9f65f2918c98d2f75c819f8964d43577aeb76e99b7725ff55157b1510dd6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465767368616465642f6e7664622d73706565642d6c696d6974732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/devshaded/nvdb-speed-limits/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/c0bd97c1c540d270deabd430a66f5805081c5e7f6eab76a159de2681a1f1c371/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465767368616465642f6e7664622d73706565642d6c696d6974732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/devshaded/nvdb-speed-limits/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/82a57f743e48916cf975e734b09a43f1f94527a232d2138115405cde91e613b6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465767368616465642f6e7664622d73706565642d6c696d6974732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/devshaded/nvdb-speed-limits)

A Laravel package for fetching speed limits from the Norwegian NVDB API.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Get Speed Limit for a Coordinate](#get-speed-limit-for-a-coordinate)
    - [Get Speed Limit with Expanded Search](#get-speed-limit-with-expanded-search)
    - [Get Speed Limits for Multiple Coordinates](#get-speed-limits-for-multiple-coordinates)
- [Error Handling](#error-handling)
- [Testing](#testing)
- [Contributing](#contributing)
- [Changelog](#changelog)
- [Credits](#credits)
- [License](#license)

---

Features
--------

[](#features)

- Fetches speed limits from the Norwegian NVDB API for given coordinates
- Supports searching with an expanding radius if no speed limit is found initially
- Batch lookup for multiple coordinates
- Configurable API endpoint, search radius, and coordinate bounds
- Designed for Laravel, but can be used in any PHP project

---

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

[](#installation)

Install the package via Composer:

```
composer require devshaded/nvdb-speed-limits
```

Publish the config file (optional):

```
php artisan vendor:publish --tag="nvdb-speed-limits-config"
```

---

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

[](#configuration)

The configuration file allows you to customize API settings, search parameters, and coordinate bounds. Example:

```
return [
    'api' => [
        'base_url' => 'https://nvdbapiles-v3.atlas.vegvesen.no',
        'timeout' => 30,
        'headers' => [
            'accept' => 'application/vnd.vegvesen.nvdb-v3-rev1+json',
            'X-Client' => 'LaravelNvdbSpeedLimits/1.0',
        ],
    ],
    'search' => [
        'default_radius' => 0.0001, // ~11 meters
        'max_radius' => 0.005,      // ~550 meters
        'radius_multiplier' => 3,   // For expanding search
    ],
    'bounds' => [
        'latitude' => [57, 72],
        'longitude' => [4, 32],
    ],
];
```

---

Usage
-----

[](#usage)

Import the facade or use the class directly:

```
use DevShaded\NvdbSpeedLimits\Facades\NvdbSpeedLimits;
// or
use DevShaded\NvdbSpeedLimits\NvdbSpeedLimits;
```

### Get Speed Limit for a Coordinate

[](#get-speed-limit-for-a-coordinate)

```
$result = NvdbSpeedLimits::getSpeedLimit(59.9139, 10.7522);

if ($result->found) {
    echo "Speed limit: " . $result->recommended['speed'] . " km/h";
} else {
    echo "No speed limit found.";
}
```

#### Optional: Specify a Search Radius

[](#optional-specify-a-search-radius)

```
$result = NvdbSpeedLimits::getSpeedLimit(59.9139, 10.7522, 100); // 100 meters
```

### Get Speed Limit with Expanded Search

[](#get-speed-limit-with-expanded-search)

This method will automatically expand the search radius until a speed limit is found or the maximum radius is reached.

```
$result = NvdbSpeedLimits::getSpeedLimitWithExpandedSearch(59.9139, 10.7522);

if ($result->found) {
    echo "Speed limit: " . $result->recommended['speed'] . " km/h";
}
```

### Get Speed Limits for Multiple Coordinates

[](#get-speed-limits-for-multiple-coordinates)

You can pass an array of coordinates (with `lat`/`lng` or `latitude`/`longitude` keys):

```
$coordinates = [
    ['lat' => 59.9139, 'lng' => 10.7522],
    ['latitude' => 60.3913, 'longitude' => 5.3221],
    ['lat' => 61.1234, 'lng' => 11.5678],
];

$results = NvdbSpeedLimits::getSpeedLimitsForCoordinates($coordinates);

foreach ($results as $item) {
    if ($item['error']) {
        echo "Error for coordinate (" . json_encode($item['coordinate']) . "): " . $item['error'] . "\n";
    } else {
        echo "Speed limit at (" . $item['coordinate']['lat'] . ", " . $item['coordinate']['lng'] . "): " . $item['result']->recommended['speed'] . " km/h\n";
    }
}
```

---

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

[](#error-handling)

- If invalid coordinates are provided, an `InvalidCoordinatesException` will be thrown.
- For batch lookups, errors are included in the result array for each coordinate.
- Always check the `found` property on the result object to determine if a speed limit was found.

---

Testing
-------

[](#testing)

Run the tests with:

```
composer test
```

---

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

[](#contributing)

Contributions are welcome! Please open issues or submit pull requests for improvements or bug fixes.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/my-feature`)
3. Commit your changes (`git commit -am 'Add new feature'`)
4. Push to the branch (`git push origin feature/my-feature`)
5. Create a new Pull Request

---

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

---

Credits
-------

[](#credits)

- [DevShaded](https://github.com/DevShaded)

---

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance70

Regular maintenance activity

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.5% 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 ~0 days

Total

2

Last Release

367d ago

PHP version history (2 changes)v1PHP ^8.4

v1.0.1PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/49687450?v=4)[Fredrik](/maintainers/DevShaded)[@DevShaded](https://github.com/DevShaded)

---

Top Contributors

[![DevShaded](https://avatars.githubusercontent.com/u/49687450?v=4)](https://github.com/DevShaded "DevShaded (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

laravelDevShadednvdb-speed-limits

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/devshaded-nvdb-speed-limits/health.svg)

```
[![Health](https://phpackages.com/badges/devshaded-nvdb-speed-limits/health.svg)](https://phpackages.com/packages/devshaded-nvdb-speed-limits)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.6k3](/packages/defstudio-telegraph)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[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)[lettermint/lettermint-laravel

Official Lettermint driver for Laravel

1190.2k1](/packages/lettermint-lettermint-laravel)

PHPackages © 2026

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