From the above list, the complexity and feature richness of the Salesforce API is more than evident. The REST API and the SOAP API are exposing the same functionalities but using different protocols. Interacting with the REST_API can be done using tools like CURL or Postman or using HTTP clients for your favorite language or framework. A few suggestions:
- Apache HttpClient for Java
- Spray-client for Scala
- Hyper for Rust
- Ruby rest-client
- Python http-client
The Salesforce REST API supports OAuth 2.0 authentication. More information can be found in the Understanding Authentication article. After you successfully authenticate with the REST_API, you have to start interacting with its resources and start fetching data from it to load them on a warehouse.
It’s easy to get a list of all the resources we have access to. For example, using curl, we can execute the following:
curl https://na1.salesforce.com/services/data/v26.0/ -H "Authorization: Bearer token"
A typical response from the server will be a list of available resources in JSON or XML, depending on what you have asked as part of your request.
"sobjects" : "/services/data/v26.0/sobjects",
"licensing" : "/services/data/v26.0/licensing",
"connect" : "/services/data/v26.0/connect",
"search" : "/services/data/v26.0/search",
"query" : "/services/data/v26.0/query",
"tooling" : "/services/data/v26.0/tooling",
"chatter" : "/services/data/v26.0/chatter",
"recent" : "/services/data/v26.0/recent"
The Salesforce REST_API is very expressive. It also supports a language called Salesforce Object Query Language (SOQL) for executing arbitrarily complex queries. For example, the following curl command will return the name fields of accounts:
curl https://na1.salesforce.com/services/data/v20.0/query/?q=SELECT+name+from+Account -H "Authorization: Bearer token"
and the result will look like the following:
"done" : true,
"totalSize" : 14,
Again, the result can be either in JSON or XML serialization. We would recommend using JSON to make the whole data connection process easier because the most popular data warehousing solutions natively support it.
With XML, you might have to transform it first into JSON before loading any data to the repository. More information about SOQL can be found on the Salesforce Object Query Language specification page.
If for any reason you would prefer to use SOAP, then you should create a SOAP client first: for example, you can use the force.com Web Service Connector (WSC) client. Or create your own using the WSDL using the information provided by this guide.
Despite the protocol changes, the architecture of the API remains the same, so again you will be able to access the same resources.
After you have your client ready and you can connect to Salesforce, you ought to perform the following steps:
- decide which resources to extract from the API
- map these resources to the schema of the warehouse of the data repository that you will use
- transform data into it and
- load the transformed data on the repository based on the instructions below
As you can see, accessing the API alone is not enough for ensuring the operation of a pipeline that will safely and on time deliver data you own on a data warehousing solution for analysis.