So the REST API consists of a few endpoints that we provide that allow you to talk to PlayCanvas and do various things. One of those things is to download a web build. This is documented here:
http://developer.playcanvas.com/en/user-manual/api/download-app/
So the endpoint you have to use is https://playcanvas.com/api/apps/download
and the method you use must be POST
. More about methods here ( http://www.restapitutorial.com/lessons/httpmethods.html ). When you use POST
you must pass data in the form of JSON. The parameters you need to pass are documented in the endpoint’s documentation page.
Every time you call an endpoint you have to pass some Authorization details in the header. This must be in the form of Bearer access_token
where access_token is your personal token generated from the account page. So this header you use in your example is wrong:
Authorization: OrganisationName AuthCode
It should be
Authorization: Bearer access_token
So say we want to download a web build for project 99999 and we want to name the build My App
. My example access token is aNPXAa2JZGduUsynoIJwt5T2csxAfjB8
. With curl we could do:
curl -H "Authorization: Bearer aNPXAa2JZGduUsynoIJwt5T2csxAfjB8" -H "Content-Type: application/json" -X POST -d '{"project_id": 99999, "name": "My App"}' https://playcanvas.com/api/apps/download
This will return something like
{
"status": "running",
"messages": [],
"created_at": "2016-10-12T15:39:11.582000",
"modified_at": "2016-10-12T15:39:11.582000",
"data": {
"concatenate": false,
"target": "web",
"owner_id": 152329,
"scenes": [
"36532325"
],
"project_id": 99999,
"name": "My App"
},
"id": 2123212
}
The request we made started a download job which takes some time to complete (usually a few seconds). So we need to wait until the job is completed before we can download our build. The request above returned the job details as the result. You can poll the job by id
using our REST API until the job has status: complete
. For example in this case the job has id: 2123212
so we can poll it with curl like so:
curl -H "Authorization: Bearer aNPXAa2JZGduUsynoIJwt5T2csxAfjB8" https://playcanvas.com/api/jobs/2123212
This will return back the job data so let’s assume it’s completed by now so it would look something like this:
{
"status": "complete",
"messages": [],
"created_at": "2016-10-12T15:39:11.582000",
"modified_at": "2016-10-12T15:39:11.582000",
"data": {
"concatenate": false,
"name": "My App",
"scenes": [
"36532325"
],
"download_url": "url_to_zip_file_here",
"target": "web",
"project_id": 99999,
"owner_id": 152329
},
"id": 2123212
}
When the job is complete you’ll notice it has a download_url
in the data. You can use that URL to download your build.