The Spatial Analysis service contains a number of tasks that allow you to perform common spatial analyses on your data. These tasks are also available as tools in the portal Map Viewer. These tools allow end-users to easily perform analysis against hosted layers as well as other layers they have access to. To learn more about accessing these tasks using Map Viewer, see the help topic Perform analysis. Note that in some cases, the Spatial Analysis REST API has more functionality that is not exposed in Map Viewer.
An overview of the available tasks can be found in the ArcGIS for Developers website help or in the Portal for ArcGIS installed ArcGIS Services REST API reference.