A domain is available or not may mean two different concepts
- Domain is available for registration
- Domain has a valid presence on DNS system (eg. has a website, can accept email etc.)
You mention about domaintools, hence probably you are interested in concept 1 mentioned above.
The most reliable way to find out whether a domain is available for registration or not is to query whois server for that TLD or ccTLD. Query to whois servers is always free. Although there may be strict limitations as to how many queries can be made per min/hour etc.
Finding out availability based on DNS is not reliable. It is possible that a domain may not have nameservers set with the registrars, in that case the response from DNS server would be "domain does not exists" though the domain is not available for registration.
ProgrammableWeb has a good collection of domain related apis here.