There are different APIs which developers can use to integrate with Salesforce org. In this blog post, we will talk about what APIs we have and when to use them.
What are Salesforce APIs and how developers can use them?
We have about 8 APIs till now. While all these serve a similar purpose of accessing data from Force.com platform or Database.com but there are key differences between each of these APIs.The important point to remember is that all of these APIs operate identically across Force.com platform and Database.com
SOAP API:
The most well-known API is the SOAP API. As the name indicates, it uses SOAP as a wrapper for API operations. Most of the API traffic is from SOAP API because its been in the market for long time.
SOAP API is around for long time:
SOAP APIs is considered as the “granddaddy” of the APIs. SOAP API is used in enterprise setting because tooling is used to create SOAP messages. You can even build a SOAP envelope by concatenating strings but that task is pretty laborious. So we use tools like Visual Studio or Eclipse to import the WSDL. Salesforce also offers a Java toolkit called WSC through which you can import a .jar file and it provides you a nice programming interface to create records, run queries etc.
Metadata API:
The second type of API is Metadata API. The SOAP API is focussed towards accessing data and manipulating records, whereas the Metadata API focusses on Metadata. This API is uses to manipulate layouts, visualforce pages, apex triggers and classes- pretty much everything that you can do from the browser interface.
Metadata API is not just used to fetch. Tools like Force.com IDE use Metadata API to make changes to your Salesforce org. So to summarize, Metadata API is not just for querying information but it is also used for updating or creating objects.
Metadata API is also a SOAP based API so you will need a library on the client side or you can use the tools to import the WSDL.
Apex API:
The metadata API enables you to upload APEX classes, but tools like Force.com IDE needs more functionality. Apex API exposes API objects and calls which allow you to execute an anonymous block of code, run tests and compile classes. Most developers won’t ever need to use APEX API directly but they all are benefited from its use in the force.com IDE.
This is also a SOAP API so you have to download the WSDL to get started.
APEX SOAP:
This is a third API. APEX SOAP Api enables you to expose APEX methods via SOAP. For example, you have an Apex method which takes parameters like person name, company name and phone number and then it creates an Account and Contact in one operation.You can expose this method as a service operation by using @WebService annotation above the method.
But one of the drawbacks of SOAP is that it’s pretty heavyweight.
REST : If you just need a point-to-point call, then SOAP can be overkill. In SOAP, you will need an envelop and headers and a whole spec which contains information on how to process the message. But if your requirement is just to send a message from a client to a server and send back the response, you can use something simple which is REST.
REST is Representational State Transfer and it is very simple as compared to SOAP. The main idea behind REST is that every object in the system is associated with a URL. When you perform operations on that URL, you are accessing a representation of the state of that object. For example, if you do a GET on a URL representing an account record, you will get back XML or JSON response with the state of that account. You can perform a POST request to create a new account, DELETE request to delete an account.
They have a new addition to the HTTP methods known as PATCH, this can be used to update the account. In nutshell, we are passing XML or JSON back and forth and leveraging HTTP operations. REST makes it easy for programmers.
SOAP messages are formatted as XML. JSON stands for JavaScript Object Notation is more concise data representation than XML. In JSON, data is represented in form of object. You have property names, property values and you can also have nested objects and arrays.
For instance, if you use REST API to do a query which would be a GET request on a URL which ends in “query?q=soql query”, you will recieve an array of records formatted in JSON.
The main thing about JSON is that its comparatively more concise and lightweight. Since there is less data on the wire so it is faster also. But from programmer point of view, if you are working in JavaScript or PHP or Java or any other language, there are great high-performance libraries available for parsing JSON. Its easy to work with and you don’t have to download a WSDL particular to the Salesforce API.
The great thing about using URLs is when you have a foreign key relationship. For instance, if you have an account and contact, if you just retrieve the contact, it will contain the URL to retrieve the account as well. Then you only need to perform GET operation on that URL to retrieve the account.
REST API:
For REST, the developer doesn’t need to know what objects are available to query. The REST API is been around since Spring ’11 release and it also encompass metadata operations. But in REST API, the metadata is read-only. A programmer can perform a similar operation using REST, you could retrieve a list of objects which are available in the system. For a particular object, you can also retrieve the list of its fields. You can build dynamic interfaces using REST API.
Usually, REST API operates on small number of records. You can retrieve a single record using GET request or you can also run a query to get back a set of records.
Bulk API:
Bulk API has been around longer than REST API. It is an asynchronous API, and it has the ability to work with large data sets like 600,000 records. But you should not use this API if you just need a handful of records and also if you want to create a dynamic UI. Bulk API is a special purpose API to load large amount of data.
With the Bulk API, the programmer/developer must know about the object in their salesforce org because if you are using BUlk API to load data, you have to formate the data based
on the schema.
Apex REST:
Just like in Apex SOAP, you can write an Apex method and expose it via a SOAP interface. Similarly, we can have an APEx method exposed via REST. That’s extremely helpful because one of the properties of REST API is that you can do updates and they are on individual records. For instance, if you want to do an atomic update in which you want to update the account and a contact record and you also want them either both to succeed or both to fail. Its not possible to do that via REST API. In this case you have to do a PATCH on the account and a PATCH on the contact.
So basically, you can’t have a transaction.Scenarios like this when you have an Apex method that performed both of those updates and expose the method via REST, you will call the method, send the account and contact info, and then make the updates in that method. The way Apex methods work is that if in a method you have one successful operation and the next operation fails in an error, then your method will roll back any change that were made.
To summarize, you can have an Apex method that perform multiple operations and it is effectively one transaction. This is really helpful when you want to work with more complex data.
Streaming API:
The next API is the Streaming API. The APIs that we have discussed so far, enables you to make a call and get back data or update data, whereas the Streaming API is used to create a push topic based on a query and it get updates regularly based on the results of that query change. So you can pick “select name from some object” and then subscribe to the topic channel. When there are no changes, you get nothing.Your app sits there and waits. But as soon as somonene creates or update a record which matches your push topic query, you will receive a notification which contains fields thats are in the SELECT statement of the topic query. The notification of data change is also pushed to the client.
You can design your SOQL query to match whatever constraints you like even you can narrow down to changes on an individual record. This tool enables you to build dynamic user interfaces.
Chatter API:
The API that we have discussed so far are usually for general purpose. Those API can be used on any object in the database. You can use all those APIs to communicate with Chatter if you are aware of the underlying chatter model.But to access chatter that way is very laborious because as a developer you have to thread those objects together urself. And it is also very costly in terms of round trips. You have to make several trips using REST API or SOAP API to assemble the data which you want to show to the user.
In this case, Chatter API comes to rescue. It gives a higher-level of abstraction of that data. Instead of dealing with the underlying objects, you will deal with slightly abstract representaion of a user’s chatter feed. It is designed so that, you can make one call and retrieve pretty much everything you need. In some cases, you might have to drill down little bit but in most applications which are manipulating chatter are making standard requests.
Course:
I have a course on API with examples, please check the complete course here:
Resources :
Easier Developer Doc and Salesforce Searches on Chrome
Quality articles is the important to be a focus for the viewers
to visit the site, that’s what this site is providing.
Paragraph writing is also a fun, if you know afterward you can write
otherwise it is complicated to write.
Hurrah! After all I got a blog from where I can really get useful data concerning my study and knowledge.
I gotta favorite this site it seems extremely helpful very helpful.
Hi every one, here every one is sharing these knowledge, thus it’s
nice to read this web site, and I used to pay
a visit this blog daily.
Very interesting info!Perfect just what I was searching for!
I want to point out my love for your generosity giving support to
persons who should have guidance on your concept. Your special dedication to
getting the message all through had become exceptionally invaluable and have consistently enabled ladies much like me to get to their pursuits.
Your warm and friendly guidelines denotes much a person like me and much more to my office workers.
Thanks a lot; from all of us.
Aw, this was a very good post. Taking the time
and actual effort to generate a good article?
but what can I say? I hesitate a whole lot and don’t
manage to get nearly anything done.
Aw, this was an incredibly good post. Finding the time and actual effort to make a superb article…
but what can I say… I put things off a lot and don’t seem to get nearly anything done.
We stumbled over here by a different web address and thought I should check
things out. I like what I see so now i am following you.
Look forward to checking out your web page repeatedly.
Excellent post! We are linking to this great content on our website.
Keep up the good writing.
Highly descriptive blog, I enjoyed that bit. Will there be a part 2?
I love your blog.. very nice colors & theme.
Did you create this website yourself or did you hire someone to do it
for you? Plz reply as I’m looking to create my own blog and would like to find out where u got this from.
cheers
Hello There. I found your blog using msn. This is a very well written article.
I will make sure to bookmark it and come back to read more of your useful information. Thanks for the post.
I’ll definitely return.
I’m gone to tell my little brother, that he should also go to see this blog on regular basis to
obtain updated from newest information.
Very quickly this site will be famous amid all blogging and site-building users, due to it’s pleasant
articles or reviews
I feel that is among the such a lot vital information for me.
And i am happy studying your article. But want to commentary on some normal things, The site taste is
wonderful, the articles is truly nice : D. Good task, cheers
I am really grateful to the holder of this website who has shared this wonderful piece of writing at at this place.
Unquestionably believe that which you said. Your favorite reason seemed to be on the
net the simplest thing to be aware of. I say to you, I definitely get
irked while people consider worries that they plainly do not know about.
You managed to hit the nail upon the top and defined out the
whole thing without having side-effects , people
can take a signal. Will probably be back to get more.
Thanks
Hi! Do you know if they make any plugins to protect against hackers?
I’m kinda paranoid about losing everything I’ve worked
hard on. Any suggestions?
Wow, that’s what I was searching for, what a material! present here at
this web site, thanks admin of this site.
I don’t even know how I ended up here, but I thought this post was good.
I do not know who you are but definitely you’re
going to a famous blogger if you are not already 😉 Cheers!
I’d like to find out more? I’d love to find out some additional information.
Saved as a favorite, I love your website!
I visited many web pages except the audio quality for audio songs existing at this website is actually fabulous.
I really like your blog.. very nice colors & theme. Did
you create this website yourself or did you hire someone
to do it for you? Plz reply as I’m looking to design my
own blog and would like to find out where u got
this from. thanks a lot
Very rapidly this website will be famous among all blogging and site-building viewers, due
to it’s nice posts
Wow, fantastic blog layout! How long have you been blogging for?
you make blogging look easy. The overall look of your web site is excellent, as well as the content!
Great article. I will be going through many of these issues as well..
excellent issues altogether, you simply received a brand new reader.
What would you suggest about your submit that you just
made a few days ago? Any certain?
It’s an awesome paragraph designed for all
the online visitors; they will take advantage from it I
am sure.
What’s up, everything is going fine here and ofcourse every one is sharing facts,
that’s in fact excellent, keep up writing.
I always spent my half an hour to read this web site’s articles or reviews all the
time along with a mug of coffee.
Hi, i think that i noticed you visited my web site so i came to return the want?.I’m attempting to in finding issues to
enhance my website!I assume its adequate to make use of some of
your concepts!!
A fascinating discussion is definitely worth comment.
I believe that you should publish more on this topic, it may not
be a taboo matter but usually people do not speak about these topics.
To the next! Kind regards!!
It’s very effortless to find out any matter on web as compared to books, as I found this article at this
site.
I’m pretty pleased to find this site. I need to to thank you for your time
for this fantastic read!! I definitely liked every
part of it and I have you book-marked to look at new information on your blog.
What’s up to all, the contents present at this web page are actually
awesome for people experience, well, keep up the nice work fellows.
Hi! Someone in my Facebook group shared this website with us so I came to check it out.
I’m definitely enjoying the information. I’m book-marking and
will be tweeting this to my followers! Exceptional blog and superb design.
Hello to all, the contents existing at this web site are
in fact remarkable for people knowledge, well, keep up the good work
fellows.
Hey! I know this is kind of off topic but I was wondering if
you knew where I could get a captcha plugin for my comment form?
I’m using the same blog platform as yours and I’m having
trouble finding one? Thanks a lot!
This site truly has all of the information I wanted
about this subject and didn’t know who to ask.
Heya i’m for the first time here. I came across this board and I find It truly useful & it helped
me out a lot. I hope to give something back and aid others like you helped
me.
Greetings! Very useful advice in this particular article!
It’s the little changes that will make the
largest changes. Thanks for sharing!
Hello i am kavin, its my first time to commenting anywhere, when i
read this piece of writing i thought i could also create comment due to this sensible article.
I know this if off topic but I’m looking into starting my own blog and was wondering what
all is needed to get set up? I’m assuming having a blog like yours would cost a pretty penny?
I’m not very internet smart so I’m not 100% certain. Any tips or
advice would be greatly appreciated. Cheers
Thanks for sharing your info. I really appreciate your efforts and I am
waiting for your next write ups thank you once again.
After looking over a handful of the articles on your website, I honestly like your technique of writing a blog. I saved it to my bookmark website list and will be checking back soon. Please check out my website as well and let me know your opinion.|
Yes! Finally something about gum disease.
Great article! We will be linking to this particularly great content on our site.
Keep up the good writing.
It’s not my first time to pay a visit this site, i am visiting this
site dailly and get good data from here every day.
I have read so many articles or reviews about the blogger lovers however this article is genuinely a good
article, keep it up.
No matter if some one searches for his necessary thing, therefore he/she
desires to be available that in detail, so that thing is maintained over here.
whoah this blog is excellent i really like studying your articles.
Keep up the great work! You know, a lot of persons are looking round for this
info, you can aid them greatly.
We are a group of volunteers and opening a new scheme in our
community. Your website offered us with valuable info to work on. You’ve
done a formidable job and our whole community will be grateful to you.
Simply discovered your site through google and I consider it’s a shame that you’re not ranked greater since this is a implausible post. To alter this I decided to avoid wasting your web site to my RSS reader and I will try to mention you in one of my posts since you really deserv extra readers when publishing content of this quality.
Nicely picked details, many thanks to the author. It’s incomprehensive in my experience at present, however in common, the convenience and importance is mind-boggling. Regards and all the best ..
I loved as much as you will receive carried out right here.
The sketch is attractive, your authored material stylish.
nonetheless, you command get bought an nervousness over that you wish be delivering the following.
unwell unquestionably come further formerly again as exactly the same nearly a lot often inside case you shield this increase.
I’m not that much of a online reader to be honest but your sites really nice, keep it up! I’ll go ahead and bookmark your website to come back in the future. All the best|
Incredible points. Solid arguments. Keep up the amazing effort.
Helpful information. Fortunate me I found your site by chance, and I am shocked why this coincidence didn’t happened in advance! I bookmarked it.|
I am extremely impressed with your writing skills as well as with the layout on your weblog.
Is this a paid theme or did you modify it yourself? Anyway keep up the nice quality
writing, it’s rare to see a nice blog like this one
these days.
Hi to all, the contents existing at this web
page are really amazing for people experience, well, keep up the
good work fellows.
I always used to study paragraph in news papers but now as I am a user of internet so from now I am using net for content, thanks to web.|
My coder is trying to persuade me to move to .net from PHP.
I have always disliked the idea because of the costs. But he’s tryiong none the less.
I’ve been using WordPress on a variety of websites for about a year and am
concerned about switching to another platform.
I have heard excellent things about blogengine.net.
Is there a way I can import all my wordpress posts into it?
Any help would be greatly appreciated!
Wonderful blog! I found it while surfing around on Yahoo News. Do you have any suggestions on how to get listed in Yahoo News? I’ve been trying for a while but I never seem to get there! Many thanks|
Incredible points. Great arguments. Keep up the great effort.|
With havin so much content do you ever run into any problems of plagorism or copyright infringement?
My blog has a lot of completely unique content I’ve either
created myself or outsourced but it looks like a lot of
it is popping it up all over the web without my permission. Do you know any solutions to help
reduce content from being stolen? I’d really appreciate it.
Hello, Neat post. There’s a problem along with your web site in internet
explorer, could check this? IE nonetheless is the marketplace leader and a huge section of
people will miss your wonderful writing due to this problem.
I was more than happy to uncover this website.
I need to to thank you for ones time due to this wonderful
read!! I definitely enjoyed every part of it and i also have you saved to fav to
see new stuff on your web site.
Hello there, I discovered your blog by way of Google while searching for a similar matter, your web site came up, it seems great. I have bookmarked it in my google bookmarks.
Incredible! This blog looks just like my old one! It’s on a completely different subject but
it has pretty much the same layout and design.
Superb choice of colors!
Highly energetic blog, I liked that a lot. Will there be a part 2?
This design is steller! You most certainly know how to keep a reader amused.
Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Fantastic job.
I really enjoyed what you had to say, and more than that, how you presented it.
Too cool!
I want to start a blog that deals with moral issues. I want people to be able to see it, and also be easy to use and post..
I think this is one of the such a lot important
information for me. And i am happy studying your article. However should remark on some normal things, The website taste is
great, the articles is in reality nice : D. Good activity,
cheers
I am really grateful to the owner of this site who has shared this fantastic post at
at this time.
Hurrah! In the end I got a webpage from where I be capable of in fact take useful information concerning my study and knowledge.
You should be a part of a contest for one of the best websites on the web.
I most certainly will highly recommend this website!