Although the Force.com REST API makes accessing data in Salesforce very straightforward, it is limited to inserting, updating and deleting a single record at a time. The SOAP API is able to manipulate larger sets of records, but is more complex to work with. The Bulk API, on the other hand is based on REST principles and is optimized for loading or deleting large sets of data. You can use it to query, insert, update, upsert, or delete thousands of records asynchronously by submitting batches which are processed in the background by Salesforce.
Although the Bulk API is indeed ‘based on REST principles’, it is very different from the REST API itself. Rather than operating on records in Salesforce, clients create asynchronous jobs, upload records in batches, and periodically check for job status. Although data can be uploaded in CSV or XML format, clients exchange XML messages in the ‘control plane’.
BulkTK extends ForceTK by adding methods to the ForceTK client object. After initializing a ForceTK client with a session ID, you can create a Bulk API job,
add one or more batches of records,
close the job,
check batch status,
and retrieve results,
which, for a CSV job, are in the form
A sample Visualforce page demonstrates bulk query, insert, update, upsert and delete for both CSV and XML data.
As of this writing, BulkTK should be considered ‘early Alpha’ quality, but brave (‘foolhardy?’) developers are invited to take it for a spin (in a Sandbox or Developer Edition, please!) and report back their findings. Leave a comment here, file an issue or, best of all, fork ForceTK and submit a pull request!