REST API

Live Documentation

https://raw.githubusercontent.com/openwisp/openwisp-ipam/docs/docs/api-docs.png

A general live API documentation (following the OpenAPI specification) is available at /api/v1/docs/.

Browsable Web Interface

https://raw.githubusercontent.com/openwisp/openwisp-ipam/docs/docs/api-ui.png

Additionally, opening any of the endpoints List of Endpoints directly in the browser will show the browsable API interface of Django-REST-Framework, which makes it even easier to find out the details of each endpoint.

Authentication

See openwisp-users: Authenticating with the User Token.

When browsing the API via the Live Documentation or the Browsable Web Interface, you can also use the session authentication by logging in the django admin.

API Throttling

To override the default API throttling settings, add the following to your settings.py file:

REST_FRAMEWORK = {
    "DEFAULT_THROTTLE_RATES": {
        "ipam": "100/hour",
    }
}

The rate descriptions used in DEFAULT_THROTTLE_RATES may include second, minute, hour or day as the throttle period.

Pagination

All list endpoints support the page_size parameter that allows paginating the results in conjunction with the page parameter.

GET /api/v1/<api endpoint url>/?page_size=10
GET /api/v1/<api endpoint url>/?page_size=10&page=2

List of Endpoints

Since the detailed explanation is contained in the Live Documentation and in the Browsable Web Interface of each endpoint, here we'll provide just a list of the available endpoints, for further information please open the URL of the endpoint in your browser.

Get Next Available IP

Fetch the next available IP address under a specific subnet.

GET

Returns the next available IP address under a subnet.

/api/v1/ipam/subnet/<subnet_id>/get-next-available-ip/

Request IP

A model method to create and fetch the next available IP address record under a subnet.

POST

Creates a record for next available IP address and returns JSON data of that record.

POST /api/v1/ipam/subnet/<subnet_id>/request-ip/

Param

Description

description

Optional description for the IP address

Response

{
    "ip_address": "ip_address",
    "subnet": "subnet_uuid",
    "description": "optional description"
}

Subnet IP Address List/Create

An api endpoint to retrieve or create IP addresses under a specific subnet.

GET

Returns the list of IP addresses under a particular subnet.

/api/v1/ipam/subnet/<subnet_id>/ip-address/

POST

Create a new IP Address.

/api/v1/ipam/subnet/<subnet_id>/ip-address/

Param

Description

ip_address

IPv6/IPv4 address value

subnet

Subnet UUID

description

Optional description for the IP address

Subnet List/Create

An api endpoint to create or retrieve the list of subnet instances.

GET

Returns the list of Subnet instances.

/api/v1/ipam/subnet/

POST

Create a new Subnet.

/api/v1/ipam/subnet/

Param

Description

subnet

Subnet value in CIDR format

master_subnet

Master Subnet UUID

description

Optional description for the IP address

Subnet Detail

An api endpoint for retrieving, updating or deleting a subnet instance.

GET

Get details of a Subnet instance

/api/v1/ipam/subnet/<subnet-id>/

DELETE

Delete a Subnet instance

/api/v1/ipam/subnet/<subnet-id>/

PUT

Update details of a Subnet instance.

/api/v1/ipam/subnet/<subnet-id>/

Param

Description

subnet

Subnet value in CIDR format

master_subnet

Master Subnet UUID

description

Optional description for the IP address

IP Address Detail

An api endpoint for retrieving, updating or deleting a IP address instance.

GET

Get details of an IP address instance.

/api/v1/ipam/ip-address/<ip_address-id>/

DELETE

Delete an IP address instance.

/api/v1/ipam/ip-address/<ip_address-id>/

PUT

Update details of an IP address instance.

/api/v1/ipam/ip-address/<ip_address-id>/

Param

Description

ip_address

IPv6/IPv4 value

subnet

Subnet UUID

description

Optional description for the IP address

Export Subnet

View to export subnet data.

POST

/api/v1/ipam/subnet/<subnet-id>/export/

Import Subnet

View to import subnet data.

POST

/api/v1/ipam/import-subnet/