API Documentation

Introduction

Welcome to the Ocugine Direct API documentation section. In this section you can learn how to work with Ocugine API and build your own awesome games faster.
Also you can see how to work with API and try to work with API Sandbox here.

Ocugine API Layer contain two ways for connection:

  • Direct API - you need to use your own REST API wrapper for your games;
  • Ocugine SDK - Ready-to-use wrappers for popular platforms. You can learn more here;

In this guide you will find basic information about the principles of Ocugine Direct API and about preparing for its use. If you have already worked with our API or with similar services from other platforms, and know which application you want to create, we recommend that you go to the appropriate section of the documentation.

API (application programming interface) is an intermediary between the application developer and any environment with which this application should interact. The API makes it easy to create code because it provides a set of ready-made classes, functions, or structures for working with existing data.

Methods and Objects

Ocugine Direct API — it is an interface that allows you to receive information from the Ocugine database and interact with all services via https requests to a special server. You do not need to know in detail how the database is organized, from which tables and fields of what types it consists of - it is enough that the API query “knows” about this. Query syntax and the type of data returned by them are strictly defined on the side of the service itself.

API Requests

Most requests to our platform are made through API. To work with any method or platform object, you should send a POST-request of the following form:

https://cp.ocugine.pro/api/OBJECT_NAME/METHOD_NAME/

Where:

  • OBJECT_NAME - the name of object from our list.
  • METHOD_NAME - the name of requested methods, available for this method. By default - init method.

Usage Example:

https://cp.ocugine.pro/api/utils/get_ua/

Ocugine API response - JSON object. You can deserialize our objects for models in your games. Response example:

{
    "complete": true,
    "message": "",
    "data": {
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36 OPR/63.0.3368.71"
    }
}

Where:

  • complete - an operation status (boolean). If complete = false - your request has error.
  • message - error message. If complete = true, message = null.
  • data - response data object.

So, for every API request, our services has basic response:

// THE BASIC RESPONSE MODEL
{
    complete: true,
    message: "",
    data: {}
}

Application Registration

In our example, the method /state/ was used, to call which it is enough just to specify its input parameters. But more often this will not be enough. You need to register your application to use all the features of the Ocugine Direct API.

How to create your first project (read this article).

After creating your project, you will be taken to the Ocugine Control Panel. Open the “Project Settings” tab in the menu on the left. You will see the "Application ID" field in which the number will be indicated, for example, 77814. This number is the application identifier, it is also APP_ID, CLIENT_ID, you will need it in your further work. In the same place you will find "Application Key" to work with your application. Typically, the "Application Key" is a string.

Under no circumstances should you pass the parameters of your application to third parties.

What's Next?

Now that you know about the principles of our API work, you can start studying the work with each object of the platform separately.