9 Replies Latest reply: Jun 21, 2012 6:03 AM by darkdog74 RSS

how to use data extraction API for java applications?

Newbie
Hi,

I am a newbie to Webtrends. I am trying to use the Data Extraction API. I have a few queries -

1. Is it possible to use this API for a java application?

2. If it is possible, do I need to include any jar or make any sort of configuration for using this API in my java application?

3. Is there any sample code snippet for using data extraction API in a a java application?

I had searched all your discussions and blogs, but may be I was wrong, could not find answers to my questions.
Any idea or suggestion on this would be of great help.

Thanks & Regards,

Amitava.
  • Re: how to use data extraction API for java applications?
    Paul Lawbaugh Novice

    Yes, you can absolutely use Java to access the data.  Many people already have in creating Java apps, web apps, Android Java apps, and Blackberry Java ME apps.

     

     

    We created our Data Extraction API in such a way that it is _code free_!  You don't need any code to get data using our REST requests.  In fact, try it out and log in and create a REST url from our http://generator.webtrends.com and then paste the REST URL into your browser address bar and the data will simply return (after you authenticate of course).

     

     

    But I can give you some helpful pointers for getting your Java app running with our data embedded in it.

     

     

     

     

     

    The process is simple.

    Short summary:

    • All you need is a java library for making an https connection.
    • Pass your webtrends account name along with your username in the authentication process with a backslash seperator.
    • Create your REST request in generator.webtrends.com and choose a format you prefer.
    • Add a parser library to your java code for the format you chose.

     

     

     

     

    Step by step pointers:

    1) For libraries, to make an Extraction request, all you need is any method of making an https request (there are lots of http helper libraries out there) with authentication.  In order to make this as easy to embed in applications as possible, we use http authentication.  Here is a link to apache commons libraries:  http://commons.apache.org/

     

    2) when you pass your username and password in the https request you need to follow this format:

         Username should look like:    webtrendsAccountName\userName     (i.e. the username should have your webt account, backslash, username)

         Password should look like:   password    (send your password as normal of course)

     

    3) practice with a simple Webtrends REST request first.  Create one in generator (http://generator.webtrends.com) from a basic report for "this month" and copy and paste the URL it generates for you into your test code.

     

    4) once you send the https request Webtrends will respond with all the data.  No extra code is needed of any kind.  In fact, if you were to paste that REST request into your browser, the data would simply show in your browser window.

         Do you want it in XML, JSON or HTML format?

         Many developers find it easiest to recieve data in XML because there are so many XML parsers out there.  See my link above to apache commons.

     

    I suggest you use our XML format made friendly for developers and change your rest request to show format=xml2

    That "xml2" is not a typo.  We have two xml formats to use and xml2 is the easiest to automate parsing for.

     

    5) get yourself a java parser for the format you chose in step 4.  Apache commons has one for both XML and JSON.  If you want to pursue JSON further (json is more compact, faster and efficient but not as easy to develop for) go to http://json.org/index.html and scroll down and you'll find a dozen or more json parsers for every platform.  If you are using Java to develop for Android, I recommend "gson".

    • Re: how to use data extraction API for java applications?
      Newbie

      Hi Paul,

       

      Thanks for the reply. However, there's something more, I would like to know in this regard. As suggested by you, the webtrends account name, username and password should be sent as parameters in the second step of the development process. Can you please clarify, how can I get these credentials? Do I need to do any sort of registration for obtaining these credentials?

       

      Thanks & Regards,

       

      Amitava.

       

       


      • Re: how to use data extraction API for java applications?
        Paul Lawbaugh Novice
        You just need to be a Webtrends customer.  The credentials just tells us what data you are trying to access (and whether or not you have the rights to access it). 

         

        The credentials are the same ones you use to log into Webtrends.  If you are not a Webtrends customer, sign up now and you'll get instant access to your data via REST web services.  Or you can contact our business development group if you are a partner or 3rd party developer and they can set you up with a demo/test data set.
        • how to use data extraction API for java applications?
          Newbie

          Hi,

           

          I am trying use data extraction API. Since we have a server installed on site, I cannot use the URL generator. What is the proper way to approach?   I am having a difficulties to access the server even if our infrastructure team says the API is installed.   Thank you in advance.

           

          Brian

          • how to use data extraction API for java applications?
            Paul Lawbaugh Novice

            There are several options.

            First of all, if you are in our new Insight user interface, even in on-premises there is a "Share" button.  When you click on that you can see the REST urls for the reports and it shows your own domain address for the web services.  It's using the same method as Generator is for your on-premises.

             

            But really the thing that is super useful about Generator for me is that it gives you a first intro to how REST works and then it is a good tool for getting your profile and report IDs for various data.  Using the Share feature will show the IDs the same way.

             

            Your next option is that you may not know this but you can actually just browse the REST data in your web browser, no Generator or html page needed.  Just use format=xml or format=html in your parameters and you can view the data returned right in your browse and change the parameters in your address bar.  This is the advanced users way of exploring the REST.

             

            The one option I don't have for you right now though is there isn't an "offline" way of doing the Generator type functions. 

            • how to use data extraction API for java applications?
              Newbie

              Hi Paul,

               

              Thank you for your prompt reply. However, I do not see the share button. Therefore, I think either I do not have the correct premission or it was not installed on our server. Our version is 9.2.1.290. Is it supposed to have Insight user interface?  If so, is there a special permission on user account for that user interface?

               

              Thank you.

              • how to use data extraction API for java applications?
                Paul Lawbaugh Novice

                The good news is that 9.2 has the Insight interface... but the person that installed and configured your environment needed to assign it to a particular address.  Typically people create a subdomain for insight like insight.[yourdomain].com or something like that. 

                 

                 

                To be honest, Insight is the interface all users should be accessing to see Webtrends.  The console interface most are used to from the past is really meant for an admins to configure profiles, create new metrics, etc. But in terms of understanding your site and viewing Analytics, you really should be using Insight.

                 

                Here is a screenshot of what you should be seeing:

                 

                profileview_withTwitterFeed_sharebutton.png

    • how to use data extraction API for java applications?
      darkdog74 Newbie

      Hi Paul, i used the generator to got an URL for a java Client extractor.
      When i try to invoke this URL i have a "connection refused" exception (maybe i'm doing something wrong in authentication), could you help posting an example code snippet?
      I'm using the Apache HttpComponents.

       

      Thank you very much

      Alessio