Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Sep 2006
    Location
    Pennsylvania
    Posts
    6

    Default XML or JSON API?

    Hi,

    I was just reading the API documentation. I have read that it is recommended to use JSON over XML because it is faster. Is this still the case, and why so? I don't see how one output format is faster than the other. If so, is the performance difference significant?

    I ask because I'm much more comfortable with using XML, but don't want a huge performance hit.

  2. #2
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default

    Hi Azavia,

    I don't remember reading that, but would be interested to know where you found it in the API docs. Kinda curious now...

    If I had to venture a guess (concerning cPanel specifically), I'd say that it has to do with data manipulation on the server-side. When an API call is made the json-api or xml-api see the request, fetch info or perform action, then have to prepare the response. Preparing the response might take long for the xml-api binary.

    In general, I've heard is said that XML simply takes longer that JSON because the the character count, e.g. the amount of data. Also, I've heard it said that XML is slower than JSON when parsing in browser JS engines. It seems plausible with modern browsers (who are so intent on JS speed). But I've never seen, or search for, lab results.

    I wouldn't sweat it until you have proof which shows marked improvement. To my knowledge, WHM uses both xml-api and json-api (more json).
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  3. #3
    Member
    Join Date
    Sep 2006
    Location
    Pennsylvania
    Posts
    6

    Default

    Hi,

    Thanks for your reply. Here's where I found it: XML and JSON APIs

    Important: The JSON API is much less resource-intensive than the XML API. We highly recommend using the JSON API, especially if performance is important, since it provides much faster results.

  4. #4
    cPanel Staff cPanelMatt's Avatar
    Join Date
    Apr 2005
    Location
    Houston, TX
    Posts
    409

    Default

    This really depends on what you're doing.

    Currently JSON queries using API1 are broken, so if you're doing cpanel API w/ API1 calls, XML is probably the best option for the time being. (this will be fixed soon)

    That being said, the XML API w/ API1 can cause encoding issues due to the fact that the XMLAPI can return HTML output.

    If API1 isn't a concern for you, then the issue comes down to a matter of implementation.

    Within javascript, JSON is MUCH faster to use as it is the format used for datastructures with in JSON natively, there isn't much in terms of client side processing involved. While XML can put a bit more load on the server.

    In the context of a non-browser environment, I suggest using whatever you feel most comfortable with.
    Matt Dees
    Integration Developer
    cPanel, Inc.
    cPanel Integration Blog

Similar Threads & Tags
Similar threads

  1. is XML/JSON-API available only to WHM accounts?
    By eschminke in forum cPanel Developers
    Replies: 6
    Last Post: 12-02-2011, 03:35 PM
  2. DNS Setup/edit domain forwarding via XML/JSON API
    By abrakadabra in forum Feature Requests for cPanel/WHM
    Replies: 2
    Last Post: 09-02-2011, 06:24 AM
  3. Replies: 0
    Last Post: 04-20-2010, 03:37 PM
  4. XML/JSON API & Session Creation using Access Hash
    By jdelsman in forum Feature Requests for cPanel/WHM
    Replies: 0
    Last Post: 02-08-2010, 04:15 PM
  5. XML/JSON API Function to retreive the 'Remote Access Key'
    By shaun in forum Feature Requests for cPanel/WHM
    Replies: 4
    Last Post: 02-08-2010, 02:36 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube