If you want to determine the actual carrier of a phone number, you should do what's called an HLR (Home Location Register) lookup. Many messaging services provide such a service and they usually have an HTTP API for that. However, it is going to cost you - there is a price per each lookup, quite small but it all adds up.
Also, if you need this for specific countries, the regulatory authority in charge of phone numbering may or may not have some kind of a database service that can be queried for numbering data. These usually have fixed costs, so you should do the math if you're doing enough lookups for that country's numbers so that it pays off.