Using the NiFi API

Russell Bateman
10 April 2023
last update:

NiFi API services layout (entry point URIs)

API Module URI path Description
Access /access authenticate user and get access token from NiFi
Controller /controller manage the cluster and create reporting task
Controller Services /controller-services manage controller services and update controller service references
Reporting Tasks /reporting-tasks manage reporting tasks
Flow /flow get the data flow metadata and component status and query history
Process Groups /process-groups upload and instantiate a template and create components
Processors /processors create and schedule a processor and set its properties
Connections /connections create a connection, set queue priority and update connection destination
FlowFile Queues /flowfile-queues view queue contents, download flowfile content, and empty queue
Remote Process Groups /remote-process-groups create a remote group and enable transmission
Provenance /provenance query provenance, and search event lineage

For example, getting information about the flow...

(The return is wrapped for readability.)

$ GET http://localhost:9113/nifi-api/flow/about

{"about":{"title":"NiFi","version":"1.13.2","uri":"http://localhost:9113/nifi-api/","contentViewerUrl":"../nifi-content-viewer/","timezone":"MDT","buildTag":"nifi-1.13.2-RC1","buildRevision":"174938e","buildBranch":"UNKNOWN","buildTimestamp":"03/17/2021 20:45:53 MDT"}}

...or:

{
  "about":
  {
    "title":            "NiFi",
    "version":          "1.13.2",
    "uri":              "http://localhost:9113/nifi-api/",
    "contentViewerUrl": "../nifi-content-viewer/",
    "timezone":         "MDT",
    "buildTag":         "nifi-1.13.2-RC1",
    "buildRevision":    "174938e",
    "buildBranch":      "UNKNOWN",
    "buildTimestamp":   "03/17/2021 20:45:53 MDT"
  }
}

Steps to using the NiFi API to interact with templates...

Creating NiFi Template via Rest API.

  1. Fetch access token...
    $ curl --request POST \
           --header "Accept: */*" \
           --header "Accept-Encoding: gzip" \
           --header "Accept-Language: en-US,en;q=0.5" \
           --header "Connection: keep-alive" \
           --header "Content-Length: 38" \
           --header "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" \
           --header "Host: http://localhost:9113" \
           --header "Referer: http://localhost:9113/nifi/login" \
           --header "X-Requested-With: XMLHttpRequest" \
           --data   'username=myUserName&password=YourPasswordHere' \
           http://localhost:9113/nifi-api/access/token \
      | gunzip
    
    
    
    curl --request POST --header "Accept: */*" --header "Accept-Encoding: gzip" --header "Accept-Language: en-US,en;q=0.5" --header "Connection: keep-alive" --header "Content-Length: 38" --header "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" --header "Host: http://localhost:9113" --header "Referer: http://localhost:9113/nifi/login" --header "X-Requested-With: XMLHttpRequest" http://localhost:9113/nifi-api/access/token
    
    
  2. Fetch the UUID of the process group that interests you.