[Billing] Understand Transaction Calculation for Matrix Routing
If you want to understand how the transactions are calculated for Matrix Routing, this article is for you.
Pricing Documentation
Referring to https://www.here.com/get-started/pricing > HERE Matrix Routing > Pricing Details for the transaction calculation method of the Matrix Routing API:
1 Transaction means if Starting Points or number of Destination Points is less than 5, the number of Transactions is calculated by multiplying the number of Starting Points by the number of Destination Points. If the number of Starting Points and number of Destination Points are 5 or greater, the number of Transactions is calculated by multiplying 5 with the greater of (i) the number of Starting Points or (ii) the number of Destination Points.
So the Matrix Routing pricing model has the following two scenarios:
1. If the Starting Points (S) or number of Destination Points (D) is less than 5, the number of Transactions is calculated by multiplying the number of Starting Points by the number of Destination Points. > If S or D is less than 5, the transaction is S x D.
2. If the number of Starting Points and number of Destination Points are 5 or greater, the number of Transactions is calculated by multiplying 5 with the greater of (i) the number of Starting Points or (ii) the number of Destination Points. > If S and D are both equal or greater than 5, transactions is the greater one of S or D x 5
Testing Cases
For better understanding the above pricing model upon the two scenarios, here are some examples with different numbers of origins and destinations.
Case 1 - 4 Starting Points and 4 Destination Points
This fits the scenario 1 - when one of the S or D is less than 5 (Actually, both are less than 5)
The transaction is calculated as: S x D = 4 x 4 = 16
Request:
Using the following API request including a billing tag "o4d4" with payload JSON as follows:
https://matrix.router.hereapi.com/v8/matrix?async=false&billingTag=o4d4<br />{ "origins": [ { "lat": 52.54, "lng": 13.40 }, { "lat": 50.43, "lng": 30.52 }, { "lat": 51.50, "lng": -0.08 }, { "lat": 40.40, "lng": -3.68 } ], "destinations": [ { "lat": 52.54, "lng": 13.40 }, { "lat": 50.43, "lng": 30.52 }, { "lat": 51.50, "lng": -0.08 }, { "lat": 40.40, "lng": -3.68 } ], "profile": "carFast", "regionDefinition": { "type": "world" }, "matrixAttributes": ["distances"]}<br />
Response:<br />{ "matrixId": "d2ba62c7-d0fe-465e-a511-89b2129feb6a", "matrix": { "numOrigins": 4, "numDestinations": 4, "distances": [ 0, 1378337, 1095170, 2322681, 1376876, 0, 2413914, 3641425, 1098371, 2418169, 0, 1719413, 2321546, 3641344, 1713920, 0 ] }, "regionDefinition": { "type": "world" }}`<br />
You can check the transactions generated from the above request on your Usage dashboard by filtering the billing tag "o4d4".
This may takes 48 hours to be visible because "Usage can take up to 2 days to appear" as stated on the Usage dashboard.
Another way to check the transactions generated from the above request is with the Cost Management Usage API.
In this way, you only need to wait for tens of minutes or half an hour to get the result:
Note that, the transactions for the above API query with billing tag "o4d4" is exactly 16.
Case 2 - 7 Starting Points and 4 Destination Points
This fits the scenario 1 - when one of the S or D is less than 5 (The number of Destination Points is less than 5)
The transaction is calculated as: S x D = 7 x 4 = 28
Request:
Using the following API request including a billing tag "o7d4" with payload JSON as follows:
https://matrix.router.hereapi.com/v8/matrix?async=false&billingTag=o7d4<br />{ "origins": [ { "lat": 52.54, "lng": 13.40 }, { "lat": 50.43, "lng": 30.52 }, { "lat": 51.50, "lng": -0.08 }, { "lat": 40.40, "lng": -3.68 }, { "lat": 55.75, "lng": 37.60 }, { "lat": 48.87, "lng": 2.33 }, { "lat": 41.90, "lng": 12.48 } ], "destinations": [ { "lat": 52.54, "lng": 13.40 }, { "lat": 50.43, "lng": 30.52 }, { "lat": 51.50, "lng": -0.08 }, { "lat": 40.40, "lng": -3.68 } ], "profile": "carFast", "regionDefinition": { "type": "world" }, "matrixAttributes": ["distances"]}<br />
Response:<br />{ "matrixId": "303727d8-e734-447c-a8ba-d3c879aaca17", "matrix": { "numOrigins": 7, "numDestinations": 4, "distances": [ 0, 1378337, 1095170, 2322681, 1376876, 0, 2413914, 3641425, 1098371, 2418169, 0, 1719413, 2321546, 3641344, 1713920, 0, 1841499, 853474, 2878537, 4106048, 1053405, 2373203, 446722, 1273481, 1509156, 2415988, 1831029, 1960998 ] }, "regionDefinition": { "type": "world" }}`<br />
Still with Usage dasnbhoard or Cost Management Usage API we can confirm the transactions generated from the above API query is:

Note that, the transactions for the above API query with billing tag "o7d4" is exactly 28.
Case 3 - 7 Starting Points and 6 Destination Points
This fits the scenario 2 - when both of the S or D are greater than 5, the greater one of S and D multiplies by 5
The transaction is calculated as 7 x 5 = 35
Request:<br />{ "origins": [ { "lat": 52.54, "lng": 13.40 }, { "lat": 50.43, "lng": 30.52 }, { "lat": 51.50, "lng": -0.08 }, { "lat": 40.40, "lng": -3.68 }, { "lat": 55.75, "lng": 37.60 }, { "lat": 48.87, "lng": 2.33 }, { "lat": 41.90, "lng": 12.48 } ], "destinations": [ { "lat": 52.54, "lng": 13.40 }, { "lat": 50.43, "lng": 30.52 }, { "lat": 51.50, "lng": -0.08 }, { "lat": 40.40, "lng": -3.68 }, { "lat": 55.75, "lng": 37.60 }, { "lat": 48.87, "lng": 2.33 } ], "profile": "carFast", "regionDefinition": { "type": "world" }, "matrixAttributes": ["distances"]}<br />
Response:<br />{ "matrixId": "d4da6764-02c0-4ed7-94e0-2dbeb9cc7ee0", "matrix": { "numOrigins": 7, "numDestinations": 6, "distances": [ 0, 1353532, 1098335, 2322033, 1822076, 1056823, 1371066, 0, 2411274, 3634972, 862055, 2369762, 1102152, 2413674, 0, 1719296, 2882218, 458823, 2323192, 3634714, 1717082, 0, 4103258, 1273028, 1849623, 853470, 2889831, 4113529, 0, 2848319, 1055081, 2366603, 453509, 1273468, 2835147, 0, 1510789, 2419368, 1832381, 1945551, 3014030, 1425983 ] }, "regionDefinition": { "type": "world" }}`<br />
Still with Usage dashboard or Cost Management Usage API we can confirm the transactions generated from the above API query is:

Note that, the transactions for the above API query with billing tag "o7d6" is exactly 35.
Summary
All in all, we have the following use cases tested and had the transaction calculation method for Matrix Routing verified:
4 origins and 4 destinations generate 16 transactions
7 origins and 4 destinations generate 28 transactions
* 7 origins and 6 destinations generate 35 transactions
I hope this helps, but if still have confusions you can use the testing method in this KB article to test your own use cases too.