battery api example