How to get all the accounts?

How to get all the accounts?

I'm new here. and i want to know how can i get all the accounts and contacts listed. 
basically i have to create a contact if there is no contact for a particular account, I have to create a contact using accountid.
so, I am doing is simple.
  1. get each account_Id of all the accounts.
  2. check in contacts_id. that it exists or not.
  3. if not create a new contact using account_id
  4. create a token using account-_id and contact_id
So, how should I get all the account ids that were created so far in zoho?