Top

Documentation

REST APIs

We are happy to announce APIs to interact with the system

Main idea behind the REST APIs is to allow you to build integration with your Continuous Integration workflow. So if you won't find the call you would need -- just let us know and we will figure something out.

First you need to generate your API key to interact with calls. This can be done on your profile's page. You will need to pass that key as 'x-api-key' header.

Index of calls

GET /api/result/{id} Get the results of the job (either Snapshot or Diff)
POST /api/project Create a new project
PUT /api/project/{id} Update existing project
POST /api/project/{id}/snapshot Create a snapshot
POST /api/project/{id}/compare_prod_stage Compare production environment with staging
POST /api/project/{id}/compare_prod_dev Compare production environment with development
POST /api/project/{id}/compare_stage_dev Compare staging environment with development
POST /api/project/{id}/compare_custom Compare custom environments. Can be used for Continuous Integration builds testing
POST /api/project/{id}/compare_itself Take snapshot of production environment and compare it with previous snapshot

 
 

Get results of existing the Snapshot or Diff job

POST https://backtrac.io/api/result/{id}

Where {id} is the id of your snapshot of diff.
Example bash command:

curl --header 'x-api-key: 48ca959376d1fa45b822eeee717f04b6' --request GET https://backtrac.io/api/result/54766

Sample of response:

{"status":"success","result":{"message":"Diff is completed","result":"Amount of differences: 100 %"}}

 

Create new project (up to index)

POST https://backtrac.io/api/project

Create a project with API. Currently we expose limited number of arguments. Please reach out if you need any additional parameters.

title title of the project
prod array with production environment settings
 
url URL of the environment
usename basic authentication username
pass basic authentication password
stage array with staging environment settings
 
url URL of the environment
usename basic authentication username
pass basic authentication password
dev array with development environment settings
 
url URL of the environment
usename basic authentication username
pass basic authentication password
automatic array settings for automated snapshots and diffs settings
 
schedule every X days to run snapshot. Available values: 0, 1, 2, 7, 14
diff whether to create a diff automatically. Available values: 0, 1
notification array settings notification settings
 
emails list of emails to send notifications. One per row

Example of the call

curl --header 'x-api-key: 48ca959376d1fa45b822eeee717f04b6' --request POST --data '{"prod":{"url":"https:\/\/drupal.org"},"stage":{"url":"https:\/\/staging.devdrupal.org","username":"drupal","pass":"drupal"},"automatic":{"schedule":2,"diff":0},"notification":{"emails":"info@backtrac.io\nyuri.gerasimov@gmail.com"}}' https://backtrac.io/api/project

Update existing project (up to index)

PUT https://backtrac.io/api/project/{id}

Structure of the arguments is exactly the same as for creating new project (above).
 

Create snapshot (up to index)

Create a snapshot for the project

POST https://backtrac.io/api/project/{id}/snapshot

Arguments to be passed as JSON encoded string in request body

env Environment for the snapshot. Valid values: "production", "staging", "development"

Example of the call:

curl --header 'x-api-key: 48ca959376d1fa45b822eeee717f04b6' --request POST https://backtrac.io/api/project/159/snapshot --data '{"env":"staging"}'

Response

{"status":"success","result":{"message":"Snapshot from production environment started.","url":"https:\/\/backtrac.io\/node\/5XXX9\/5f2be41XXX1de558d11c4bcf4f1ab557","nid":"5XXX9"}}

Compare predefined environments (up to index)

This call can be used for example when you are doing release to staging environment and would like to check it against production.

POST https://backtrac.io/api/project/{id}/{method}

Where {id} is ID of your project. On the project's page you can see the ID in URL (i.e. node/159 means project's id is 159).

{method} can be one of: compare_prod_stage, compare_prod_dev or compare_stage_dev. Each of them compare environments between themselves.

Here is example of the call written in bash:

curl --header 'x-api-key: 48ca959376d1fa45b822eeee717f04b6' --request POST https://backtrac.io/api/project/159/compare_prod_dev

 

Compare custom environments (up to index)

This is a bit more advanced version of previous call. It is aimed to assist you with comparing your dynamic environments (i.e. builds on your CI system).

Calls signature is:

POST https://backtrac.io/api/project/{id}/compare_custom

Arguments to be passed as JSON encoded string in request body

url1 URL of the first website to compare
sn1_name title of the snapshot for the first custom URL
url2 URL of the second website to compare
sn2_name title of the snapshot for the second custom URL
diff_name title of the Diff that will compare above two snapshots
login1 object of auth data for url1
 
url URL to login
usernameSelector Username Selector (CSS selector for the username form element, i.e. #edit-user-name)
passwordSelector Password Selector (CSS selector for the password form element, i.e. #edit-pass)
submitSelector Submit Selector (CSS selector for the submit button form element, i.e. #edit-submit)
username Username
password Password
login2 object of auth data for url2
 
url URL to login
usernameSelector Username Selector (CSS selector for the username form element, i.e. #edit-user-name)
passwordSelector Password Selector (CSS selector for the password form element, i.e. #edit-pass)
submitSelector Submit Selector (CSS selector for the submit button form element, i.e. #edit-submit)
username Username
password Password

Only url1 and url2 arguments are required.

Example of the call:

curl --header 'x-api-key: 48ca959376d1fa45b822eeee717f04b6' --request POST https://backtrac.io/api/project/159/compare_custom --data '{"url1":"http:\/\/ci.example.com\/build302","sn1_name":"build302","url2":"http:\/\/ci.example.com\/build304","sn2_name":"build304","diff_name":"build302 vs build304","login1":{"url": "http:\/\/ci.example.com\/build302\/user","usernameSelector":"#edit-name","passwordSelector":"#edit-pass","submitSelector":"#edit-submit","username":"admin","password":"pass"}, "login2": {"url": "http:\/\/ci.example.com\/build302\/user","usernameSelector":"#edit-name","passwordSelector":"#edit-pass","submitSelector":"#edit-submit","username":"admin","password":"pass"}}'

 
 

Monitor environment (up to index)

This call to be used when you would like to see what has been changed to particular environment. It will create a snapshot and compare it to the latest snapshot created on this environment.

Call's signature is:

POST https://backtrac.io/api/project/{id}/compare_itself

Argument to be passed as JSON encoded string in request body

env Name of the environment: production, staging, development.

Example of the call:

curl --header 'x-api-key: 48ca959376d1fa45b822eeee717f04b6' --request POST https://backtrac.io/api/project/159/compare_itself --data '{"env":"production"}'