Public API

We are expanding the API with every release to make more analysis information available. Contact Codescene, and we are happy to share our detailed plans and get your feedback.

You can get the following information from the API:

Using CodeScene’s REST API

The REST API documentation URL

You can browse the REST API functions here CodeScene RestAPI Functions. Before trying any functionality, use the Authorize button then fill in the value with ‘Bearer <your_token>’ to authenticate.
The version in use is v2.

The REST API token

CodeScene lets you create a token intended to consume the API. Login then create a new token as illustrated in Fig. 166 and Fig. 167.
List Api tokens

Fig. 166 List Api tokens

Add Api token

Fig. 167 Add Api token

Api token

Fig. 168 Api token created

To consume the REST API, you need to authenticate by adding the http header 'Authorization: Bearer <your token>'.

Project endpoints

Projects list

 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects'

New Project

 curl -X POST --header 'Content-Type: application/json' --header 'Authorization: Bearer <token>' \
 --data "@./project.json" 'https://api.codescene.io/v2/projects/new'
  • Replace ./project.json with a valid a path to your project configuration.

  • Example of ./project.json

{
   "config": {
   "name" : "test",
   "repo-paths" : ["https://yourprovider.com/mycompany/myproject.git"],
   "developer-configuration" : 99
   }
}
  • name is optional, if missing CodeScene will use the project name from the first repository

  • the repo paths must contain only urls accessible by the user which created the token

  • developer-configuration is optional, replace 99 with a valid id taken from the developer settings list results.

Analysis List of a project

 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project-id}/analyses'
  • Replace {project-id} with a valid id taken from the project list results.

Single analysis details

Single analysis details using its id
 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project-id}/analyses/{analysis-id}'
  • Replace {project-id} with a valid id taken from the project list results.

  • Replace {analysis-id} with a valid id taken from the analysis list results.

Latest analysis details
 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project-id}/analyses/latest'
  • Replace {project-id} with a valid id taken from the project list results.

Files list from an analysis

File list in descending order based on order_by value for given analysis id
 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project-id}/analyses/{analysis-id}/files?page={page}&page_size={page_size}&order_by={order_by}'
  • Replace {project-id} with a valid id taken from the project list results.

  • Replace {analysis-id} with a valid id taken from the analysis list results.

  • Replace {page} with required page to return. If page parameter is omitted the default value is 1.

  • Replace {page_size} with the number of files to return for a page. If page_size parameter is omitted the default value is 100.

  • Replace {order_by} with one of the following values: “lines_of_code”, “change_frequency”, “number_of_defects”, “code_health” or “cost”. If order_by parameter is omitted the default value is “change_frequency”.

Files list in descending order based on order_by value for latest analysis
 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project-id}/analyses/latest/files?page={page}&page_size={page_size}&order_by={order_by}'
  • Replace {project-id} with a valid id taken from the project list results.

  • Replace {page} with required page to return. If page parameter is omitted the default value is 1.

  • Replace {page_size} with the number of files to return for a page. If page_size parameter is omitted the default value is 100.

  • Replace {order_by} with one of the following values: “lines_of_code”, “change_frequency”, “number_of_defects”, “code_health” or “cost”. If order_by parameter is omitted the default value is “change_frequency”.

Components list from an analysis

Components list using analysis id
 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project-id}/analyses/{analysis-id}/components'
  • Replace {project-id} with a valid id taken from the project list results.

  • Replace {analysis-id} with a valid id taken from the analysis list results.

Latest analysis components list
 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project-id}/analyses/latest/components'
  • Replace {project-id} with a valid id taken from the project list results.

Single components details from an analysis

Component details using analysis id
 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project-id}/analyses/{analysis-id}/components/{component-name}'
  • Replace {project-id} with a valid id taken from the project list results.

  • Replace {analysis-id} with a valid id taken from the analysis list results.

  • Replace {component-name} with a valid name taken from the components list results.

Latest analysis component detail
 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project-id}/analyses/latest/components/{component-name}'
  • Replace {project-id} with a valid id taken from the project list results.

  • Replace {component-name} with a valid name taken from the components list results.

Component file list from an analysis

Component file list in descending order based on order_by value for given analysis id
curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
'https://api.codescene.io/v2/projects/{project-id}/analyses/{analysis-id}/components/{component-name}/files?page={page}&page_size={page_size}&order_by={order_by}'
  • Replace {project-id} with a valid id taken from the project list results.

  • Replace {analysis-id} with a valid id taken from the analysis list results.

  • Replace {component-name} with a valid id taken from the component list results.

  • Replace {page} with required page to return. If page parameter is omitted the default value is 1.

  • Replace {page_size} with the number of files to return for a page. If page_size parameter is omitted the default value is 100.

  • Replace {order_by} with one of the following values: “lines_of_code”, “change_frequency”, “number_of_defects”, “code_health” or “cost”. If order_by parameter is omitted the default value is “change_frequency”.

