ocolin/netbox

REST client for Netbox

Maintainers

Details

github.com/ocolin/Netbox

Source

Issues

Installs: 18

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/ocolin/netbox

2.1 2025-11-18 21:52 UTC

This package is auto-updated.

Last update: 2025-11-18 21:52:52 UTC


README

Description

This is a basic REST client for the Netbox API.

Usage

Environment variables

You can specify parameters in the constructor, but if any are left out, these environment variables will be used instead.

NETBOX_API_TOKEN - Authentication token for API

NETBOX_API_HOST - URL of server API

Instantiate

Create an instance of the Netbox object.

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

Parameters

$host: Name of the Netbox host server. If null, will use Env parameter

$token: Authentication token for server. If null, will use Env parameter.

$timeout: HTTP Timeout. Defaults to 20 seconds.

$verify: Verify SSL certificate. Defaults to off.

Making a call

This method will return just the HTTP body from the server.

$output = $netbox->call( 
    path: '/dcim/devices/{id}',
    query: [
        'id' => 'f700f200-f27f-442b-b086-c6ea128953b7',
    ] 
);

Parameters

$path: REQUIRED - API endpoint path, including named parameters.

$query: Array/Object of parameters name/values to use for URI path or URI query.

$body: Array/Object for POST/PUT/PATCH HTTP body.

$method: HTTP method. Defaults to GET.

Making a full call.

Same parametes as the call() function, but different output. This will return an object 4 properties:

  • $status: HTTP status code
  • $statusMessage: HTTP status message
  • $headers: HTTP response headers
  • $body: HTTP response body
$output = $netbox->full( 
    path: '/dcim/devices/{id}',
    method: 'DELETE',
    query: [
        'id' => 'f700f200-f27f-442b-b086-c6ea128953b7',
    ] 
);