getOrgDomainUrl() can be used in Salesforce Apex to get your org URL.
getCurrentRequestUrl() can used in Salesforce Apex to get the URL of an entire request on a Salesforce instance.
Sample Code:
System.debug(
URL.getOrgDomainUrl()
);
System.debug(
URL.getCurrentRequestUrl()
);