API Reference

Welcome to the Nucleus API, you can use this API to work with licenses and policies.

Would like to see something more? Let us know hello@nucleus.sh

Authentication

Nucleus expects for the API key to be included in all API requests to the server in a header that looks like the following:

Authorization: your_access_token

Example:

curl "api_endpoint_here"
    -H "Authorization: your_access_token"

You may also send it in the body of a POST request as the parameter token.

Analytics

/!\ This API and documentation is in beta for now, there might be breaking changes in the future

We will add more endpoints over time. If you need to fetch a specific data that isn't documented here, please let us know so we can help you.

Realtime data

Fetch the number of users using your app right now.

HTTP Request

GET https://nucleus.sh/app/:appId/analytics/realtime

It will return the number of users like this:

{
    "realtime": 23,
}

Quick glance data

Fetch the number of users, installs and more during the last 24 hours.

HTTP Request

GET https://nucleus.sh/app/:appId/analytics/quickglance

It will return the numbers like this:

{
    "realTime": 5,
    "installs": 9,
    "users": 29,
    "appStarts": 75
}

Daily app analytics data

The daily analytics data for your application.

You need to supply a date interval as timestamps.

HTTP Request

GET https://nucleus.sh/app/:appId/analytics

Parameter Optional Description
start required Timestamp for beginning of interval
end required Timestamp for end of interval
utcOffset optional Your timezone UTC offset (in minutes) so we can return the appropriate dates

It will return various data on your app like the following. Where each object contains a property for every day for the interval you supplied.

{
    "totalEvents": {},
    "usage": {},
    "newUsers": {},
    "activeUsers": {},
    "nonNewUsers": {},
    "hours": {},
    "platforms": {},
    "errors": {}, // Number of users
    "languages": {},
    "ram": {},
    "versions": {},
    "events": {},
    "countries": {}
}

Report events via HTTP

POST https://nucleus.sh/app/:appId/track

Parameter Optional Description
data required Array containing events objects

Useful if you want to report data from an app that isn't Electron based, or where you can't use the module.

You must post the data as a JSON object, containing a data array property. This array contains the events you want to report (you can report multiple events at the same time).

{
    "data": [{
        "event": String, // Name of the event
        "id": String, // OPTIONAL A random id for the event that will be returned when the query succeeds, can be used to make sure no events are reported two times.
        "userId": String, // A string to identify the user (could be his email)
        "machineId": String, // A hashed identifier of the machine
        "sessionId": Int, // A random 4-digits number that identifies the current session
        "platform": String, // Either 'win32', 'darwin' or 'linux'
        "osVersion": String, // The version of the OS
        "totalRam": Int, // The total number of RAM available, in GB
        "version": String, // Version of the app
        "language": String, // Locale of the user (i.e. 'en-US')
        "payload": {}, // Any additionnal data that you want to report along the event
    }]
}

If the requests succeeds it will reply with an array of the IDs of the events reported.

The first thing you need to report when the user opens the app is the event named init upon which most of the analytics relies on.

It tracks the actual use of the app.