I'm wondering if there is a way for a plugin to install other plugins directly. That means, I provide an interface for the user to click multiple plugins and download and install them directly to wp-content/plugins.
Basically imagine a marketplace plugin within wordpress where users can purchase plugins FROM a plugin and install directly into their site.
I would like to find out the API or any ideas on how to achieve the installation/upgrade.
You can take a look at TGM-Plugin-Activation plugin. It should give you good starting point. As written in the documentation:
TGM Plugin Activation is a PHP library that allows you to easily
require or recommend plugins for your WordPress themes (and plugins).
It allows your users to install and even automatically activate
plugins in singular or bulk fashion using native WordPress classes,
functions and interfaces. You can reference pre-packaged plugins,
plugins from the WordPress Plugin Repository or even plugins hosted
elsewhere on the internet.
Yes, this is possible, but there isn't really any magic API for it. Because WordPress scans the plugins folder for plugins, installing a new plugin is simply a matter of writing the files to the plugins folder, and uninstalling is just deleting the files from the folder.
A useful tool to do this is: WP-CLI - WordPress Command Line Interface. You can list all plugins, activate, deactive, install, uninstall, and/or update one or more plugins using a script. A huge timesaver.