You might not know this but Forge already has an API, it’s just not a documented and feature complete one. Open up your dev tools and inspect the web requests being sent while you do various stuff on Forge.
Marcel Pociot published a new package called Blacksmith (great name Marcel) that can make calls to that API. Here are a few code examples taken from the readme:
$activeServers = $blacksmith->getActiveServers(); $server = $blacksmith->getServer(1); $sites = $server->getSites(); $newSite = $server->addSite($site_name, $project_type = 'php', $directory = '/public', $wildcards = false); $jobs = $server->getScheduledJobs(); $newJob = $server->addScheduledJob($command, $user = 'forge', $frequency = 'minutely');
Very cool stuff. Because the Forge API doesn’t include a method to login, the package will under the hood just submit a filled in login form.
An official API for Forge has been on my wishlist for quite some time. Because Forge’s code base already includes an API my guess is that it wouldn’t be too work to grow it in to a full, publicly available one. Though I surely cannot read Taylors mind, I think that if there were some more indications that a Forge API would be used by enough people, there’s a higher chance that an official API would be built. I think the only reason why the API hasn’t been built yet is because not enough people are asking for it. It makes sense for Taylor to only work on things that would actually be used. So if you are using Forge and do want an official API go ahead and star the BlackSmith package on GitHub and make some noise about it.