Jump to content

Calling an API code example


Graham Quince

Recommended Posts

I always struggle to remember the format needed to call an API, so thought it might make sense to have them here for copy-and-paste-and-adapt purposes

Internal* Frog API (GET)

Frog.Model.api('API_URL_GOES_HERE', {
    param1: 'PARAM1',
    param2: 'PARAM2'
}).done(function(response) {
    // do something with the response data
    var data = response;
}).fail(function(e) {
    // Report Error
    console.log("failed");
});

Internal Frog API (POST)

Frog.Model.api('API_URL_GOES_HERE', {
    param1: 'PARAM1',
    param2: 'PARAM2'
},{
    type: 'POST'
}).done(function(response) {
    // do something with the response data
    var data = response;
}).fail(function(e) {
    // Report Error
    console.log("failed");
});

 

FDP API (GET)

FrogOS.fdp({
    url: 'API_URL_GOES_HERE',
    path: '/api/fdp/2/',
    data: {
        param1: 'PARAM1',
        param2: 'PARAM2'
    }
}).done(function(response) {
    // do something with the response data
    var data = response;
}).fail(function(e) {
    // Report Error
    console.log("failed");
});

FDP API (POST)

FrogOS.fdp({
    url: 'API_URL_GOES_HERE',
    path: '/api/fdp/2/',
    type: 'POST',
    data: {
        param1: 'PARAM1',
        param2: 'PARAM2'
    }
}).done(function(response) {
    // do something with the response data
    var data = response;
}).fail(function(e) {
    // Report Error
    console.log("failed");
});

 

* Internal APIs are subject to change by our developers.  FDP APIs are set in stone.  You can use the Network tab in your browser's Developer Console to identify an internal API and its required parameters.

On each of your Frog platforms, there is an application called fdpapi.pngFDP API Reference (if it's not visible, you may need to publish this via Package Manager).  Within this, you'll find a list of all the FDP APIs, their URLs and available parameters.  The one element this application lacks is the above example, but hopefully this will help with that.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...