Skip to main content
GET
/
api
/
watched-directories
{
  "status": "<string>",
  "data": {
    "total_directories": 123,
    "directories": [
      {
        "path": "<string>",
        "file_count": 123,
        "indexed_count": 123,
        "failed_count": 123,
        "status": "<string>",
        "added_at": "<string>"
      }
    ]
  }
}
Retrieve a list of all directories currently being watched and indexed by CosmaSense.

Request

No parameters required.

Request Example

cURL
curl http://localhost:60534/api/watched-directories
Python
import requests

response = requests.get('http://localhost:60534/api/watched-directories')
directories = response.json()['data']['directories']

for dir in directories:
    print(f"{dir['path']}: {dir['file_count']} files")
JavaScript
const response = await fetch('http://localhost:60534/api/watched-directories');
const data = await response.json();

data.data.directories.forEach(dir => {
  console.log(`${dir.path}: ${dir.file_count} files`);
});

Response

status
string
Status of the request: success or error
data
object

Response Example

200 Success
{
  "status": "success",
  "data": {
    "total_directories": 2,
    "directories": [
      {
        "path": "/Users/username/Downloads",
        "file_count": 127,
        "indexed_count": 125,
        "failed_count": 2,
        "status": "complete",
        "added_at": "2024-01-15T10:30:00Z"
      },
      {
        "path": "/Users/username/Documents",
        "file_count": 543,
        "indexed_count": 489,
        "failed_count": 0,
        "status": "indexing",
        "added_at": "2024-01-15T14:22:00Z"
      }
    ]
  }
}

Directory Status

StatusDescription
indexingCurrently processing files in this directory
completeAll files have been processed (some may have failed)
errorCritical error occurred with this directory
watchingMonitoring for file changes (post-initial-index)
Directories continue to be watched even after initial indexing is complete. The backend monitors for file changes and automatically re-indexes modified or new files.
Use this endpoint to check indexing progress before running searches. Searches only return results for files that have been fully indexed.