Photoshop API

What is the Photoshop API?

The Photoshop API (Application Programming Interface) is a collection of web-based tools and protocols that enable developers to access and interact with Photoshop functionality via the internet. Developers can use the API to create applications and services that automate tasks, manipulate images and graphics, and integrate with other tools and services. The Photoshop API gives developers access to the same features as the desktop version of the software, such as opening and saving files, creating and modifying layers, and applying filters and effects. The API is typically accessed through web-based calls and responses, and it can be used to create web- or mobile-based applications, cloud services, and other tools that interact with Photoshop.

Integration with other Adobe products, such as Lightroom and Sensei services, is also supported by the Photoshop API. The Lightroom API gives developers access to Lightroom’s photo library and allows them to create custom workflows for editing, organizing, and sharing photos. The Sensei services API provides developers with a set of machine learning services that can be integrated into their applications, such as image recognition, natural language processing, and image manipulation. As a result, developers can combine the Photoshop API with the Lightroom API and the Sensei services API to create powerful and integrated solutions for photography and graphic design workflows.

To summarize the features:

  • Direct Actions – headless plugins that interface with Photoshop, the host OS, and the network, free of any UI.
  • Build Scalable Solutions
  • Photoshop and Lightroom’s machine learning tools and services leverage the Adobe® Sensei platform. The Photoshop APIs can supercharge any photo editing requirement at scale.

This is an example of how to use JavaScript and JQuery to interact with the Photoshop API web services:


// Authenticate with the Photoshop API
var clientId = "your_client_id";
var clientSecret = "your_client_secret";

var settings = {
  "async": true,
  "crossDomain": true,
  "url": "https://ims-na1.adobelogin.com/ims/exchange/jwt/",
  "method": "POST",
  "headers": {
    "content-type": "application/x-www-form-urlencoded"
  },
  "data": {
    "client_id": clientId,
    "client_secret": clientSecret,
    "jwt_token": "",
    "scope": "openid",
    "grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer"
  }
}

$.ajax(settings).done(function (response) {
  console.log(response);
  var accessToken = response.access_token;
  
  // Open a file in Photoshop
  var openSettings = {
    "async": true,
    "crossDomain": true,
    "url": "https://image.adobe.io/pie/psdService/document",
    "method": "POST",
    "headers": {
      "x-api-key": "your_api_key",
      "authorization": "Bearer " + accessToken,
      "content-type": "application/json"
    },
    "data": JSON.stringify({
      "document": "path/to/your/file.psd"
    })
  }
  
  $.ajax(openSettings).done(function (response) {
    console.log(response);
    var documentId = response.documentId;
    
    // Perform some action on the file
    var actionSettings = {
      "async": true,
      "crossDomain": true,
      "url": "https://image.adobe.io/pie/psdService/layer",
      "method": "POST",
      "headers": {
        "x-api-key": "your_api_key",
        "authorization": "Bearer " + accessToken,
        "content-type": "application/json"
      },
      "data": JSON.stringify({
        "documentId": documentId,
        "layerId": "your_layer_id",
        "action": "flatten"
      })
    }
    
    $.ajax(actionSettings).done(function (response) {
      console.log(response);
    });
  });
});