Get stats from piwik database

Hi! I am including piwik statistics in my backoffice and i need to get information about the visits in each page.
I’m using the next code:

$fetched = file_get_contents($url);
$data = json_decode($fetched);
return $data->nb_pageviews;

I receive the correct information but i’m putting it in a table, so it needs many requests what slows my website.

Someone knows another way of get the information?
I tried read the schema of the datebase but it seems very difficult build the query’s for that…

Why do you need many requests, what exactly do you change in the request?

I’m setting the values in a table where each row has a column with the number of visits, etc…, e need a request for each value in that column