Skip to main content
POST
/
api
/
analysis
/
results
/
antipatterns
Get Anti-patterns Results
curl --request POST \
  --url https://api.codeant.ai/api/analysis/results/antipatterns \
  --header 'Content-Type: application/json' \
  --data '
{
  "repo": "owner/repository",
  "commit_id": "abc123def456",
  "access_token": "ghp_xxxxxxxxxxxx",
  "service": "github"
}
'
import requests

url = "https://api.codeant.ai/api/analysis/results/antipatterns"

payload = {
"repo": "owner/repository",
"commit_id": "abc123def456",
"access_token": "ghp_xxxxxxxxxxxx",
"service": "github"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
repo: 'owner/repository',
commit_id: 'abc123def456',
access_token: 'ghp_xxxxxxxxxxxx',
service: 'github'
})
};

fetch('https://api.codeant.ai/api/analysis/results/antipatterns', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.codeant.ai/api/analysis/results/antipatterns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'repo' => 'owner/repository',
'commit_id' => 'abc123def456',
'access_token' => 'ghp_xxxxxxxxxxxx',
'service' => 'github'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.codeant.ai/api/analysis/results/antipatterns"

payload := strings.NewReader("{\n \"repo\": \"owner/repository\",\n \"commit_id\": \"abc123def456\",\n \"access_token\": \"ghp_xxxxxxxxxxxx\",\n \"service\": \"github\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.codeant.ai/api/analysis/results/antipatterns")
.header("Content-Type", "application/json")
.body("{\n \"repo\": \"owner/repository\",\n \"commit_id\": \"abc123def456\",\n \"access_token\": \"ghp_xxxxxxxxxxxx\",\n \"service\": \"github\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.codeant.ai/api/analysis/results/antipatterns")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"repo\": \"owner/repository\",\n \"commit_id\": \"abc123def456\",\n \"access_token\": \"ghp_xxxxxxxxxxxx\",\n \"service\": \"github\"\n}"

response = http.request(request)
puts response.read_body
{
  "results": {
    "owner/repository/abc123def456/src/utils.py/anti_patterns.json": [
      {
        "line_number": 42,
        "endLine": null,
        "issue_text": "TODO: Implement timeout for requests",
        "type": "CODE_SMELL",
        "message-id": "W0511",
        "fixAvailable": false,
        "symbol": "fixme",
        "column": 9,
        "endColumn": null,
        "severity": "Minor",
        "context_code_block": "def fetch_data(url):\n    headers = {\"Authorization\": f\"Bearer {token}\"}\n    # TODO: Implement timeout for requests\n    response = requests.get(url, headers=headers)\n    if response.status_code == 200:\n        return response.json()\n    return None"
      }
    ]
  }
}
{
"error": "Access token invalid"
}
{
"error": "Error retrieving anti-patterns results"
}

Body

application/json
repo
string
required

Repository identifier (format varies by service)

Example:

"owner/repository"

access_token
string
required

Authentication token for the service

Example:

"ghp_xxxxxxxxxxxx"

service
enum<string>
required

Version control service provider

Available options:
github,
azuredevops,
gitlab,
bitbucket
Example:

"github"

commit_id
string

Git commit SHA or identifier. Either commit_id or branch is required. If both are provided, commit_id takes precedence.

Example:

"abc123def456"

branch
string

Git branch name. When provided without commit_id, the service resolves the latest commit from scan history for this branch. Either commit_id or branch is required.

Example:

"main"

gitlab_base_url
string

Base URL for the service (optional for GitHub, required for GitLab)

Example:

"https://gitlab.com"

Response

Anti-patterns results retrieved successfully

Anti-patterns response containing detected code smells and anti-patterns

results
object

Anti-patterns analysis results organized by file path

Example:
{
"owner/repository/abc123def456/src/utils.py/anti_patterns.json": [
{
"line_number": 42,
"endLine": null,
"issue_text": "TODO: Implement timeout for requests",
"type": "CODE_SMELL",
"message-id": "W0511",
"fixAvailable": false,
"symbol": "fixme",
"column": 9,
"endColumn": null,
"severity": "Minor",
"context_code_block": "def fetch_data(url):\n headers = {\"Authorization\": f\"Bearer {token}\"}\n # TODO: Implement timeout for requests\n response = requests.get(url, headers=headers)\n if response.status_code == 200:\n return response.json()\n return None"
}
]
}