Powered by Nodecraft

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 primary repository inside NodeCDN's system. Once processed and reviewed for changes, this will be pushed to all replica 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 replica device, the primary, and their current file head. The file head is a checksum hash of the file contents, calculated based on the file names, sizes, and timestamps.

Routes

POST https://api.nodecdn.net/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 return.

  • 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 request.

  • delete Boolean

    Defaults to true. When the delete flag is assigned, files on the remote server (NodeCDN) will be deleted if they do not exist on the the source (developer server). This is recommended to be set to true.

Results
{
	"code": "nodecdn.commit_success",
	"message": "Successfully retrieved request for commit.",
	"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 https://api.nodecdn.net/status

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

Results
{
	"code": "nodecdn.status",
	"message": "Successfully retrieved status information.",
	"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 https://api.nodecdn.net/commits

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

Results
{
	"code": "nodecdn.commits_success",
	"message": "Successfully listed commits.",
	"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 https://api.nodecdn.net/commits/:HEAD

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

Results
{
	"code": "nodecdn.commit_get_success",
	"message": "Successfully retrieved commit by given ID.",
	"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"
		}
	}
}

POST https://api.nodecdn.net/clear-cache

Clears the Cloudflare cache for given URLs. Images and things may be cached for multiple hours by default - this route can be used to clear the cache forcefully.

Request Variables
  • urls Array REQUIRED

    Array of URLs, relative to your container location. If your container was abc, and you wanted to clear https://download.nodecdn.net/containers/abc/image.png, you would send /image.png.

Results
{
	"code": "nodecdn.cloudflare_cache.clear.success",
	"message": "Successfully cleared Cloudflare cache for given URLs.",
	"success": true,
	"data": {
		"result": {
			"id": "e55de9236f8e337893174ba2a2fad"
		},
		"success": true,
		"errors": [],
		"messages": []
	}
}