# Get insight scores

GET https://app.launchdarkly.com/api/v2/engineering-insights/insights/scores

Return insights scores, based on the given parameters. This data is also used in engineering insights metrics views.

Reference: https://launchdarkly.com/docs/api/insights-scores-beta/get-insights-scores

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: LaunchDarkly REST API
  version: 1.0.0
paths:
  /api/v2/engineering-insights/insights/scores:
    get:
      operationId: get-insights-scores
      summary: Get insight scores
      description: >-
        Return insights scores, based on the given parameters. This data is also
        used in engineering insights metrics views.
      tags:
        - subpackage_insightsScoresBeta
      parameters:
        - name: projectKey
          in: query
          description: The project key
          required: true
          schema:
            type: string
            format: string
        - name: environmentKey
          in: query
          description: The environment key
          required: true
          schema:
            type: string
            format: string
        - name: applicationKey
          in: query
          description: Comma separated list of application keys
          required: false
          schema:
            type: string
            format: string
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Insight score response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InsightScores'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationFailedErrorRep'
        '401':
          description: Invalid access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedErrorRep'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ForbiddenErrorRep'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitedErrorRep'
servers:
  - url: https://app.launchdarkly.com
  - url: https://app.launchdarkly.us
components:
  schemas:
    UnixMillis:
      type: integer
      format: int64
      title: UnixMillis
    InsightPeriod:
      type: object
      properties:
        startTime:
          $ref: '#/components/schemas/UnixMillis'
          description: The start time of the period
        endTime:
          $ref: '#/components/schemas/UnixMillis'
          description: The end time of the period
      required:
        - startTime
        - endTime
      title: InsightPeriod
    InsightsMetricScoreIndicator:
      type: string
      title: InsightsMetricScoreIndicator
    InsightsMetricIndicatorRange:
      type: object
      properties:
        min:
          type: integer
          description: The minimum value for the indicator range
        max:
          type: integer
          description: The maximum value for the indicator range
      required:
        - min
        - max
      title: InsightsMetricIndicatorRange
    InsightsMetricScore:
      type: object
      properties:
        score:
          type: integer
          description: The score for the metric
        aggregateOf:
          type: array
          items:
            type: string
          description: The keys of the metrics that were aggregated to calculate this score
        diffVsLastPeriod:
          type: integer
        indicator:
          $ref: '#/components/schemas/InsightsMetricScoreIndicator'
          description: The indicator for the score
        indicatorRange:
          $ref: '#/components/schemas/InsightsMetricIndicatorRange'
          description: The indicator range for the score
        lastPeriod:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The score for the metric in the last period
      required:
        - score
        - indicator
        - indicatorRange
      title: InsightsMetricScore
    InsightGroupScores:
      type: object
      properties:
        overall:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The overall score for the insight group
        deploymentFrequency:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The deployment frequency score for the insight group
        deploymentFailureRate:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The deployment failure rate score for the insight group
        leadTime:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The lead time score for the insight group
        impactSize:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The impact size score for the insight group
        experimentationCoverage:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The Experimentation coverage score for the insight group
        flagHealth:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The flag health score for the insight group
        velocity:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The velocity score for the insight group
        risk:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The risk score for the insight group
        efficiency:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The efficiency score for the insight group
        creationRatio:
          $ref: '#/components/schemas/InsightsMetricScore'
          description: The creation ratio score for the insight group
      required:
        - overall
        - deploymentFrequency
        - deploymentFailureRate
        - leadTime
        - impactSize
        - experimentationCoverage
        - flagHealth
        - velocity
        - risk
        - efficiency
      title: InsightGroupScores
    Link:
      type: object
      properties:
        href:
          type: string
          description: The URL of the link
        type:
          type: string
          description: The type of the link
      title: Link
    InsightScores:
      type: object
      properties:
        period:
          $ref: '#/components/schemas/InsightPeriod'
          description: The time period for the scores
        lastPeriod:
          $ref: '#/components/schemas/InsightPeriod'
          description: The time period for the scores in the last period
        scores:
          $ref: '#/components/schemas/InsightGroupScores'
          description: The scores for the insight groups
        _links:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/Link'
          description: The location and content type of related resources
      required:
        - period
        - lastPeriod
        - scores
      title: InsightScores
    FailureReasonRep:
      type: object
      properties:
        attribute:
          type: string
          description: The attribute that failed validation
        reason:
          type: string
          description: The reason the attribute failed validation
      required:
        - attribute
        - reason
      title: FailureReasonRep
    ValidationFailedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
        errors:
          type: array
          items:
            $ref: '#/components/schemas/FailureReasonRep'
          description: List of validation errors
      required:
        - code
        - message
        - errors
      title: ValidationFailedErrorRep
    UnauthorizedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: UnauthorizedErrorRep
    ForbiddenErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: ForbiddenErrorRep
    RateLimitedErrorRep:
      type: object
      properties:
        code:
          type: string
          description: Specific error code encountered
        message:
          type: string
          description: Description of the error
      required:
        - code
        - message
      title: RateLimitedErrorRep
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

```

## SDK Code Examples

```python
import requests

url = "https://app.launchdarkly.com/api/v2/engineering-insights/insights/scores"

querystring = {"projectKey":"projectKey","environmentKey":"environmentKey"}

headers = {"Authorization": "<apiKey>"}

response = requests.get(url, headers=headers, params=querystring)

print(response.json())
```

```javascript
const url = 'https://app.launchdarkly.com/api/v2/engineering-insights/insights/scores?projectKey=projectKey&environmentKey=environmentKey';
const options = {method: 'GET', headers: {Authorization: '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://app.launchdarkly.com/api/v2/engineering-insights/insights/scores?projectKey=projectKey&environmentKey=environmentKey"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("Authorization", "<apiKey>")

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

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

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://app.launchdarkly.com/api/v2/engineering-insights/insights/scores?projectKey=projectKey&environmentKey=environmentKey")

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

request = Net::HTTP::Get.new(url)
request["Authorization"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://app.launchdarkly.com/api/v2/engineering-insights/insights/scores?projectKey=projectKey&environmentKey=environmentKey")
  .header("Authorization", "<apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://app.launchdarkly.com/api/v2/engineering-insights/insights/scores?projectKey=projectKey&environmentKey=environmentKey', [
  'headers' => [
    'Authorization' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://app.launchdarkly.com/api/v2/engineering-insights/insights/scores?projectKey=projectKey&environmentKey=environmentKey");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://app.launchdarkly.com/api/v2/engineering-insights/insights/scores?projectKey=projectKey&environmentKey=environmentKey")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```