Download REST api at specific checkpoint

Hey all,

I feel like I’ve done this before, but I can’t work out if something has changed, or I was doing it incorrect all along, but we’re using the rest api to download the latest checkpoint of a project by first getting the required branch using /projects/${project_id}/branches. This gives us a checkpoint for the branch, something along the lines of the following;

{ latestCheckpointId: '0e542s3c-de9c-4214-8159-6fg43435th59' }

Then we take the first part of the id up to the ‘-’ and use that to construct a download request using { version: ‘0e542s3c’ } in this scenario. This all works correctly, no errors are raised and we eventually get a download link, however once we download the zip it seems to contain the current working state of the project and not the state at the given checkpoint. So any files that we’re added or changed since the checkpoint are also included.

The documentation isn’t totally clear on how the version parameter should be structured other than it should me a max of 20 characters. Could I potentially be making a wrong assumption about the version parameter and it therefore just downloads the latest project contents? Any help would be awesome

Which end point are you using for download?

This one and then using the job endpoint to verify completion${jobid}

AFAIK, that API never supported the checkpoint id so I have no idea how it worked before if it did?

I thought it was the version parameter of the download endpoint Apps - Download app | Learn PlayCanvas

That’s the version of the published build (eg 1.1.0)

Aha, that would explain it. I totally misunderstood what that parameter was. So I guess without a valid version it just gets whatever the latest state of the project is? I guess a follow up question would be, is there a way to get the latest published build number from one of the api endpoints?

That version param is the same as this textfield in the editor

It’s just a string so if it’s empty, it will just be an empty string/version.

This endpoint will give you the build details of the build that is marked to be used for the permalink: Apps - Get primary app | Learn PlayCanvas

Whereas this endpoint, will give you a list of all the builds: Apps - Get project apps | Learn PlayCanvas

Neither of them returns the URL for build annoyingly, but we have a feature request to add this information: Add publish URL to the primary and project app REST API · Issue #894 · playcanvas/editor · GitHub

Thanks for the info @yaustar. So the primary build can only be set when you publish to playcanvas right? It can’t be set just for a build?