Application Programming Interface

Command line, RESTful and JavaScript APIs that integrate NETS into systems.

NETS has two kinds of API - application APIs and library APIs. Application APIs help to run NETS on the command line, as a web service or from JavaScript. Library APIs allow compiled grammars to be built using a set of C library functions. This section deals with application APIs.

Command Line Interface

The NETS Command Line Interface (CLI) allows the parser to be executed from an operating system terminal. It can be executed independently or as part of a script or batch process. The nets-parser command is followed by a number of command line parameters as follows. These parameters are by convention used in the RESTful API and the JavaScript API.

The command line is called either as a native executable (MacOS/Linux/Windows, NodeJS WASM executable or a Wasmtime WASI executable.

Name Command
Native Executable

NETS is started from the command line by invoking the nets-parser executable.

> nets-parser-${platform}-${architecture}-v${version}[d] [arguments]

  • Platform may be either win, macos, linux, wasm-wasi, wasm-node or wasm-web
  • Architecture may be either x86-64 or 32
  • Version is expressed as major dot minor and an optional build number ie. v1.0.0001
  • Debug executables are indicated with a d suffix ie. v1.0.0001d

For example nets-parser-macos-x86-64-v1.0d is the executable file name on MacOS for the x86 64 bit architrecture, in debug mode. nets-parser-wasm-wasi-32-v1.0 is the executable file name for Wasmtime in production mode.

NodeJS Executable

NETS requires node to run the wasm-node executable. A helper JavaScript program nets-parser is used for node. (Update the paths in nets-parser.js when using the wasm-node-32 build).

> node nets-parser.js -- [arguments]

NETS Command line arguments are added after the double dash --.

Wasmtime Executable

NETS requires wasmtime to run the wasm-wasi executable. NETS requires wasmtime permission to directories for working files, temporary files and the wasm executable. NETS Command line arguments are added after the double dash --.

> wasmttime nets-parser-wasi.wasm --dir=. --dir=/tmp --dir=${path to nets-parser-debug.wasm} -- [arguments]

Command line arguments are specified using either the - or / character followed by the name of the parameter and followed optionally by an equal sign and the value of the paramater.

Name Description
input Defines the input file for the parser. Defaults to
output Defines the output file for the parser. Defaults to default.out.
error Defines the log file for the parser. Defaults to default.log.
loglevel Sets the initial loglevel for the parser.
grammar Defines the grammars for the parser. Defaults to default.g. May include multiple files separated by either '#' or ';'.
grammar_xml Defines the grammar XML output file for the parser. Defaults to default.g.xml.
nologo Ommits the copyright and version information from being displayed.
encoding The input and output stream encoding in the form encoding="SOURCE/TARGET". The default encoding is "ASCII/ASCII".
grammar_encoding The grammar encoding in the form encoding="SOURCE/TARGET". The default grammar encoding is "ASCII/ASCII".
loadenv Load the system environment variables as context grammar entities.
grammar_libpath Load path for compiled grammar libraries and the 'command.g' grammar. (Not used in cloud environments for security reasons).
init Initialise the parser only and do not start. Can be used to check for configuration errors.
help Displays help information about command line parameters.
jobid The 'jobid' command line parameter adds jobid (instead of the thread id) to each line in the error stream.
xxxxxx Any unkown parameter is interpretted as a context grammar entity.

RESTful Interface

The NETS RESTful Interface allows the parser to be executed over an HTTP(S) protocol. The endpoint is and responds to a POST with multi-part form data containing the input and the grammar. A form which uses the endpoint is available at

An example using the cURL utility is shown below.

> curl --location --request POST \
'' \
--form 'output="default.out"' \
--form 'grammar=@"default.g"' \
--form 'input=@""' \
--form 'loglevel="4"' \
--form 'error="default.log"'

The curl command returns the output to the terminal. Any valid commandline argument can be used as part of the POST. In addition the result_file argument can be used to return any file generated during processing. For example result_file=default.log returns the log file. The /process POST endpoint is synchronous with results returned as soon as processing is finished.

/process POST returns the following HTTP message response codes.

Code Description
200 Successful completion of the operation.

JavaScript Interface

The NETS JavaScript Interface allows the parser to be executed from JavaScript code either using Node or a web browser. A Node example is shown below which requires the installation of the nets-parser npm module.

const Nets = require('nets-parser.js');

var args = {

Nets().then(function(app) {
var parser=0;

An example Node project using NETS is available on Runkit.