Several Questions / Issues - Getting reports with node.js

Hi!

I am using WPAPI ( Github > WP-AP > node-wpapi) to authenticate with node.js and then set up this route (> node-wpapi#custom-routes):

wp.matomoReport = wp.registerRoute( 'matomo/v1/api', '/processed_report', {
    params: [ 'apiModule', 'apiAction', 'period', 'date', 'segment' ]
} );

then fetch the report like this

 wp.matomoReport()
      .period('day').date('yesterday')
      .segment('visitDuration>5')
      .apiModule('Actions').apiAction('getPageUrls')
      .then(res => database.matomo.yesterday = res)
      .catch(err => console.log(err))

I experience several issues:

1. Error with visitDuration segment

.segment('visitDuration>5')

results in

“API returned an error: The segment condition ‘visitDuration&gt’ is not valid. at SegmentExpression.
php:116”

2. Empty reportData object

Removing the segment from the query above returns a report, but reportData: {} has no properties

3. Modules

Changing the request to

.apiModule('VisitsSummary').apiAction('getVisits')

results in

‘Requested report VisitsSummary.getVisits for Website id=1 not found in the list of available report
s.’

4. reportTotal vs. “Visit Overview” on Website differ

Why does the Website display 17 unique visitors, but the API states 3; or better: what is what?
So far I figured out that nb_visits is what the user interface in Wordpress calls unique pageviews

  reportTotal: {
    nb_visits: 31,
    nb_hits: 81,
    sum_time_spent: 852,
    sum_time_generation: 37.458,
    nb_hits_with_time_generation: 71,
    min_time_generation: 1.197,
    max_time_generation: 6.094999999999999,
    entry_nb_visits: 20,
    entry_nb_actions: 86,
    entry_sum_visit_length: 867,
    entry_bounce_count: 5,
    exit_nb_visits: 20,
    nb_uniq_visitors: 3,
    entry_nb_uniq_visitors: 2,
    exit_nb_uniq_visitors: 1
  }
Visits Overview
20 visits, 17 unique visitors
43s average visit duration
25% visits have bounced (left the website after one page)
4.3 actions (page views, downloads, outlinks and internal site searches) per visit
0.53s average generation time

81 pageviews, 31 unique pageviews
0 total searches on your website, 0 unique keywords
0 downloads, 0 unique downloads
5 outlinks, 5 unique outlinks
36 max actions in one visit

I would appreciate some pointers as to what is happening. Thanks a lot in advance!

PAV