Skip to main content

Rest API to convert openwrt config to json and vice versa using flask

Project description


A simple flask rest API's to convert from json config to openwrt and vice versa

The code is Python 2, but Python 3 compatible.



pip install netjson-rest

For a manual installation

   mkdir netjson-rest
   cd netjson-rest
   python install
   cd netjsonFlaskRest


Invoke this API to convert from json to openwrt by http://IP:6000/api/v1/netjson-config/jsontoopenwrt/

data = {
    "hostname" :  "spanidea",
    "timezone" :  "IST",
    "radios" : [{
    "name" : "Spanidea",
    "protocol" : "802.11ac" ,
    "channel" : 36,
    "channel_width" : 20,
    "tx_power " : 10,
    "country" : "IN"

"wireless": [
            "name": "lo",
            "type": "wireless",
            "addresses": [
                    "address": "",
                    "mask": 8,
                    "proto": "static",
                    "family": "ipv4"

request above endpoint from python

x = =data, url = 'http://<IP>:6000/api/v1/netjson-config/jsontoopenwrt/')

##Call this to convert from openwrt to json : http://:6000/api/v1/netjson-config/openwrttojson/

Example to request from python

multipart_form_data = {
    'file2': ('', open('', 'rb')),
    'action': (None, 'store'),
    'path': (None, '/path1')

x = = multipart_form_data , url = 'http://<IP>:6000/api/v1/netjson-config/openwrttojson/', files=multipart_form_data )

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

netjson-rest-1.0.5.tar.gz (3.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page