Skip to main content

Django module which provides a GraphQL API for Netbox (For django 1.11)

Project description


Netbox-Graphql is a simple Django app which provides a GraphQL API for Netbox.
This module is dockerized and **development of it is still in progress**. Netbox's circuit module with all it's models are covered.
For this part of app you can CRUD operations.

Available Models for CRUD
* Provider
* Circuit
* CircuitType
* CircuitTermination
* Region
* Site
* TenantGroup
* Tenant
* Role
* VlanGroup
* Aggregate
* Prefix
* ClusterType
* ClusterGroup
* Cluster
* VirtualMachine

Build package (optional)

| git clone
| cd django-netbox-graphql
| python sdist

This module relies on modules
| graphene-django>=1.0
| django-filter>=1.0.2

Quick start

1. Install module::

pip install django-netbox-graphql #from external storage, not yet deployed
pip install dist/django-netbox-graphql-0.0.x.tar.gz

2. Add below modules to your INSTALLED_APPS setting like this::


3. Add graphene settings to netbox/

GRAPHIQL_ENABLED = True # optional, by default True, set False to disable it
'SCHEMA' : 'netbox_graphql.schema.schema', #points to the netbox-graphql schema variable in
'SCHEMA_INDENT': 2, #defines the indentation space in the output

4. Include the polls URLconf in your project netbox/ like this::

url(r'^graphql', include('netbox_graphql.urls')),

5. Visit to fetch records with graphql::

curl -H 'Content-Type: application/json'\
-H "Authorization: Token <netbox_token>"\
-XPOST -d '{"query":"{ circuitTypes { edges { node { id name slug } } } }"}' http://localhost:8000/graphql

Visit http://localhost:8000/user/api-tokens/ to generate token

Graphql CRUD examples


curl -H 'Content-Type: application/json'\
-H "Authorization: Token <netbox_token>"\
-XPOST -d '{"query":"mutation { newCircuitType(input: {name: \"Type1\", slug: \"type1\"}) { circuitType { id name slug } } }"}' http://localhost:8000/graphql


curl -H 'Content-Type: application/json'\
-H "Authorization: Token <netbox_token>"\
-XPOST -d '{"query":"{ circuitTypes(id: \"<circuit-type-id>\") { edges { node { id name slug } } } }"}' http://localhost:8000/graphql


curl -H 'Content-Type: application/json'\
-H "Authorization: Token <netbox_token>"\
-XPOST -d '{"query":"mutation { updateCircuitType(input: {id:\"<circuit-type-id>\", name: \"TypeX\", slug: \"typeX\"}) { circuitType { slug name slug } } }"}' http://localhost:8000/graphql



curl -H 'Content-Type: application/json'\
-H "Authorization: Token <netbox_token>"\
-XPOST -d '{"query":"mutation { deleteCircuitType(input: {id:\"<circuit-type-id>\"}) { circuitType { name slug } } }"}' http://localhost:8000/graphql


Graphql editor for writing queries

1. You should have installed `graphene_django`::


2. Create url for graphql client with adding new link in `` ::

url(r'^graphql/client', GraphQLView.as_view(graphiql=True)),

3. Visit ::

.. image::

Examples for module Circuit

All examples are available `here <>`_

Packaging and deploying to
The simplest way to make package and deploy it is with using `twine`::

pip install twine # install twine
python sdist # build django-netbox-graphql-X.X.X.tar.gz
twine upload dist/django-netbox-graphql-X.X.X.tar.gz

Run unit tests::

docker-compose run netbox ./ test # runs all tests
docker-compose run netbox ./ test netbox_graphql/ # runs only netbox_graphql module tests

# At the end, you can stop any running service and cleanup as follows:
docker-compose down

PYPI Distribution

Can be found at

This module is currently maintained and funded by `nine <>`_

.. image::

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-netbox-graphql-0.0.4.tar.gz (22.7 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page