The record count you see in the org setup under "Storage Usage" is an estimate. Same for the Record Count platform API.
To get an actual count of records from Salesforce you need to issue a
COUNT SOQL query, though note it may timeout when there are a lot of records. In this case you may want to issue multiple queries counting records in different time ranges, or use the Data Loader to export records IDs and count them from a file instead.
Updated 4 days ago