General information

JavaScript SDK is SDK of built-in applications that are iframes, the content of which is located on the developer’s server.

JS SDK is supported for:

  • all web apps launched on out desktop platform ok.ru;
  • all new mobile apps launched on our mobile platform in an iframe (partially)

If your application is still launched as an external page you can request us to launch it in an iframe sending a request to api-support@ok.ru

Methods supported on mobile are marked with icon
Methods available ONLY on mobile are marked with icon

Setting up SDK

<script type="text/javascript" src="//api.ok.ru/js/fapi5.js" defer="defer"></script>

Connecting a library:

<script type="text/javascript" src="//api.ok.ru/js/fapi5.js" defer="defer"></script>

When using js + flash in a flash application, the “wmode=opaque” parameter must be set.

After every transition inside an iframe it is necessary to perform an initialization again with the FAPI.init method, as well as pass the following parameters:

  • api_server
  • apiconnection
  • web_server
  • application_key
  • session_key
  • session_secret_key

Using SDK

SDK allows you to:

  • invoke OK REST API methods;
  • implement social mechanics - posts, invites and notifications between users;
  • implement in-app purchases and subscriptions;
  • implement in-app ads;
  • work with browser window and iframe in which app is launched.

SDK initialization

  • FAPI.init - SDK initialization. Must be called before calling any method (both when launching applications for the first time and when doing internal transitions across the frame).

In-app purchases

In-app ads

Social mechanics

Other game mechanics

Working with other OK services

Anonymous games

Working with REST API

Utility methods

Other features

API_callback

Methods from the FAPI.UI group don’t require the callback function to be passed. After the method is executed, a global function will be called, and the developer must realize it. The function must have the signature:

function API_callback(method, result, data);

Here:

  • method - the name of the method called
  • result - the result of the execution (“ok” if successful, “cancel” if the user canceled the action)
  • data - additional information, for example, for showInvite() – a list of IDs of invited friends, separated by commas, in the string format.