Was this helpful?

Here's how to integrate Apigee functionality into your HTML5/JavaScript application using the Apigee SDK for JavaScript.

1. Create an Apigee account

Sign in or create a new account if you do not already have one. You won't need it to install the SDK, but you'll need it to create apps.

For more about Apigee accounts, see Creating an Apigee Account.

After you've signed up, you'll see that you have a sandbox application to experiment with. For more information about that, see Using a Sandbox Application.

2. Download the Apigee JavaScript SDK

Download the Apigee JavaScript SDK and expand the ZIP file.

When you expand the ZIP file, you should see the following structure:

apigee-javascript-sdk-master
    /lib
    /samples
    /source
    /tests
    README.md
    build_release_zip.sh

What's included

The SDK includes the following:

File or Directory Description
/lib Minified version of the SDK (apigee.js).
/samples Sample apps that you can run to explore Apigee features.
/source Source code for JavaScript functions in the SDK.
/tests For SDK development only. HTML and JavaScript for testing the SDK functions.
build_release_zip.sh Builds SDK outputs and packages them into a ZIP file.

3. Import the SDK into your HTML

To enable support for Apigee-related functions in your HTML, you'll need to include apigee.js in your app. To do this, add the following to the head block of your HTML:

<script type="text/javascript" src="path/to/js/sdk/apigee.js"></script>

4. Instantiate Apigee.Client

Apigee.Client initializes the App Services SDK, and gives you access to all of the App Services SDK methods.

You will need to pass a JSON object with the UUID or name for your App Services organization and application when you instantiate it.

var client_creds = {
        orgName:'your-org',
        appName:'your-app'
    }

//Initializes the SDK. Also instantiates Apigee.MonitoringClient
var dataClient = new Apigee.Client(client_creds);  

5. Verify SDK installation

Once initialized, App Services will also automatically instantiate Apigee.MonitoringClient and begin logging usage, crash and error metrics for your app.

To verify that the SDK has been properly initialized, run your app, then go to 'Monitoring' > 'App Usage' in the App Services admin portal to verify that data is being sent.

It may take up to two minutes for data to appear in the admin portal after you run your app.

Installation complete! Try these next steps

  • Call additional SDK methods in your code

    Use dataClient or dataClient.monitor to call SDK methods:

    • dataClient: Used to access the data methods of the App Services SDK, including those for push notifications, data store, and geolocation.
    • dataClient.monitor: Used to access the app configuration and monitoring methods of the App Services SDK, including advanced logging, and A/B testing.
  • Add App Services features to your app

    With App Services you can quickly add valuable features to your mobile or web app, including push notifications, a custom data store, geolocation and more. Check out these links to get started with a few of our most popular features:

    • Push notifications: Send offers, alerts and other messages directly to user devices to dramatically increase engagement. With App Services you can send 10 million push notification per month for free!
    • App Monitoring: When you initialize the App Services SDK, a suite of valuable, customizable application monitoring features are automatically enabled that deliver the data you need to fine tune performance, analyze issues, and improve user experience.
    • Geolocation: Keep your app highly-relevant by targeting users or returning result sets based on user location.
    • Data storage: Store all your application data on our high-availability infrastructure, and never worry about dealing with a database ever again.
    • User management and authentication: Every app needs users. Use App Services to easily implement registration, login and OAuth 2.0-compliant authentication.
  • Check out the sample apps

    The SDK includes samples that illustrate Apigee features. To look at them, open the .xcodeproj file for each in Xcode. You'll find the samples in the following location in your SDK download:

    apigee-javascript-sdk-master
        ...
        /samples		
    		

    The samples include the following:

    Sample Description
    booksSample.html An app for storing a list of books that shows Apigee database operations such as reading, creating, and deleting.
    messagee An app for sending and receiving messages that shows Apigee database operations (reading, creating).
    monitoringSample.html Shows basic configuration and initialization of the HTML5 app monitoring functionality. Works in browser, PhoneGap, Appcelerator, and Trigger.io.
    readmeSample.html A simple app for reading data from an Apigee database.

Add new comment

Provide your email address if you wish to be contacted offline about your comment.
We will not display your email address as part of your comment.

We'd love your feedback and perspective! Please be as specific as possible.
Type the characters you see in this picture. (verify using audio)

Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.