Is it possible to set the sitemap option programmatically using the module Simple XML Sitemap? On my drupal instance I have enabled the module called Simple XML Sitemap. The problem now is I want to toggle the option to index certain pages programmatically. I can't find out how. Can this be done?
There are API methods to alter stored inclusion settings and generate the sitemap programmatically. There is no documentation other than the documentation page and code documentation which is pretty complete. Here are the service methods which can be used to accomplish what you need:

getSetting()
saveSetting()
getSitemap()
generateSitemap()
getGeneratedAgo()
enableEntityType()
disableEntityType()
setBundleSettings()
getBundleSettings()
setEntityInstanceSettings()
getEntityInstanceSettings()
removeEntityInstanceSettings()
bundleIsIndexed()
entityTypeIsEnabled()
addCustomLink()
getCustomLinks()
getCustomLink()
removeCustomLink()
removeCustomLinks()


You can chain these methods like so:

\Drupal::service('simple_sitemap.generator')
  -&gt;saveSetting('remove_duplicates', TRUE)
  -&gt;enableEntityType('node')
  -&gt;setBundleSettings('node', 'page', ['index' =&gt; TRUE, 'priority' = 0.5])
  -&gt;removeCustomLinks()
  -&gt;addCustomLink('/some/view/page', ['priority' = 0.5])
  -&gt;generateSitemap();


I have just added the above information to the documentation page, we would appreciate anyone further contributing to it.