Question: How to use API to query reports from Analytics directly.
Solution: This can be achieved in three steps.
Step 1:
Authentication to Analytics REST API is a combination of a GET and a POST API:
curl -i -k -X GET 'https://localhost:8443/versa/analytics/auth/user' -H "Accept: application/json" -H "Content-Type: application/json" -c cookies.txt
curl -i -k -X POST 'https://localhost:8443/versa/login?username=admin&password=password' -H "Accept: application/json" -H "Content-Type: application/json" -c cookies.txt -b cookies.txt
Step 2:
The X-CSRF-TOKEN in the received in the headers of the POST API from step 2 and written into the cookies.txt. This token is needed in further API calls for the Authentication.
cat cookies.txt ............... Note down the token value
Sample output:
admin@HE2AN01:~$ cat cookies.txt
# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.
#HttpOnly_localhost FALSE / TRUE 0 JSESSIONID 343CA36A60C765958395E49D6CDD2357
localhost FALSE /versa TRUE 0 ANAL-CSRF-TOKEN dfe14d4c-c4f4-4e01-8884-e5089e263324
Step 3:
Supply the above token value and run the API for the required reports to be pulled.
Sample 1: To pull the appliance names for a specific tenant:
curl -b cookies.txt -kv 'https://localhost:8443/versa/analytics/v1.0.0/data/provider/tenants/Provider/appliances' -H "X-CSRF-TOKEN: dfe14d4c-c4f4-4e01-8884-e5089e263324"
admin@HE2AN01:~$ curl -b cookies.txt -kv 'https://localhost:8443/versa/analytics/v1.0.0/data/provider/tenants/Provider/appliances' -H "X-CSRF-TOKEN: dfe14d4c-c4f4-4e01-8884-e5089e263324"
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Unknown (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Client hello (1):
* TLSv1.3 (OUT), TLS Unknown, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=US; ST=California; O=versa-networks; OU=VersaAnalytics; CN=versa-analytics
* start date: Dec 26 17:32:46 2023 GMT
* expire date: Mar 30 17:32:46 2026 GMT
* issuer: CN=versa-analytics; O=versa-networks; OU=VersaAnalytics; C=US; ST=California; L=Santa Clara
* SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
> GET /versa/analytics/v1.0.0/data/provider/tenants/Provider/appliances HTTP/1.1
> Host: localhost:8443
> User-Agent: curl/7.58.0
> Accept: */*
> Cookie: ANAL-CSRF-TOKEN=dfe14d4c-c4f4-4e01-8884-e5089e263324; JSESSIONID=343CA36A60C765958395E49D6CDD2357
> X-CSRF-TOKEN: dfe14d4c-c4f4-4e01-8884-e5089e263324
>
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
< HTTP/1.1 200
< Cache-Control: no-store, no-cache, must-revalidate, max-age=0
< TraceId: 211b7e11-1127-432d-ab0d-54dec6247088
< X-CSRF-TOKEN: 1dbb1580-159a-4f59-a627-50467920278f
* cookie size: name/val 15 + 36 bytes
* cookie size: name/val 4 + 6 bytes
* cookie size: name/val 6 + 0 bytes
* cookie size: name/val 8 + 3 bytes
* Replaced cookie ANAL-CSRF-TOKEN="1dbb1580-159a-4f59-a627-50467920278f" for domain localhost, path /versa, expire 0
< Set-Cookie: ANAL-CSRF-TOKEN=1dbb1580-159a-4f59-a627-50467920278f; Path=/versa; Secure; SameSite=Lax
< Pragma: no-cache
< Cross-Origin-Opener-Policy: same-origin
< Cross-Origin-Resource-Policy: same-origin
< Strict-Transport-Security: max-age=31622400
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Content-Security-Policy: default-src 'self'; font-src 'self' data: https://fonts.googleapis.com/ https://fonts.gstatic.com; script-src 'self' https://maps.googleapis.com/ https://*.tile.openstreetmap.org/* https://code.highcharts.com/; img-src 'self' blob: data: https://maps.gstatic.com/ https://maps.googleapis.com/ https://*.tile.openstreetmap.org https://chart.apis.google.com/; style-src 'self' data: 'unsafe-inline' https://*.tile.openstreetmap.org https://fonts.googleapis.com/; form-action 'self' data: https://export.highcharts.com/; connect-src 'self' data: https://*.tile.openstreetmap.org/ https://ipapi.co https://maps.googleapis.com/; object-src 'none';
< Referrer-Policy: same-origin
< vary: accept-encoding
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Sat, 25 Oct 2025 06:51:24 GMT
< Server: Versa-Analytics-Server
<
[ {
"name" : "CPE01"
}, {
"name" : "CPE02"
}, {
"name" : "CPE04"
}, {
"name" : "CPE05"
}, {
"name" : "HubController01"
}, {
"name" : "RCPE01"
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
* Connection #0 to host localhost left intact
} ]admin@HE2AN01:~$
Sample 2: To pull link availability report for an appliance in Provider org for last day:
curl -b cookies.txt -kv 'https://localhost:8443/versa/analytics/v1.0.0/data/provider/tenants/Provider/features/SDWAN/?qt=rangeseries&&start-date=1daysAgo&end-date=today&q=linkstatus(site,accckt)&metrics=availability&ds=aggregate&fq=(siteName:%CPE01%22)&count=16' -H "X-CSRF-TOKEN: tokenvalue"
admin@HE2AN01:~$ curl -b cookies.txt -kv 'https://localhost:8443/versa/analytics/v1.0.0/data/provider/tenants/Provider/features/SDWAN/?qt=rangeseries&&start-date=1daysAgo&end-date=today&q=linkstatus(site,accckt)&metrics=availability&ds=aggregate&fq=(siteName:%CPE01%22)&count=16' -H "X-CSRF-TOKEN: dfe14d4c-c4f4-4e01-8884-e5089e263324"
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Unknown (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Client hello (1):
* TLSv1.3 (OUT), TLS Unknown, Certificate Status (22):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=US; ST=California; O=versa-networks; OU=VersaAnalytics; CN=versa-analytics
* start date: Dec 26 17:32:46 2023 GMT
* expire date: Mar 30 17:32:46 2026 GMT
* issuer: CN=versa-analytics; O=versa-networks; OU=VersaAnalytics; C=US; ST=California; L=Santa Clara
* SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway.
* TLSv1.3 (OUT), TLS Unknown, Unknown (23):
> GET /versa/analytics/v1.0.0/data/provider/tenants/Provider/features/SDWAN/?qt=rangeseries&&start-date=1daysAgo&end-date=today&q=linkstatus(site,accckt)&metrics=availability&ds=aggregate&fq=(siteName:%CPE01%22)&count=16 HTTP/1.1
> Host: localhost:8443
> User-Agent: curl/7.58.0
> Accept: */*
> Cookie: ANAL-CSRF-TOKEN=dfe14d4c-c4f4-4e01-8884-e5089e263324; JSESSIONID=343CA36A60C765958395E49D6CDD2357
> X-CSRF-TOKEN: dfe14d4c-c4f4-4e01-8884-e5089e263324
>
* TLSv1.3 (IN), TLS Unknown, Certificate Status (22):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
< HTTP/1.1 200
< Cache-Control: no-store, no-cache, must-revalidate, max-age=0
< TraceId: b3463b2e-1c00-41d5-971a-5bca1e6e7ec4
< X-CSRF-TOKEN: 1dbb1580-159a-4f59-a627-50467920278f
* cookie size: name/val 15 + 36 bytes
* cookie size: name/val 4 + 6 bytes
* cookie size: name/val 6 + 0 bytes
* cookie size: name/val 8 + 3 bytes
* Replaced cookie ANAL-CSRF-TOKEN="1dbb1580-159a-4f59-a627-50467920278f" for domain localhost, path /versa, expire 0
< Set-Cookie: ANAL-CSRF-TOKEN=1dbb1580-159a-4f59-a627-50467920278f; Path=/versa; Secure; SameSite=Lax
< Pragma: no-cache
< Cross-Origin-Opener-Policy: same-origin
< Cross-Origin-Resource-Policy: same-origin
< Strict-Transport-Security: max-age=31622400
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Content-Security-Policy: default-src 'self'; font-src 'self' data: https://fonts.googleapis.com/ https://fonts.gstatic.com; script-src 'self' https://maps.googleapis.com/ https://*.tile.openstreetmap.org/* https://code.highcharts.com/; img-src 'self' blob: data: https://maps.gstatic.com/ https://maps.googleapis.com/ https://*.tile.openstreetmap.org https://chart.apis.google.com/; style-src 'self' data: 'unsafe-inline' https://*.tile.openstreetmap.org https://fonts.googleapis.com/; form-action 'self' data: https://export.highcharts.com/; connect-src 'self' data: https://*.tile.openstreetmap.org/ https://ipapi.co https://maps.googleapis.com/; object-src 'none';
< Referrer-Policy: same-origin
< vary: accept-encoding
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Sat, 25 Oct 2025 06:48:40 GMT
< Server: Versa-Analytics-Server
<
{
"qTime" : 51,
"data" : [ {
"name" : "Down",
"type" : "data",
"metric" : "availability",
"data" : [ [ 2, 1761346500000, 1761347400000 ], [ 3, 1761346200000, 1761347400000 ], [ 4, 1761264000000, 1761374700000 ], [ 5, 1761264000000, 1761374700000 ], [ 6, 1761264000000, 1761374700000 ], [ 7, 1761264000000, 1761374700000 ], [ 8, 1761264000000, 1761374700000 ], [ 9, 1761264000000, 1761374700000 ] ]
}, {
"name" : "Degraded",
"type" : "data",
"metric" : "availability",
"data" : [ ]
}, {
"name" : "Up",
"type" : "data",
"metric" : "availability",
"data" : [ [ 0, 1761264000000, 1761374700000 ], [ 1, 1761264000000, 1761374400000 ], [ 2, 1761264000000, 1761346500000 ], [ 2, 1761347400000, 1761374700000 ], [ 3, 1761264000000, 1761346200000 ], [ 3, 1761347400000, 1761374700000 ] ]
}, {
"name" : "Indeterminable",
"type" : "data",
"metric" : "availability",
"data" : [ [ 1, 1761374400000, 1761374700000 ] ]
} ],
"metadata" : {
"categories" : [ "HubController01,Internet (100.00 %)", "CPE01,Internet (100.00 %)", "CPE02,Internet (99.19 %)", "CPE04,Internet (98.92 %)", "CPE05,Internet2 (0.00 %)", "CPE01,MPLS (0.00 %)", "CPE05,Internet (0.00 %)", "RCPE01,MPLS (0.00 %)", "RCPE01,Internet (0.00 %)", "CPE04,MPLS (0.00 %)" ],
"type" : "range"
},
"totalCount" : 10
* TLSv1.3 (IN), TLS Unknown, Unknown (23):
* Connection #0 to host localhost left intact
}admin@HE2AN01:~$
Note: The localhost is used since these commands are run from Analytics node itself. If the reports need to be pulled from any other Linux machine then supply the IP or hostname of the analytics where the data needs to be queried.
Guide to available APIs:
Versa Analytics REST API calls are documented in the Versa Analytics API Reference guide, which you can access from the Versa Analytics application or the Analytics tab in the Director GUI.
Path: Administration > Tools > Documentation in the left menu bar, and then click the API Documentation field.