---
title: "Like /search, but aggregates per package"
method: GET
path: "/searchperpackage"
tags: ["search"]
---

# Like /search, but aggregates per package

`GET /searchperpackage`

The search results are currently sorted arbitrarily, but we intend to sort them by ranking eventually: https://github.com/Debian/dcs/blob/51338e934eb7ee18d00c5c18531c0790a83cb698/cmd/dcs-web/querymanager.go#L719

## Query parameters

- `query` string, required
- `match_mode` 'literal' | 'regexp'

## Response `200`

All search results

- PackageSearchResult[]
  - `package` string, required — The Debian source package for which up to 2 search results have been aggregated in `results`.
  - `results` SearchResult[], required
    - `package` string, required — The Debian source package containing this search result, including the full Debian version number.
    - `path` string, required — Path to the file containing the this search result, starting with `package`.
    - `line` integer, required — Line number containing the search result.
    - `context_before` string[] — Up to 2 full lines before the search result (see `context`).
    - `context` string, required — The full line containing the search result.
    - `context_after` string[] — Up to 2 full lines after the search result (see `context`).

## Other responses

- `403` — The x-dcs-apikey header was either not set at all, or contained an invalid (no longer valid?) API key. Please see https://codesearch.debian.net/apikeys/ for obtaining a key.

---

[API](https://skmtc.dev/debian/apis/debian-code-search.md) · [All operations](https://skmtc.dev/debian/apis/debian-code-search/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/debian/debian-code-search/revisions/671129ae43ea/schema)
