Lgtm

LGTM API specification

The REST API for LGTM provides data so that you can customize how you integrate LGTM analysis into your workflow. It includes the following resources: * /…

Developer tools#openapi#developer-tools

Fork copies the collection into your workspace, without the publisher's secrets, so you can add your own key and send requests. Star saves it to your starred APIs (Account › Marketplace) and helps others find it.

Overview

The REST API for LGTM provides data so that you can customize how you integrate LGTM analysis into your workflow. It includes the following resources:

  • / (API root)—get version information or download the specification in OpenAPI format.
  • /projects (Projects)—list projects, get a summary of the current status for a project, or add new projects.
  • /analyses (Analyses)—get a summary of results, download all the alerts, or trigger analysis for a specific commit.
  • /codereviews (Code reviews)—trigger code review for a patch, and view the results.
  • /operations (Operations)—get information about long-running tasks, for example, analyses or code reviews that you've requested.
  • /snapshots (Snapshots)—download and upload databases representing a snapshot of a codebase.
  • /queryjobs (Query jobs)—submit queries to evaluate against existing projects, and download their results.
  • /system (System)—get information on the health or usage of the system.

For an overview and getting started topics, see API for LGTM.

Endpoints 29

API root

  • GETVersion information/Get the version information of this API.
  • GETAPI specification/openapiGet the specification of this API in OpenAPI format. This endpoint does not require an access token. This makes it easier for you to use the specification…

Projects

  • GETList projects/projects?limit=100&start=stringList all the projects the current user has authorization to view. A maximum of 100 projects are returned in each response. When further results are available,…
  • POSTAdd a project to LGTM/projects?repository=https://example.com&language=string&mode=full&commit=string&date=2024-01-01T00:00:00Z&worker-label=stringLGTM administrators can add a new project to LGTM by providing a repository URL. By default, LGTM tries to build and analyze the project in the same way as…
  • GETGet project by numeric identifier/projects/:project-idGet the latest summary for a specific project using the numeric project identifier. To find the LGTM identifier for a project, list all projects using the…
  • DELETEDelete project by numeric identifier/projects/:project-idDelete a project with a particular numeric project identifier. In addition to access to the project, administrative access to LGTM or the LGTM Enterprise…
  • GETGet configuration for a project identified by numeric identifier/projects/:project-id/settings/analysis-configuration?source=repositoryGet the latest configuration for a specific project using the numeric project identifier.
  • PUTSet the administrator configuration for a project identified by numeric identifier/projects/:project-id/settings/analysis-configurationSet the administrator configuration for a specific project using the numeric project identifier.
  • GETGet project by URL identifier/projects/:provider/:org/:nameGet the latest summary for a specific project using the project's URL identifier {provider}/{org}/{name}. To find the URL identifier for a project, view the…

