NodeCDN

API Documentation

Developers have full access to a REST api to manage the deployment of files, review sync status of cdn servers, and commit status.

Authentication

Authentication to the API is very simple. All end-points use basic HTTP Authentication, including a public and private key. All containers share the same public key with a separate private key.

Authentication assigns your container ID to all API endpoints.

File Sync

NodeCDN operates a file sync operation to a remote server which is controlled by a mod/modpack developer. These servers can be personal or provided by NodeCraft. The servers will connect to the developer's server via a non-root user and an SSH key.

Once connected, NodeCDN's system will start an rsync process to the master repository inside NodeCDN's system. Once processed and reviewed for changes, this will be pushed to all slave devices in our network within 2-5 minutes, depending on sizes of any modified files.

During this time, the API can be queried to get the status of each slave device, the master, and their current file head. The file head is a checksum hash of the file contents, calcuated based on the file names, sizes, and timestamps.

Routes

POST /commit

Starts the sync process to connect to the developer server and retrieve file changes. This request can take an extended period of time depending on the number of file changes. It's highly recommended you use the webhook or noReply if your system will not work well with long polling requests.

Request Variables
  • message String REQUIRED

    Commit message. Used to track what changes are being submitted.

  • webhook String

    Optional, URL to submit request to when the commit finalizes. The request will be a POST request with the same variables this request would otherwise.

  • noReply Boolean

    Optional, forces the system to reply instantly to compensate for system that can not account for timeout or long request. Will change the response to exclude any status or results of the requset.

  • delete Boolean

    Defaults to `true`. When the delete flag is assigned, the remote server will delete any files which do not match the source (developer server). This is recommended to be set to `true`.

Results
{
    "statusCode": 200,
    "success": true,
    "data": {
        "commit": {
            "status": "success",
            "message": "test",
            "author": "NodeCraft",
            "container": "atl",
            "data": {
                "progress": "0",
                "rate": "0.00 kB\/s",
                "remaining": "0:00:06",
                "report": {
                    "sent": "3,782",
                    "received": "5,069,268",
                    "rate": "596,829.41",
                    "speedup": "6,705.85"
                },
                "log": "receiving incremental file list\n"
            },
            "id": "527368293c0b24a3e2fef6c4c0e5002c"
        }
    }
}

GET /status

Get the current status of the master and slave servers. This will return a status for all devices that are updating their content as well as their current head.

Results
{
    "statusCode": 200,
    "success": true,
    "data": {
        "stats": {
            "Joe": {
                "status": "ready",
                "time": 1416205869,
                "head": "jJDOIWzPvlVKcZeLXE1TSRG0erCxVwXm"
            },
            "Sal": {
                "status": "offline",
                "time": 1416205866
            },
            "James": {
                "status": "ready",
                "time": 1416205861,
                "head": "jJDOIWzPvlVKcZeLXE1TSRG0erCxVwXm"
            },
            "Jon": {
                "status": "ready",
                "time": 1416205870,
                "head": "jJDOIWzPvlVKcZeLXE1TSRG0erCxVwXm"
            },
            "master": {
                "report": {
                    "received": 0,
                    "sent": 0,
                    "rate": 0,
                    "speedup": 0
                },
                "remaining": "calculating...",
                "status": "committing",
                "log": "",
                "rate": "0.00MB\/s",
                "progress": 0
            }
        }
    }
}

GET /commits

Get a list of the lastest heads successfully submitted. Each ID is a unique file head.

Results
{
    "statusCode": 200,
    "success": true,
    "data": {
        "commits": [
            {
                "author": "John Doe",
                "container": "containerName",
                "data": {
                    "progress": "0",
                    "rate": "0.00 kB\/s",
                    "remaining": "0:00:06",
                    "report": {
                        "rate": "597,274.94",
                        "received": "5,073,102",
                        "sent": "3,735",
                        "speedup": "6,695.83"
                    }
                },
                "id": "l6U7l0i0e49657Cx0L8vdJDiNuzEeX1Y",
                "message": "Custom commit message",
                "status": "success",
                "time": "2014-11-17T06:41:21.165Z"
            },
            {
                "author": "John Doe",
                "container": "containerName",
                "data": {
                    "progress": "0",
                    "rate": "6.21 MB\/s",
                    "remaining": "0:00:10",
                    "report": {
                        "rate": "1,706,724.89",
                        "received": "22,793,340",
                        "sent": "247,446",
                        "speedup": "1,475.37"
                    }
                },
                "id": "KE1UAOSryxi03oqjYLi28OHX1lNOOUSq",
                "message": "Custom commit message",
                "status": "success",
                "time": "2014-11-17T06:35:24.454Z"
            },
            {
                "author": "John Doe",
                "container": "containerName",
                "data": {
                    "progress": "0",
                    "rate": "0.00 kB\/s",
                    "remaining": "0:00:06",
                    "report": {
                        "rate": "598,388.82",
                        "received": "5,082,523",
                        "sent": "3,782",
                        "speedup": "6,689.03"
                    }
                },
                "id": "mQsVHnNIEi3CPgRljN8gUUZp3NFqpX3d",
                "message": "Custom commit message",
                "status": "success",
                "time": "2014-11-16T21:21:19.499Z"
            }
        ]
    }
}

GET /commits/:HEAD

Get a specific commit by the head / commit ID. This will include the rsync log.

Results
{
    "statusCode": 200,
    "success": true,
    "data": {
        "commit": {
            "author": "John Doe",
            "container": "containerName",
            "data": {
                "progress": "0",
                "rate": "0.00 kB\/s",
                "remaining": "0:00:06",
                "report": {
                    "rate": "597,274.94",
                    "received": "5,073,102",
                    "sent": "3,735",
                    "speedup": "6,695.83"
                }
            },
            "log": "receiving incremental file list\n",
            "id": "l6U7l0i0e49657Cx0L8vdJDiNuzEeX1Y",
            "message": "Custom commit message",
            "status": "success",
            "time": "2014-11-17T06:41:21.165Z"
        }
    }
}