Fetching list view columns without using Metadata API in Salesforce can be tricky because the list view columns are not directly available via any standard object or SOQL query. However, you can use the ListView describe call from the REST API, which will give you the list view's columns along with other information.
Here's an example of how you might do this in Apex:
public class ListViewColumns {
public static void getListColumns() {
String sObjectApiName = 'Account'; // replace with your sObject API Name
String listViewId = '00BT0000001Kxmu'; // replace with your List View Id
HttpRequest req = new HttpRequest();
req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm()
+ '/services/data/v53.0/sobjects/'
+ sObjectApiName + '/listviews/'
+ listViewId + '/describe');
req.setMethod('GET');
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
Http http = new Http();
HttpResponse res = http.send(req);
System.debug(res.getBody());
}
}
The debug log will show the JSON response of the ListView describe call, which includes the columns in the list view.
Please note that this requires the user to have access to the list view and the sObject, and it involves a callout, so it can't be used in triggers or synchronous processes that don't allow callouts.