Sahil Malik has written a blog post on how to "Get list of site collections using CSOM in Office365". It may help you.
Below is the code snippet from his blog:
var token = TokenHelper.GetAppOnlyAccessToken("00000003-0000-0ff1-ce00-000000000000", tenantAdminUri.Authority, null).AccessToken;
using (var clientContext = TokenHelper.GetClientContextWithAccessToken("https://yourtenant-admin.sharepoint.com", token))
{
var tenant = new Tenant(clientContext);
SPOSitePropertiesEnumerable spp = tenant.GetSiteProperties(0, true);
clientContext.Load(spp);
clientContext.ExecuteQuery();
foreach(SiteProperties sp in spp)
{
// you'll get your site collections here
}
}
Reference: http://blah.winsmarts.com/2014-4-Get_list_of_site_collections_using_CSOM_in_Office365.aspx
If you are looking for REST then using SharePoint Search Query REST Api you can achieve this, below is the sample code:
function searchSites(webUrl,success, failure) {
var url = webUrl + "/_api/search/query?querytext='contentclass:sts_site'";
$.ajax({
url: url,
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
success(data.d.query);
},
error: function (data) {
failure(data);
}
});
}
//print sites info
searchSites(_spPageContextInfo.webAbsoluteUrl, function(query){
var resultsCount = query.PrimaryQueryResult.RelevantResults.RowCount;
for (var i = 0; i < resultsCount;i++) {
var row = query.PrimaryQueryResult.RelevantResults.Table.Rows.results[i];
var siteUrl = row.Cells.results[6].Value;
console.log(JSON.stringify(siteUrl));
}
},
function(error){
console.log(JSON.stringify(error));
});
Reference: What is the REST endpoint URL to get list of site collections?