Search
Search file contents and filenames across your sandbox environment with powerful filtering options.
Search File Contents
Search for text within files:
const results = await sandbox.search.search({
query: 'function',
options: {
caseSensitive: false,
regex: false,
path: '/opt/app/src'
}
});
console.log(`Found ${results.matches.length} matches`);
results.matches.forEach(match => {
console.log(`${match.file}:${match.line}: ${match.text}`);
});const response = await fetch(`${sandbox.url}/search`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${sandbox.token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'function',
options: {
caseSensitive: false,
regex: false,
path: '/opt/app/src'
}
})
});
const results = await response.json();curl -X POST https://sandbox.oblien.com/search \
-H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
-H "Content-Type: application/json"Response:
{
"success": true,
"query": "function",
"matches": [
{
"file": "/opt/app/src/utils.js",
"line": 10,
"column": 5,
"text": "function formatDate(date) {",
"context": "export function formatDate(date) {\n return date.toISOString();\n}"
},
{
"file": "/opt/app/src/api.js",
"line": 23,
"column": 8,
"text": "async function fetchData() {",
"context": "async function fetchData() {\n const response = await fetch(url);\n}"
}
],
"totalMatches": 2,
"filesSearched": 15
}Search Filenames
Search for files by name:
const results = await sandbox.search.searchFileNames({
query: 'component',
options: {
path: '/opt/app'
}
});
console.log('Matching files:');
results.files.forEach(file => {
console.log(` ${file}`);
});const response = await fetch(`${sandbox.url}/search/filenames`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${sandbox.token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'component',
options: {
path: '/opt/app'
}
})
});
const results = await response.json();curl -X POST https://sandbox.oblien.com/search/filenames \
-H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
-H "Content-Type: application/json"Response:
{
"success": true,
"query": "component",
"files": [
"/opt/app/src/components/Button.tsx",
"/opt/app/src/components/Header.tsx",
"/opt/app/tests/component.test.js"
],
"totalFiles": 3
}Search Options
Case Sensitive Search
const results = await sandbox.search.search({
query: 'APIKey',
options: {
caseSensitive: true
}
});
// Only matches exact caseconst response = await fetch(`${sandbox.url}/search`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${sandbox.token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'APIKey',
options: { caseSensitive: true }
})
});curl -X POST https://sandbox.oblien.com/search \
-H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
-H "Content-Type: application/json"Regular Expression Search
const results = await sandbox.search.search({
query: 'function\\s+\\w+\\(',
options: {
regex: true
}
});
// Matches function declarationsconst response = await fetch(`${sandbox.url}/search`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${sandbox.token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'function\\s+\\w+\\(',
options: { regex: true }
})
});curl -X POST https://sandbox.oblien.com/search \
-H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
-H "Content-Type: application/json"Search Specific Path
const results = await sandbox.search.search({
query: 'import',
options: {
path: '/opt/app/src/components'
}
});
// Only searches within components directoryComplete Example
// Search for TODO comments
const todos = await sandbox.search.search({
query: 'TODO:',
options: {
caseSensitive: false,
path: '/opt/app/src'
}
});
console.log(`Found ${todos.matches.length} TODO items:`);
todos.matches.forEach(match => {
console.log(`\n${match.file}:${match.line}`);
console.log(` ${match.text.trim()}`);
});
// Search for React components
const components = await sandbox.search.searchFileNames({
query: 'Component',
options: {
path: '/opt/app/src'
}
});
console.log(`\nFound ${components.files.length} component files`);
// Search for API endpoints using regex
const endpoints = await sandbox.search.search({
query: 'app\\.(get|post|put|delete)\\(',
options: {
regex: true,
path: '/opt/app/src/routes'
}
});
console.log(`\nFound ${endpoints.matches.length} API endpoints`);// Search for TODO comments
let response = await fetch(`${sandbox.url}/search`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${sandbox.token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'TODO:',
options: {
caseSensitive: false,
path: '/opt/app/src'
}
})
});
const todos = await response.json();
// Search for React components
response = await fetch(`${sandbox.url}/search/filenames`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${sandbox.token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'Component',
options: { path: '/opt/app/src' }
})
});
const components = await response.json();curl -X POST https://sandbox.oblien.com/search \
-H "Authorization: Bearer YOUR_SANDBOX_TOKEN" \
-H "Content-Type: application/json"Parameters
Search Content
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Search query or regex pattern |
options.caseSensitive | boolean | No | Case sensitive search |
options.regex | boolean | No | Use regex pattern |
options.path | string | No | Limit to specific path |
Search Filenames
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Filename to search for |
options.path | string | No | Limit to specific path |
Use Cases
Find All Imports
const imports = await sandbox.search.search({
query: '^import\\s',
options: {
regex: true,
path: '/opt/app/src'
}
});Find Configuration Files
const configs = await sandbox.search.searchFileNames({
query: 'config',
options: {
path: '/opt/app'
}
});Find Security Issues
const security = await sandbox.search.search({
query: 'password|secret|key',
options: {
regex: true,
caseSensitive: false
}
});Find Unused Variables
const unused = await sandbox.search.search({
query: 'const\\s+\\w+\\s*=.*//\\s*unused',
options: {
regex: true
}
});Best Practices
-
Use specific paths: Limit searches to relevant directories for faster results
-
Combine with file operations: Search, then read/edit matching files
-
Use regex for complex patterns: Enable
regex: truefor advanced searches -
Handle large result sets: Consider pagination or limiting scope
Next Steps
- File Operations - Work with found files
- File Reading - Read file contents
- Terminal - Execute commands