Skip to content
Snippets Groups Projects
badges.mdx 2.69 KiB
Newer Older
---
sidebar_position: 3
---
import { Tabs, Callout } from 'nextra/components'

# Badges

## Get SVG Badge

<Callout type="info">
  `GET /api/v1/repositories/{repositoryUrl}/badges/{badgeId}.svg[?timestamp=<unix_timestamp>]`
</Callout>

This endpoint gets parameterized with the repository URL and the badge ID. The repository URL is the URL of the repository that should 
be or was already scanned. The URL should be in the following format: `https://gitlab.opencode.de/zendis-repo-scanner`. 
**The URL must be URL encoded.** (`https%3A%2F%2Fgitlab.opencode.de%2Fzendis-repo-scanner`)

The badge ID is the title of the badge that should be returned. The badge ID can be one of the following:
- `MAINTENANCE`
- `SECURITY`
- `REUSED`

The timestamp parameter is optional. If it is provided, the endpoint will return the badge that is closest (but never in the future) to 
the given timestamp. If it is not provided, the endpoint will return the latest badge as a SVG image `image/svg+xml`.

This simplifies the integration of the badges into other elements like README files or websites.

## Get Badge Explanation

<Callout type="info">
  `GET /api/v1/repositories/{repositoryUrl}/badges/{badgeId}[?timestamp=<unix_timestamp>]`
</Callout>

This endpoint gets parameterized with the repository URL and the badge ID. The repository URL is the URL of the repository that should 
be or was already scanned.

The badge ID is the title of the badge that should be returned.

The endpoint will return the badge evaluation as JSON. The timestamp parameter is optional. If it is provided, the endpoint will return the 
badge that is closest (but never in the future) to the given timestamp. If it is not provided, the endpoint will return the latest badge 
evaluation. It is a subset of the whole SARIF response.

### Example Response

```json
{
  "badgeUrl": "https://img.shields.io/badge/maintenance-silver-lightgrey.svg",
  "badgeId": "MAINTENANCE",
  "badgeStatus": "silver",
  "badgeInformationUri": "https://gitlab.opencode.de/zendis-repo-scanner/badges/maintenance.json",
  "badgeExplanation": {
    "criteria": [
      {
        "description": "The average issue reaction time qualifies as silver (4 days, between 1 and 7 days).",
        "ruleId": "ISSUE_REACTION_TIME",
        "value": 4,
        "status": "silver",
      },
      {
        "description": "The bus factor qualifies as gold (3 contributors or more).",
        "ruleId": "BUS_FACTOR",
        "value": 3,
        "status": "gold",
      },
    ],
    "conclusion": "Based on the evaluation of the above criteria, this project is classified as Silver level maintenance."
  }
}
```

The currently provided badgeUrls serve only as an example. They will be dynamically generated in the future.

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.