This API is available on Firefox OS for privileged or certified applications only.


The getCount method is used to retrieve the total number of contacts available inside the device's contact database.


var instanceOfDomRequest = window.navigator.mozContacts.getCount();

Return value

A DOMRequest object to handle the success or error of the operation. In case of success, the request's result is a number.


var request = window.navigator.mozContacts.getCount();

request.onsuccess = function () {
  console.log('there are ' + this.result + ' contacts in the database.');

request.onerror = function () {
  console.log('Something goes wrong!');


Specification Status Comment
Contacts Manager API
The definition of 'Contacts Manager API' in that specification.
Working Draft  
vCard Format Specification IETF RFC RFC 6350

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
basic support No support No support No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
basic support No support No support 18.0 No support No support No support

See also


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

API B2G Contact Firefox OS Method Reference Référence WebAPI