Artica Wiki

ActiveDebianSync Search packages via API

it includes a powerful package search feature similar to apt-file, allowing you to search for packages by name, description, or files they contain.

ActiveDebianSync includes a powerful package search feature similar to apt-file, allowing you to search for packages by name, description, or files they contain.

Features

Search feature provides:

Enable the package search feature in your config.json:

{
  "package_search_enabled": true,//Enable/disable the package search feature
  "sync_contents": true // Download Contents files for file-to-package search
}

Note: If sync_contents is false, file search functionality will be limited as Contents files won't be available.

Enabling Search After Initial Setup

If you initially had sync_contents: false and later change it to true, a background scheduler will automatically:

  1. Detect that Contents files are missing
  2. Download them from the configured Debian mirror
  3. Index them into the search database

This check runs every 15 minutes, so changes take effect without restarting the daemon.

API Endpoints

All search endpoints are available under /api/search/ and require API access (subject to IP filtering if configured).

Endpoint: GET /api/search
Search across package names, descriptions, and files.
 

Parameter Required Description
q Yes Search query
type No Search type: name, description, file, or empty for all
release No Filter by release (e.g., bookworm, trixie)
component No Filter by component (e.g., main, contrib)
architecture No Filter by architecture (e.g., amd64, arm64)
exact No Set to true or 1 for exact match
limit No Maximum results (default: 100)

Example: curl "http://127.0.0.1:9090/api/search?q=nginx&type=name&release=bookworm"

Response:

{
  "query": "nginx",
  "type": "name",
  "count": 15,
  "results": [
      {
          "package_name": "nginx",
          "version": "1.22.1-9",
          "description": "small, powerful, scalable web/proxy server",
          "section": "httpd",
          "release": "bookworm",
          "component": "main",
          "architecture": "amd64",
          "filename": "pool/main/n/nginx/nginx_1.22.1-9_amd64.deb",
          "match_type": "name"
      }
  ]
}


Endpoint: GET /api/search/file
Find packages containing a specific file path (similar to apt-file search).

Parameter Required Description
path or q Yes File path to search for
release No Filter by release
architecture No Filter by architecture
limit No Maximum results (default: 100)

Example: Find which package provides /usr/bin/vim curl : "http://127.0.0.1:9090/api/search/file?path=/usr/bin/vim"

Response:

{
  "file_path": "/usr/bin/vim",
  "count": 2,
  "results": [
      {
          "package_name": "vim",
          "version": "9.0.1378-2",
          "description": "Vi IMproved - enhanced vi editor",
          "release": "bookworm",
          "component": "main",
          "architecture": "amd64",
          "match_type": "file",
          "matched_file": "usr/bin/vim"
      }
  ]
}
 


Search packages by name only.

Endpoint: GET /api/search/package

Parameter Required Description
name or q Yes Package name to search
release No Filter by release
limit No Maximum results (default: 100)

Example: curl "http://127.0.0.1:9090/api/search/package?name=python3"
 


Search packages by description keywords.

Endpoint: GET /api/search/description

Parameter Required Description
desc or q Yes Keywords to search in descriptions
release No Filter by release
limit No Maximum results (default: 100)

Example: Find packages related to "web server": curl "http://127.0.0.1:9090/api/search/description?q=web%20server"
 


Package Files Listing: List all files contained in a package (similar to apt-file list).

Endpoint: GET /api/search/package-files

Parameter Required Description
package or name Yes Package name
release No Filter by release
architecture No Filter by architecture

Example: List all files in the nginx package curl "http://127.0.0.1:9090/api/search/package-files?package=nginx"  

Response:

{
  "package": "nginx",
  "count": 42,
  "files": [
      "etc/nginx/nginx.conf",
      "usr/sbin/nginx",
      "usr/share/doc/nginx/README.Debian",
      "usr/share/man/man8/nginx.8.gz"
  ]
}


Package Information

Get detailed information about a specific package, including its files.

Endpoint: GET /api/search/package-info

Parameter Required Description
package or name Yes Package name
release No Filter by release
architecture No Filter by architecture

Example:curl "http://127.0.0.1:9090/api/search/package-info?package=nginx&release=bookworm"

Response:

{
  "package": {
      "package_name": "nginx",
      "version": "1.22.1-9",
      "description": "small, powerful, scalable web/proxy server",
      "section": "httpd",
      "release": "bookworm",
      "component": "main",
      "architecture": "amd64",
      "filename": "pool/main/n/nginx/nginx_1.22.1-9_amd64.deb"
  },
  "files": [
      "etc/nginx/nginx.conf",
      "usr/sbin/nginx"
  ],
  "files_count": 42
}


Search Status

Get the status of the search index, including statistics and indexing progress.

Endpoint: GET /api/search/status

Example: curl "http://127.0.0.1:9090/api/search/status"

Response:

{
  "enabled": true,
  "status": "ready",
  "stats": {
      "total_packages": 65432,
      "total_files": 12345678,
      "last_indexed": "2024-01-15T10:30:00Z"
  },
  "index_status": [
      {
          "release": "bookworm",
          "component": "main",
          "architecture": "amd64",
          "packages_count": 32000,
          "files_count": 6000000,
          "last_indexed": "2024-01-15T10:30:00Z"
      },
      {
          "release": "bookworm",
          "component": "contrib",
          "architecture": "amd64",
          "packages_count": 1500,
          "files_count": 250000,
          "last_indexed": "2024-01-15T10:30:00Z"
      }
  ]
}

Usage Examples

Database/table Structure

The search feature uses an SQLite database stored alongside the configuration file (e.g., /etc/ActiveDebianSync/package_search.db).

packages: 
Stores package metadata

package_files: 
Stores file-to-package mappings

index_status: 
Tracks indexing progress

Automatic Indexing

Performance 

Troubleshooting