Deepcode
Machine LearningGetting Started with DeepCode.AI Public API
DeepCode.AI is a state-of-the-art code review and analysis tool that uses AI to help developers quickly detect and fix security vulnerabilities, performance issues, and other bugs in their code.
DeepCode.AI offers a public API that allows developers to seamlessly integrate the platform's code analysis capabilities into their own workflows. In this blog post, we'll walk you through the basics of using DeepCode.AI's public API and provide some example code in JavaScript to get you started.
API Endpoint
DeepCode.AI's public API endpoint is located at https://www.deepcode.ai/api/v1
. All requests to the API must be authenticated with an API token, which can be generated by logging in to your DeepCode.AI account and navigating to the "API Tokens" section of the Settings page.
API Examples
Here are some examples of how to use the DeepCode.AI API in JavaScript:
Analyze a Repository
const repositoryUrl = 'https://github.com/deepcodeai/deepcode-vscode.git';
const apiToken = 'your-api-token-here';
fetch(`https://www.deepcode.ai/api/v1/analyze?repository_url=${encodeURIComponent(repositoryUrl)}`, {
headers: {
'Authorization': `Bearer ${apiToken}`
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
This code analyzes a GitHub repository with DeepCode.AI and logs the results to the console. Simply replace the repositoryUrl
and apiToken
variables with your own values to use with your own repository.
Get Analysis Results
const analysisId = '12345';
const apiToken = 'your-api-token-here';
fetch(`https://www.deepcode.ai/api/v1/analysis/${analysisId}/result`, {
headers: {
'Authorization': `Bearer ${apiToken}`
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
This code retrieves the analysis results for a previously analyzed repository from DeepCode.AI and logs them to the console. Replace analysisId
and apiToken
with your own values.
Get Issues
const analysisId = '12345';
const apiToken = 'your-api-token-here';
fetch(`https://www.deepcode.ai/api/v1/analysis/${analysisId}/issues`, {
headers: {
'Authorization': `Bearer ${apiToken}`
}
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
This code retrieves all issues found in a previously analyzed repository from DeepCode.AI and logs them to the console. Replace analysisId
and apiToken
with your own values.
Conclusion
In this blog post, we discussed the basics of using DeepCode.AI's public API and provided some example code in JavaScript to help you get started. With the help of DeepCode.AI's powerful code analysis capabilities, you can quickly and easily detect and fix bugs in your code, leading to faster, more reliable application development.