We have a requirement where we need to export records from salesforce tables into our application programmatically. I am reading on the various API's for data integration from salesforce mainly SOAP vs REST API's.
From what I understand, REST should be used when the web service requests are from mobile devices or browser based clients (since they understand JSON). Is that true? If that's the case how do Bulk REST API's fit the bill (since they are meant for bulk data transfers)?
I would like to get your thoughts on what are pros and cons in using SOAP or REST API's to export data records. Note that the requests are being made a java ee server application programmatically. After retrieving the records (probably in batches) from salesforce records we process (validate, filter etc) them and load them in our internal tables.
Thanks.
Best Answer
As a starting point, have a read of Which API Should I Use?.
The correct API for the job will depend on where you are calling it from, how many records you are working with and how long you are prepared to wait for the result.
Your use case
From your description of your server applications I'd suggest starting with the Bulk API. It sounds like your code is running without a user waiting for immediate output, so the asynchronous nature of the calls shouldn't be an issue. Moving more records in fewer API calls will also help keep your API call count down.
The SOAP API is another option if the number of records isn't particularly large and you are more comfortable using XML SOAP Messages after importing the WSDL.
At what number of records you should switch from the SOAP API to the Bulk API is a bit of a gray area. The SOAP API would work well from 1 to several thousand records. Note that it batchs up to 2000 records per query result. The Bulk API works better when dealing with thousands of records (or more). The JSON response data format makes it easy to process the data with JavaScript in the browser.
There is also a discussion style blog post Salesforce APIs – What They Are & When to Use Them.
UPDATE for comments:
With SOAP you can import a WSDL into your tooling of choice and have native methods generated for working with the API. This makes calling the API and accessing the data relatively straight forward (E.g. strongly typed classes in .NET and Java).
There is some overhead for all the SOAP marshaling code that is generated. REST strips away a lot of this and sends more minimal messages that are closer to how HTTP operates.
Consider this diagram I've borrowed from the popular StackOverflow question: REST and SOAP
- Image by Nakkeeran
In general, the REST API (non-bulk) isn't the first choice for a server to Salesforce integration where the focus is more on moving large volumes of records rather than responding to the user quickly and integrating with software running in a browser.
You could use the REST API if you want, but the SOAP and BULK APIs are generally better suited for your use case.