+ Start a Discussion
buggs sfdcbuggs sfdc 

Need help With Streaming API,to stream live data from SFDC to Warehouse System


Here am gone through a lot of research but some how am not getting a solution how to start, experts please help me out.

My requirement is:—

 I wanted to stream live data to Warehouse system from salesforce,if new records is inserted or udpated on standard objects like Account,contact,Opportunity,Lead etc..
I wanted to inform Warehouse system about new insertions and updations from salesforce,so here how can i start writing my programme.And totally i need 20-25 SObjects data to be informed at a time , as newbie it looks quite hard to start writing a code for it.

Any Help Greatly Appreciated!

Thanks in Advance!
Austin MuellerAustin Mueller
How often are you wanting to get updates? When doing this, make sure you have enough API calls allowed for the amount of data that will be transmitted from your organization. 
buggs sfdcbuggs sfdc
HI Austin,

-Currently my org is Enterprise Edition and i see maximum calls for the day is 1,000,000 & minimum is 15,000 as per salesforce documentation,and as of today i can see the API requests in my Org as 1,22,000 and maximum limit it shows me as 427,000.
-Based on this how we can plan, Thanks for reaminig me on API Limits , i really have no idea about API Governor Limits,so please guide me how can we start doing it,And advice me how oftenly we can get updates.
- As of now my requirment is if some new record is inserted on any Sobject i need to inform warehouse system about it,if we are in trouble like hitting governor limits,suggest me some other alternate,waiting for your reponse.

Thanks Again!
Austin MuellerAustin Mueller
I think if you are able to wait 5 - 10 minutes per API call for updates before they reach your warehouse system, it may help. 

One way to do this as well (to avoid to many API calls), is to create a REST Resource via Apex Class in which you query all the objects on the last updated field since your last API call, and return all the results at once, then have your warehouse system sort out the data to be updated.
buggs sfdcbuggs sfdc
HI Austin 

Thats a great suggestion!

Here am started writing my code,in general we write our Rest API in the following formate and we will use CURL or Postman to use our class,but coming to stream API we need to go through Pushtopic,so thats now killing my head how we can write POST or GET methods uing pushtopic in REST APEX CLASS,please help me out if you have any source code?OR set my below code then i can write my Rest of the class.
global with sharing class MyRestResource {
    global static Account doGet() {
        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        Account result = [SELECT Id, Name, Phone, Website FROM Account ];
        return result;
    global static String doPost(String name,
        String phone, String website) {
        Account account = new Account();
        account.Name = name;
        account.phone = phone;
        account.website = website;
        insert account;
        return account.Id;

Thanks in Advance!