Component files list in descending order based on order_by value for latest analysis
curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
'https://api.codescene.io/v2/projects/{project-id}/analyses/latest/components/{component-name}/files?page={page}&page_size={page_size}&order_by={order_by}'
  • Replace {project-id} with a valid id taken from the project list results.

  • Replace {component-name} with a valid id taken from the component list results.

  • Replace {page} with required page to return. If page parameter is omitted the default value is 1.

  • Replace {page_size} with the number of files to return for a page. If page_size parameter is omitted the default value is 100.

  • Replace {order_by} with one of the following values: “lines_of_code”, “change_frequency”, “number_of_defects”, “code_health” or “cost”. If order_by parameter is omitted the default value is “change_frequency”.

Delta Analyses List of a project

 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project-id}/delta-analyses'
  • Replace {project-id} with a valid id taken from the project list results.

Single delta analysis details

Single delta analysis details using its id
 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project-id}/delta-analyses/{delta-analysis-id}'
  • Replace {project-id} with a valid id taken from the project list results.

  • Replace {delta-analysis-id} with a valid id taken from the delta analysis list results.

Commit activity trend from an analysis

Commit activity trend for given analysis id
curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
'https://api.codescene.io/v2/projects/{project-id}/analyses/{analysis-id}/commit-activity'
  • Replace {project-id} with a valid id taken from the project list results.

  • Replace {analysis-id} with a valid id taken from the analysis list results.

Commit activity trend for latest analysis
curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
'https://api.codescene.io/v2/projects/{project-id}/analyses/latest/commit-activity'
  • Replace {project-id} with a valid id taken from the project list results.

Author statistics from an analysis

Author statistics for given analysis id
curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
'https://api.codescene.io/v2/projects/{project-id}/analyses/{analysis-id}/author-statistics'
  • Replace {project-id} with a valid id taken from the project list results.

  • Replace {analysis-id} with a valid id taken from the analysis list results.

Author statistics for latest analysis
curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
'https://api.codescene.io/v2/projects/{project-id}/analyses/latest/author-statistics'
  • Replace {project-id} with a valid id taken from the project list results.

Get Project Badge Status

CodeScene support the following badges: code-health, missed-goals, system-mastery

 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/projects/{project_id}/badges'
  • Replace {project_id} with a valid id taken from the project list results.

Update Project Badge Status

 curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' \
 --header 'Authorization: Bearer <token>' -d '{"code-health":true, "missed-goals": true ,"system-mastery": false}' \
 'https://api.codescene.io/v2/projects/{project_id}/badges'
  • Replace {project_id} with a valid id taken from the project list results.

Teams and Developers endpoints

Developer Settings list

 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/developer-settings'

Teams list

 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/developer-settings/{developer_setting_id}/teams'
  • Replace {developer_setting_id} with a valid id taken from the developer settings list results.

Create team

 curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' \
 --header 'Authorization: Bearer <token>' -d '{ "team_name": "my-new-team"}' \
 'https://api.codescene.io/v2/developer-settings/{developer_setting_id}/teams/new'
  • Replace {developer_setting_id} with a valid id taken from the developer settings list results.

Update team

 curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' \
 --header 'Authorization: Bearer <token>' -d '{ "team_name": "my-updated-team"}' \
 'https://api.codescene.io/v2/developer-settings/{developer_setting_id}/teams/{team_id}'
  • Replace {developer_setting_id} with a valid id taken from the developer settings list results.

  • Replace {team_id} with a valid id taken from the teams list results.

Delete team

 curl -X DELETE --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/developer-settings/{developer_setting_id}/teams/{team_id}'
  • Replace {developer_setting_id} with a valid id taken from the developer settings list results.

  • Replace {team_id} with a valid id taken from the teams list results.

Developer list

 curl -X GET --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/developer-settings/{developer_setting_id}/developers'
  • Replace {developer_setting_id} with a valid id taken from the developer settings list results.

Update developer

 curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/json' \
 --header 'Authorization: Bearer <token>' -d '{ "team_id": 12, "former_contributor": true, "exclude_from_all_analyses": true}' \
 'https://api.codescene.io/v2/developer-settings/{developer_setting_id}/developers/{developer_id}'
  • Replace {developer_setting_id} with a valid id taken from the developer settings list results.

  • Replace {developer_id} with a valid id taken from the developers list results.

  • Set the team_id to a valid id taken from teams list if you need to assign the current developer to that team.

  • The only updateable attributes of a developer are the team_id, former_contributor and exclude_from_all_analyses

  • The payload can contain any of the attributes or only some of them.

Delete developer

 curl -X DELETE --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/developer-settings/{developer_setting_id}/developers/{developer_id}'
  • Replace {developer_setting_id} with a valid id taken from the developer settings list results.

  • Replace {developer_id} with a valid id taken from the developers list results.

Remove Developer from Team

 curl -X DELETE --header 'Accept: application/json' --header 'Authorization: Bearer <token>' \
 'https://api.codescene.io/v2/developer-settings/{developer_setting_id}/developers/{developer_id}/team'
  • Replace {developer_setting_id} with a valid id taken from the developer settings list results.

  • Replace {developer_id} with a valid id taken from the developers list results.