REST API endpoint to use in Add-ins:<appweburl>/_api/SP.AppContextSite(@target)/web/parentweb?$select=Title&@target=<hostweburl>
Embed Code Snippet
The following code snippet can be added to a SharePoint page or in the content editor web part as a script. This example used to retrieve the parent website of the current site and its title property. If you are in a top-level site, the REST url returns the empty information.
The following code snippet is used in SharePoint Add-in to retrieve the parent website information and displays the parent website title.