Detect ISP (or/and country) by IP Address

There are many services on the Internet where we can the external IP address of our machine to find, but these benefits are generally information on ISP or country (or both). So my question is: How can I get this information programmatically for the IP address is there public catalogs or some API to retrieve this information?
