Jump to content
Graham Quince

Calling an API code example

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...