What is the difference between platform.api.get("user/session") and getSession()?


What is the difference between platform.api.get(“user/session”) and getSession()?

Through Server Side scripts, I can make a call similar to: platform.api.get(“user/session”)

This returns a session object that I can work with on the server. See this previous post:

Under the API Docs tab in my local DSP, under GET /user/session, over to the right it is listed as getSession().

Is there a getSession() function that is accessible to my server side scripts that does the same thing as platform.api.get(“user/session”) ?


getSession() is just how the call GET /rest/user/session is represented by Swagger. If you’re using one of our SDKs, your “DSP URL” will be something like (this one from the JS SDK)

var dsp_url = "https://_your_dsp_hostname_here_/rest/api_docs";

so the representations of these calls will be returned as Swagger represents them at /rest/api_docs.

You’ll notice in your browser’s network monitoring console that when you click “Try it out!” on getSession(), it simply calls GET /rest/user/session.

This is the same call that your script accesses when you implement platform.api.get("user/session").


It’s also interesting to note that the admin console is primarily an example of what sort of app you can write (in AngularJS, in this case) to use DreamFactory. There is no function in the admin console that doesn’t simply make an API call that you could make from any other tool or app. It may be of didactic use to use your browser console to monitor the API calls that the console makes when you create services, modify users, save settings, etc. Every operation is simply a call to the API, and you could make the same call from cURL or an app of your own.


Great answers! Much appreciated. I understand (did have to lookup didactic) now. Thanks for the detail, I won’t worry that I’m not using the correct function calls now.