It is possible using the details from Salesforce Metadata Api/ Tooling Api to build changesets to retrieve and modify the contents of a change set via the Metadata API.
However, the whole process depends on knowing the "Change Set Name" that can then be used as the Package Name against the Metadata API.
Is there a programmatic way to discover the package names of the changesets that exist in an org?
Ideally this would be an official API.
See also, Salesforce Idea: Expose the native change sets via an API
changeSetId.getSObjectType().getDescribe().getName();
, it seems the API name of changeset isDevelopmentPackageVersion
and keyPrefix is `0A2'. I tried using SOQL in rest as well as tooling API, it seems SF has not exposed that object yet. Surprisingly if you try instancesf.com/0A2 , it opes up packages tab.