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 [email protected]

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, please let us know.

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,
}

Daily app analytics data

The daily analytics data for your application.

You need to supply an 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.

{
    "quickData": {}, // 24h and realtime data 
    "uniqueIps": {}, 
    "totalEvents": {},
    "usage": {},
    "newUsers": {},
    "activeUsers": {},
    "nonNewUsers": {},
    "hours": {},
    "platforms": {},
    "errors": {}, // Number of users
    "languages": {},
    "versions": {},
    "events": {},
    "countries": {}
}

License Policies

A policy defines how a license can be used. For example, it allows you to configure its expiration delay, how many machines the license should work, etc.. and can be used inside your app to separate licenses types.

Get All Policies

This endpoint retrieves all licensing policies for a given app.

HTTP Request

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

It will return a JSON array structured like this:

[
    {
        "id": "basic",
        "duration": "365",
        "maxMachines": "5",
        "version": "0.8.1"
    },
    {
        "id": "lifetime",
        "duration": "0",
        "maxMachines": "0",
        "version": "all"
    }
]

Create a policy

HTTP Request

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

Body Parameters

Parameter Optional Description
id required The id of the new policy
maxMachines optional Maximum number of machines the license will be allowed on (0 for no limits)
versionValidity optional On which version should the license be working ('all' )
durationValidity optional For how many days the licenses will be valid (0 for always)

Delete a policy

Completely remove a policy. Licenses created with the policy will keep working under their policies at the time of their creation.

HTTP Request

DELETE https://nucleus.sh/app/:appId/policy/:policyId

Licenses

Get All Licenses

This endpoint retrieves all licenses for a given app.

HTTP Request

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

This will return a JSON array structured like this:

[
    {
        "id": "license_id",
        "key": "eozUYGifqgoiZefjHDiz",
        "status": "active",
        "userEmail": "[email protected]",
        "policy": "basic",
        "created": "2018-02-13",
        "expire": "0"
    }
]

Create a license

This is the main endpoint. It should be used on your server to create licenses for your users after they paid.

HTTP Request

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

Body Parameters

Parameter Optional Description
policy required The policy you want to apply to the license
userEmail optional Email of the user who bought the license

If successfull, it will return the newly created license objetc.

Get a license

HTTP Request

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

:license can either be directly the license or its id.

It will return a license object looking like:

{
    "id": "license_id",
    "key": "eozUYGifqgoiZefjHDiz",
    "status": "active",
    "userEmail": "[email protected]",
    "policy": "basic",
    "created": "2018-02-13",
    "expire": "0"
}

Update a license status

This can be used to remotely disable a license.

HTTP Request

PUT https://nucleus.sh/app/:appId/license/:licenseId

Body Parameters

Parameter Optional Description
status optional Set to disabled to disable the license or active to reenable it

Delete a license

Completely delete a license. It won't work anymore and won't show up in your dashboard. You should prefeer to instead disable it in case you want to re-use it later.

HTTP Request

DELETE https://nucleus.sh/app/:appId/license/:licenseId