Get in/out interface usage trough API

I’m trying to get some information that have on graphs.

On API ports call, I can see some information, but the data not matching.

Eg.
Int Traffic
image
On API:
“ifInOctets”: “1048465654806”,
“ifOutOctets”: “201779246221”,

Int Packets
image
On API:
“ifInUcastPkts”: “2181669256”,
“ifOutUcastPkts”: “761506912”,

Those are raw packet information, you want to use something like ifInOctets_rate / port speed * 100 I think.