Welcome to the Bugdar API documentation. This page will guide you on how to use the API to analyze GitHub pull requests and manage your integrations and tokens.
Integrate Bugdar with Slack to receive pull request analysis reports directly in your Slack channel. Set up a webhook URL in your user profile on Bugdar.
When a pull request is analyzed, Bugdar will automatically post a formatted report to the specified Slack channel.
To interact with the Bugdar API, you first need to obtain an API token. You can generate a token in the Web UI via your User Profile Page. Use the following endpoint to get your token:
POST /api/tokens
This endpoint requires basic authentication using your Bugdar username and password.
curl -u your_username:your_password -X POST https://bugdar.com/api/tokens
{"token": "YOUR_API_TOKEN"}
When you no longer need your API token or wish to generate a new one, you can revoke it using this endpoint:
DELETE /api/tokens
This endpoint requires token authentication using your existing API token.
curl -H "Authorization: Bearer YOUR_API_TOKEN" -X DELETE https://bugdar.com/api/tokens
204 No Content
Once you have obtained an API token, you can use it to run a pull request analysis. Use the following endpoint to run a pull request analysis:
POST /api/analyze/github-pr
This endpoint requires token authentication using your API token.
curl -X POST \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"url": "GITHUB_PR_URL", "prompt_id": "PROMPT_ID"}' \ https://bugdar.com/api/analyze/github-pr
{"diff_checksum": CHECKSUM, pr_id: PR_ID, report_content: ANALYSIS_REPORT, report_id: REPORT_ID}
Once you have obtained an API token, you can use it to run a pull request analysis background task. This returns the Job ID of the task. Analysis can be retrieved from Slack or Bugdar Analysis Page. Use the following endpoint to run a pull request analysis:
POST /api/analyze/github-pr-task
This endpoint requires token authentication using your API token.
curl -X POST \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"url": "GITHUB_PR_URL", "prompt_id": "PROMPT_ID"}' \ https://bugdar.com/api/analyze/github-pr-task
{"diff_checksum": CHECKSUM, pr_id: PR_ID, report_content: ANALYSIS_REPORT, report_id: REPORT_ID}
Use this endpoint to analyze pull requests that were merged within the last N days for a given GitHub repository. This can help in assessing the recent activity and security posture of the repository.
POST /api/analyze/github-merged-prs-last-n-days
This endpoint requires token authentication using your API token and accepts parameters for the organization, repository, number of days to look back, and the prompt ID for analysis criteria.
curl -X POST \ -H "Authorization: Bearer YOUR_API_TOKEN" \ -H "Content-Type: application/json" \ -d '{"org": "github_org", "repo": "github_repo", "days": N, "prompt_id": "PROMPT_ID"}' \ https://bugdar.com/api/analyze/github-merged-prs-last-n-days
[{"task_id": "TASK_ID_1"}, {"task_id": "TASK_ID_2"}, ...]
This endpoint returns a list of task IDs for the analysis jobs created for each pull request merged within the specified timeframe. These tasks process in the background, and their results can be obtained as they are completed.
Each analysis request involves processing the content you provide, which is measured in terms of 'tokens'. A token can be thought of as a piece of the content; for example, a word or a portion of a word. The total number of tokens gives an indication of the complexity and size of the content being analyzed.
The total tokens used in processing your request are charged at a rate of $0.12 per 1,000 tokens. This rate is applied to the total token count to calculate the final cost of the analysis. For example, if your request involves 500 tokens, the cost would be calculated as follows:
(500 / 1000) * $0.12
This method ensures that the cost directly reflects the amount of processing required for your specific analysis request.