Retrieving latest artifacts for a specific branch via API?

I confirmed this wasn’t an issue with my account; it appears the CircleCI API v1 artifacts endpoint clears the artifacts out as soon as the job is re-triggered. The filter=completed flag won’t work for an active branch (until it’s finished running and isn’t stomped on again)

Since we have multiple developers running builds on at any given time, the artifacts endpoint is useless for my use case.

As mentioned above; graphql api is still unstable/in-beta and v2 isn’t really clear on how to traverse down to get a job ID for the latest completed run for a branch but hopefully the API will support this at some point (you can’t currently list all jobs + filter w/ v2)

Google Chrome 2024-12-24 09.56.47

If you’re still wondering “how do i get CircleCI artifacts for a given branch or commit”, I think I found a stable enough workaround: You can use the v1 project API:

https://circleci.com/api/v1.1/project/gh/:username:/:repo:?filter=success

Once you retrieve that, you can loop thru each of those top level objects and find the matching:

  1. status (success or completed, not sure of difference?)
  2. workflowsjob_name
  3. branch or vcs_revision

Once you’ve pulled those top level objects out of that list, you can pull the workflowsjob_id values out, then use the v2 API linked above (or if your downloads aren’t really complex you can download the artifact directly from output.circle-artifacts.com)