Analyses

  • GETGet analysis summary/analyses/:analysis-idGet a summary of the analysis results for a specific analysis identifier. To find the analysis identifier for a commit, use the…
  • GETGet detailed alert information/analyses/:analysis-id/alerts?sarif-version=string&excluded-files=falseDownload all the alerts found by an analysis. Use the Accept: request header to specify the output media type as either CSV or SARIF: application/sarif+json:…
  • POSTRun analysis of a specific commit/analyses/:project-id?commit=string&language=stringTrigger the analysis of a specific commit to a project. If a previous attempt to analyze that commit failed, this triggers a fresh analysis. This is supported…
  • GETGet analysis summary for a specific commit/analyses/:project-id/commits/:commit-idGet a summary of the analysis results for a specific commit, or the latest commit, to a project. (For projects configured for sparse or upload analysis, only…

Code reviews

  • POSTRun code review for a patch/codereviews/:project-id?base=string&external-id=integer&review-url=string&callback-url=string&callback-secret=stringTrigger the code review of a patch. This is available for projects with Git repositories. Your request must include: * Identifier for the base commit * Patch…
  • GETGet results of code review/codereviews/:review-idGet the results of a code review using the review identifier for the task. When you request a code review, the response includes a task result URL of the…

Operations

  • GETGet operation status/operations/:operation-idTrack progress of a long-running operation using the operations identifier returned when you created the operation. For example, by triggering the analysis of…

Snapshots

  • PUTUpload snapshot/snapshots/uploads/:session-idUpload a database representing a snapshot of a codebase. The database is sent in one or more parts. Each part is sent in the request body. Use the POST…
  • POSTComplete snapshot upload session/snapshots/uploads/:session-idCompletes the database upload by closing the upload session, upgrading the database if appropriate, and scheduling analysis of that snapshot of the codebase.…
  • DELETEAbort database upload process/snapshots/uploads/:session-idAborts the specified upload session and deletes any uploaded parts. After the session is aborted it cannot be restarted. If any part uploads are in progress…
  • GETDownload a snapshot/snapshots/:project-id/:languageDownload a CodeQL database from LGTM, representing a snapshot of the codebase, to run queries in your IDE. This endpoint works for projects that have been…
  • POSTStart snapshot upload session/snapshots/:project-id/:language?commit=string&date=2024-01-01T00:00:00ZStart a session to upload an externally-built database (which represents a snapshot of a codebase) to a project on LGTM. This endpoint works for projects that…

System

  • GETGet a summary of the application's health/system/healthReturn an indication of whether the application is working as expected (up) or needs attention (down). \> The description and details fields are reported only…
  • GETGet the identifiers and descriptions of the usage metrics/system/metricsLGTM administrators can use this endpoint to list the usage metrics that are available to download.
  • GETGet the computed values of the specified metric/system/metrics/:metric-idLGTM administrators can download usage data using this endpoint. The response includes up to 1000 values for the specified metric and reports the date-time…

Query jobs

  • POSTRun a CodeQL query on one or more projects/queryjobs?language=string&project-id=0&projects-list=stringSubmit a query to run on one or more projects on LGTM. The query is included in the body of the request.
  • GETGet the status of a query job/queryjobs/:queryjob-idGet the status of a query job using the query job identifier for the task. When you create a query job, the response includes a task result URL of the form:…
  • GETProvide a summary of results for the projects in the query job/queryjobs/:queryjob-id/results?start=string&limit=100&filter=stringThis endpoint provides a summary of the results generated by completed query runs for each project specified in the the POST /queryjobs endpoint. For…
  • GETFetch the results of a query job for a specific project/queryjobs/:queryjob-id/results/:project-id?start=0&limit=100&nofilter=falseFetch the results for a specific project. The endpoint succeeds only if the query was successful, and returns a 404 error otherwise. By default, the endpoint…

Issues

  • GETGet detailed alert information for an issue/issues/:project-id/:alert-keyFetch the alert information for an issue in SARIF format.

API details

Base URL
https://lgtm.com/api/v1.0
Authentication
A bearer token in the Authorization header
Operations
29 operations on 23 pathsGET 19POST 6PUT 2DELETE 2
Main resources
Projects 7Snapshots 5Analyses 4Query jobs 4System 3API root 2Code reviews 2Issues 1Operations 1
Response formats
application/json application/sarif+json application/x-yaml text/csv
Description format
OpenAPI 3.0.1, API version v1.0
Listed from
APIs.guru OpenAPI Directory (CC0-1.0)
Source updated

How to test the LGTM API specification in Swastik Codes

  1. Open the APISelect “Fork & run in Swastik Codes” on this page. Sign in or create a free account if asked.
  2. Fork it into your workspaceChoose a workspace. You get your own copy of the LGTM API specification collection, without the publisher's secrets.
  3. Add your credentialsThis API uses A bearer token in the Authorization header. Add yours in the collection's variables or an environment; the requests already reference it.
  4. Send a requestPick an endpoint, for example “Version information” (GET /), and press Send. Check the response, add tests and run the whole collection with the runner.

Frequently asked questions

What is the LGTM API specification?

The REST API for LGTM provides data so that you can customize how you integrate LGTM analysis into your workflow. It includes the following resources: * /… It is listed under Developer tools and has 29 endpoints.

Who publishes the LGTM API specification?

It is listed from Lgtm's public API description (an OpenAPI document), not published by Lgtm on Swastik Codes. Anyone who controls lgtm.com can claim the profile by adding a DNS TXT record.

What is the base URL of the LGTM API specification?

Requests go to https://lgtm.com/api/v1.0. Endpoint paths are added to this base URL.

How do I authenticate with the LGTM API specification?

With A bearer token in the Authorization header.

How many endpoints does the LGTM API specification have?

29 operations on 23 paths (19 GET, 6 POST, 2 PUT, 2 DELETE). The largest groups are Projects, Snapshots, Analyses, Query jobs.

Is forking the LGTM API specification free?

Yes. Forking copies the collection into your workspace for free. It has been starred 0 times and forked 0 times.

Suggest an API

Tell us which public API is missing. We check it, then add it here with its endpoints when it has an OpenAPI (Swagger) description.