Configuration

Configuring the SDK can be done programmatically and/or via loading (and saving) simple JSON text configuration files. At a minimum, the NS1 API key to access the REST API must be specified.

Loading From a File

By default, configuration is loaded from the file ~/.nsone; that is, a file called .nsone in the home directory of the user calling the script.

# to load an explicit configuration file:
api = NS1(configFile='/etc/ns1/api.json')

From an API Key

# to generate a configuration based on an api key
api = NS1(apiKey='<<CLEARTEXT API KEY>>')

JSON File Format

This example shows two different API keys. Which to use can be selected at runtime, see ns1.config

{
   "default_key": "account2",
   "verbosity": 5,
   "keys": {
        "account1": {
            "key": "<<CLEARTEXT API KEY>>",
            "desc": "account number 1",
            "writeLock": true
        },
        "account2": {
            "key": "<<ANOTHER CLEARTEXT API KEY>>",
            "desc": "account number 2",
            "writeLock": false
        },
   },
   "cli": {
       "output_format": "text"
   }
}

More

There are more examples in the config.py example. For the full Config object reference API, see ns1.config