Reputation: 15
I am using Google Distance Matrix API. But I am unable to figure out the API cost, it has written on their website that "price per element". So, if I have two origins and 1000 destinations, then what will be my total API cost, and is the example program with Google OR tools is enough to run 1000 destination distance API call and solve the matrix?
Please Help!!
Upvotes: 0
Views: 3105
Reputation: 1167
The Google Distance Matrix API has been deprecated and is now replaced by the Compute Routes endpoint of the Routes API (https://blog.afi.io/blog/using-the-google-distance-matrix-api-for-taxi-dispatch/). This API costs $5 CPM per element so if you have a 25 origin x 25 destination it will cost 10 * 10 * ($5 / 1000) = $3.125. You won't be able to do a single 2 x 1000 call because the max number of origins and destinations is 25.
Upvotes: -1
Reputation: 72
As @evan said each element costs $0.005 as per Google's documentation, normally. However, there are two kinds of requests to that endpoint. First one is probably the one you are using (e.g. default settings). The second is when some special modificitations are made e.g. specifying departure times etc. The second kind, called Advanced, is more expensive at a price of $0.01 per element.
In your case you will need to query 2*1000=2000 elements (over multiple API calls). If you are not using advanced features, you'd be billed 0.005 * 2000 = $10. Otherwise you'd be billed $20.
Upvotes: 0
Reputation: 5699
Each Distance Matrix API call generates a number of elements (the number of origins times the number of destinations, e.g. 10 origins * 10 destinations = 100 elements) and each element costs $0.005 as per Google's documentation. So in the provided example, you'd be billed 0.005 * 100 = $0.5 per call to the Distance Matrix API.
Also, note that you cannot add two origins and 1000 destinations to a single request. You are limited to a maximum of 25 origins or 25 destinations per request, hence in order to query 1,000 destinations you'd need to make multiple Distance Matrix API requests.
Hope this helps!
Upvotes: 0