The Quttera port scanner API
gives you a list of all the open TCP and UDP ports. It gives the number of each open port, the protocol, and the name of the service or application listening on the port.
For each port, the report states whether it is open, filtered, or closed. A filtered port is blocked by a firewall; a closed one means the request reached the server, but no service responded.
More precisely, a filtered port doesn't respond at all; the ping times out. A closed port sends a response rejecting the query. A service can be configured not to respond at all, in which case it will be reported as filtered.
For each open port, the administrator can decide whether a service is mandatory, optional, or unauthorized. To decrease the attack surface, the admin can turn off all services that aren't needed and examine the source of unauthorized ones. The safest course is to block the unwanted ports in the firewall as well as disable them on the server.