function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ThenmozhiThenmozhi 

Any one explain me what is REST API and What is SOAP API?which Scenario we go for REST and Which we go for SOAP API?

KevinPKevinP
SOAP is an older standard for apis and stands for SImple Object Access Protocol. SOAP api's have portable XML Documents refered to as WSDL (Web services definition language) that language, os and platform agnostically define how the webservice works. WSDL's are downloaded from the api server, parsed by your prefered language's wsdl parsing tool into classes in your language of choice. ie: Wsdl2ruby would generate ruby classes from the wsdl that allow you to create the objects and call methods on those objects. SOAP transfers information across the "wire" by sending XML. Because of this, payloads can be ... large. 

REST is a newer standard for API's and stands for Representative State Transfer. Rest API's can use either XML or JSON, but most commonly use JSON as a wire serialization protocol. REST api's are built on top of HTTP(S) and data is exchanged using HTTP action verbs - POST, PATCH, GET, DELETE etc. REST has "conventions" that map certian action verbs to certian actions. Ie: POST creates a record. Patch updates a record, GET retrieves the Record and Delete deletes. 

Rest differs from SOAP in one really big way - With SOAP, you Instantiate an object, say an account and then call the .create() method on it. With REST, you create your object, serialize it to JSON or XML and POST the data to a given URL. Because of this there are some additional considerations for Authentication and authorization. REST api's commonly use oAuth, whereas most SOAP api's have built in login methods. 

Salesforce provides both REST and SOAP apis. I'd say 95% of the functionality available in the SOAP Api is also available in the REST api and the gap is closing. 

If you are using a statically typed language, with a legacy framework stack like Java, .Net etc that provides a rich set of utilities around SOAP api's you may find soap is easier to adopt quickly. On the other hand, if you work with a more dynamic language like Ruby or Python, you will likely find it easier to deal with the JSON and HTTP verbs of REST apis.