A web service is a code designed to handle communication between two nodes which is independent of operating systems where the nodes reside on.
A SOAP based web service usually uses a XML/JSON to organize data, SOAP (Simple Object Access Protocol)** to transfer the messages and WSDL (Web Services Description Language)*** to describe the services.
An example of a SOAP based web service can be viewed here.
An API (Application Program Interface) is a development in web services where the service is a simpler REST (representational state transfer) compliant communications. RESTful APIs do not require XML-based Web service protocols (SOAP and WSDL) to support their interfaces. To the extent that systems conform to the constraints of REST they can be called RESTful. RESTful systems typically, but not always, communicate over HTTP with the same HTTP verbs (GET, POST, PUT, DELETE, etc.) which web browsers use to retrieve web pages and to send data to remote servers. REST interfaces with external systems using resources identified by URI, for example /people/tom, which can be operated upon using standard verbs, such as DELETE /people/tom. 
An example of a RESTful based web service can be viewed here.
*XML - Extensible Markup Language is a markup language that defines a set of rules for encoding documents in a format which is both human-readable and machine-readable. It is defined by the W3C's XML 1.0 Specification and by several other related specifications, all of which are free open standards.
**SOAP, originally an acronym for Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of web services in computer networks. It uses XML Information Set for its message format, and relies on other application layer protocols, most notably Hypertext Transfer Protocol (HTTP) or Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission.
***WSDL (Web Services Description Language) is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint.
W3C DOCUMENT LICENSE