Setka Editor API Integration Integration with Style Manager

Integration with Style Manager

Before you start an API integration process, please, make sure that integration fields are activated and you have submitted URL's in the Integration settings of your account:

Editor config url – to receive the latest Setka Editor version and updates of the post styles you create in the Style Manager.

Company status url  – contains subscription details: status of payment, end of the trial period, etc.

Server status url – we use it to check if integration completed correctly or not.

Initial CMS synchronization –> Setka Editor

The latest version of the API documentation is available at: https://editor.setka.io/docs/api2/index.html

Ruby on Rails Examples: https://github.com/setkaio/grid-editor-integration

For correct initialization of the editor it is necessary to pass a set of parameters from the JSON file to editor. The link to JSON will come in response to the "initial synchronization" request. JSON needs to be parsed. The resulting response is transferred to the initialization function of the editor on the post creation page

Master domain: https://editor.setka.io.

GET https://editor.setka.io/api/v1/custom/builds/current

{
  "plugins": [
    {
      "url": "https://ceditor.setka.io/public.js",
      "filetype": "js",
      "md5": "asdfasdfasdf"
    }
  ],
  "theme_files": [
    {
      "id": 1,
      "url": "https://ceditor.setka.io/theme.min.css",
      "filetype": "css",
      "md5": "asdfasdfasdf"
    },
    {
      "id": 1,
      "url": "https://ceditor.setka.io/theme.json",
      "filetype": "json",
      "md5": "asdfasdfasdf"
    }
  ],
  "content_editor_files": [
    {
      "id": 1,
      "url": "https://ceditor.setka.io/editor.min.css",
      "filetype": "css",
      "md5": "asdfasdfasdf"
    },
    {
      "id": 1,
      "url": "https://ceditor.setka.io/editor.min.js",
      "filetype": "js",
      "md5": "asdfasdfasdf"
    }
  ]
}

Information on Setka Editor –> CMS updates and creation of Setka Editor –> CMS snippets (Edit editor config url)

Information on Setka Editor –> CMS updates and creation of Setka Editor –> CMS snippets (Edit editor config url)

There are 2 options for storing and processing the resources received from the Setka Editor:

  • To store received links to resources in the database and to dynamically connect them to the post editing and post view pages. After requesting an update, change the links to new ones.
  • Download files from links and put in the public directory of the project. Statically assign the path to the files on the necessary pages. After requesting an update, download new versions and replace old files.

CSS file themes needs to be connected in 2 places: 1. post creation/editing page and 2. post view page.

JS file plugins needs to be connected in 2 places: 1. post creation/editing page and 2. post view page.

JSON file themes, JS and CSS editor files needs to be connected at 1 place –post creation/editing page.

Public.js. The JSON file received from File Manager contains a parameter config.public_js_url. This is a link to JS file public.js, which needs to be connected to the external pages of the website to make animation and galleries work. The link to JS file public.js will change with every JSON update, so every time you press Style Manager, you need to update this link.

 

Update data (From Setka Editor to client CMS)

POST /<your_custom_url> 

{
  "token": "123456",
  "data": {
    "plugins": [
      {
        "url": "https://ceditor.setka.io/public.js",
        "filetype": "js",
        "md5": "asdfasdfasdf"
      }
    ],
    "theme_files": [
      {
        "id": 1,
        "url": "https://ceditor.setka.io/theme.min.css",
        "filetype": "css",
      },
      {
        "id": 1,
        "url": "https://ceditor.setka.io/theme.json",
        "filetype": "json",
        "md5": "asdfasdfasdf"
      }
    ],
    "content_editor_files": [
      {
        "id": 1,
        "url": "https://ceditor.setka.io/editor.min.css",
        "filetype": "css”,
        "md5": "asdfasdfasdf"
      },
      {
        "id": 1,
        "url": "https://ceditor.setka.io/editor.min.js",
        "filetype": "js",
        "md5": "asdfasdfasdf"
      }
    ]
  }
}

Create snippet (From client CMS to Setka Editor API)

POST /api/v1/custom/snippets 

{
  "token": "123456",
  "theme_id": 1,
  "snippet": {
    "name": "Snippet name",
    "code": "<html>snippet markup</html>"
  }
}

API Errors

HTTP/1.1 401 Unauthorized

{
  "error": "Not authorized!"
}

HTTP/1.1 403 Forbidden (CompanyPaymentError)

{
  "error": "There is a problem with payment. Please, check your payment settings and/or contact us!"
}

HTTP/1.1 403 Forbidden (CompanyExpiredError)

{
  "error": "Your company must be activated!"
}

HTTP/1.1 422 UnprocessableEntity

{
  "errors": {
    "code": ["can't be blank"],
    "name": ["can't be blank"]
  }
}

You are to respond 200 to our requests to the following links:

Subscription information

POST /<your_custom_url_2>

Content-Type: application/json
  {
    token: ,
    data: {
      company_status: ,
      payment_status: ,
      active_until: 
    }
  }

Client information

POST <url>

Content-Type: application/json
  {
    token: <company_token>
  }

Response:

Code: 200

{
status: "The token is valid.",
  content_editor_version: "<editor_version_that_is_currently_installed_in_your_system>"
}

// content_editor_version = which version the client is using.

In all of the above methods, links are given to uncompressed resources. CDN also distributes compressed versions. You can receive them in two ways:

  • Add an extension to the .gz link. For example: https://ceditor.setka.io/editor.min.js.gz
  • Apply for resources with a special header Accept-Encoding. For example: curl -H “Accept-Encoding: gzip” https://ceditor.setka.io/editor.min.js

To learn more about the Editor.js initialization, click here.

Custom integration: