PHPackages                             ocolin/netbox - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. ocolin/netbox

ActiveLibrary[HTTP &amp; Networking](/categories/http)

ocolin/netbox
=============

PHP REST client for Netbox

v3.0.0(1mo ago)120MITPHPPHP &gt;=8.3

Since Sep 25Pushed 1mo ago1 watchersCompare

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

READMEChangelogDependencies (9)Versions (13)Used By (0)

Netbox
======

[](#netbox)

What is it?
-----------

[](#what-is-it)

This is a small PHP client for the Netbox API REST services.

---

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

[](#requirements)

- PHP &gt;=8.3
- guzzlehttp/guzzle 7.10
- ocolin/global-type ^2.0

---

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

[](#installation)

```
composer require ocolin/netbox

```

---

TODO
----

[](#todo)

- Add an images upload function
- Integration testing for Netbox 3.

---

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

[](#configuration)

The client can be configured in two ways. Via environment variables, and constructor arguments.

### Properties

[](#properties)

Environment NameArgument NameTypeDefaultDescriptionNETBOX\_API\_HOST$hoststringN/AHostname of Netbox serverNETBOX\_API\_AUTH$authinteger2Authentication version 1 or 2NETBOX\_API\_TOKEN$tokenstringN/AAPI Auth tokenNETBOX\_API\_KEY$keystringN/AAPI Key for version 2 auth**Note**: Version 2 authentication takes both a key and a token, while Version 1 only uses a token.

### Environment Variables

[](#environment-variables)

```
// Manually creating for demonstration
$_ENV['NETBOX_API_HOST']  = 'http://localhost:8000';
$_ENV['NETBOX_API_AUTH']  = 2;
$_ENV['NETBOX_API_TOKEN'] = 'abcdefg';
$_ENV['NETBOX_API_KEY']   = 'abcdefg';

$netbox = new \Ocolin\Netbox\Netbox();
```

### Constructor arguments

[](#constructor-arguments)

The constructor takes a configuration object that allows you to add your configuration settings. These can also be used in conjunction with environment variables. Any missing parameters will be checked in the Environment.

```
$netbox = new Ocolin\Netbox\Netbox(
    config: new Ocolin\Netbox\Config(
           host: 'http://localhost:8000',
           auth: 2,
          token: 'abcdefg',
            key: 'abcdefg',
        options: [
            'verify' => true
        ]
    )
);
```

### Options

[](#options)

As can be seen in previous example, there is an options parameter. This allows you to specify Guzzle HTTP client settings if needed. This can be useful if you want to enable SSL verification, or HTTP timeout, etc. The client defaults to SSL verification off.

### HTTP defaults

[](#http-defaults)

OptionDefaultDescriptiontimeout20Seconds to give HTTP attemptverifyfalseVerify SSL credentials---

Response
--------

[](#response)

The client outputs a response object with the following parameters:

Property NameTypeDescriptionstatusintegerHTTP status codestatusMessagestringHTTP status messageheadersarrayList of response headersbodymixedHTTP response body content---

Method functions
----------------

[](#method-functions)

### Path interpolation

[](#path-interpolation)

Any {tokens} found in the endpoint path will be replaced with matching keys from the $query array. Those keys are then removed from the query string automatically.

**Note**: Netbox requires a trailing slash on all endpoint paths. The client adds one automatically if missing.

### GET

[](#get)

Get a resource

```
$output = $netbox->get(
    endpoint: '/api/dcim/sites/{id}/',
       query: [ 'id' => 123 ]
);
```

### POST

[](#post)

Create a new resource

```
$output = $netbox->post(
    endpoint: '/api/dcim/sites/',
    body: [
        'name' => 'My Site',
        'slug' => 'My-Site'
    ]
);
```

### PATCH

[](#patch)

Update a value in a resource

```
$output = $netbox->patch(
    endpoint: '/api/dcim/sites/{id}/',
       query: [ 'id' => 123 ],
        body: [ 'name' => 'My Updated Name' ]
);
```

### PUT

[](#put)

Update/Replace an entire resource

```
$output = $netbox->put(
    endpoint: '/api/dcim/sites/{id}/',
       query: [ 'id' => 123 ],
        body: $newBody
);
```

### DELETE

[](#delete)

Delete a resource

```
$output = $netbox->delete(
    endpoint: '/api/dcim/sites/{id}/',
       query: [ 'id' => 123 ]
);
```

### OPTIONS

[](#options-1)

OPTIONS returns information about an endpoint.

```
$output = $netbox->options( endpoint: '/api/dcim/sites/' );
```

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance90

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~55 days

Recently: every ~70 days

Total

11

Last Release

47d ago

Major Versions

1.4 → 2.02025-11-18

2.1 → v3.0.02026-04-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/e97ac0aa452b872ddc3f7f4c56c83852574a27bb74622f8c054d11ca20008fc9?d=identicon)[Ocolin](/maintainers/Ocolin)

---

Top Contributors

[![ocolin](https://avatars.githubusercontent.com/u/8870196?v=4)](https://github.com/ocolin "ocolin (2 commits)")

---

Tags

apiclientrestnetworkinfrastructurenetboxipamnetboxlabsdcim

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ocolin-netbox/health.svg)

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

###  Alternatives

[cybercog/youtrack-rest-php

YouTrack REST API PHP Client.

37149.2k3](/packages/cybercog-youtrack-rest-php)[rastor/jira-client

A simple PHP JIRA REST client

2070.7k](/packages/rastor-jira-client)[meteocontrol/vcom-api-client

HTTP Client for meteocontrol's VCOM API - The VCOM API enables you to directly access your data on the meteocontrol platform.

175.7k1](/packages/meteocontrol-vcom-api-client)[jonathanraftery/bullhorn-rest-client

Simple REST client for the Bullhorn API, including automated OAuth2 login

1142.7k](/packages/jonathanraftery-bullhorn-rest-client)[repat/plentymarkets-rest-client

REST Client for Plentymarkets

1510.0k](/packages/repat-plentymarkets-rest-client)[laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

161.8k](/packages/laragear-api-manager)

PHPackages © 2026

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