Search app code
Changed on<Info>This API is in beta. Endpoints, fields, and behavior may still change, so avoid depending on it in production.</Info>
Finds the lines in the app's source files that contain some text, the way the app editor's search does.
The text is matched literally, not as a pattern, and the match ignores case unless you set case_sensitive. Each result lists the matching lines of one file with their line numbers and up to 300 characters of the line around the match.
Search covers the files List app code files returns for the same branch_id. Files over 5 MB and files that aren't text are skipped and counted in skipped_files. A search stops after 500 matching lines or 10 seconds, and truncated is then true, so narrow the text if you need every match.
Reads come from the app's live sandbox, the same files the app editor shows, including changes that haven't been published yet. If no sandbox is running, the call starts one, so the first call after a quiet period takes noticeably longer than later ones.
Set branch_id to read a branch's files instead of main's. Each branch has its own sandbox, so the first read of a branch also takes longer. A merged branch can't be read: the call returns a 409. On an app imported from GitHub, reading a merged branch can instead return the files as they were when the branch was created, so don't rely on it there.
This is limited to 60 requests per minute per app for each workspace's personal API keys, so every key in a workspace shares one allowance. Some workspaces have a different limit.
<Note>This endpoint accepts a personal API key belonging to a user with editor access to the app. A read-only key is refused even though this endpoint only reads, and workspace API keys are not accepted.</Note>
Request
- Base URLhttps://app.base44.com
- URLhttps://app.base44.com/api/apps/{app_id}/code/search
- AuthHTTP bearer
Path parameters
ID of the app whose code to read.
Query parameters
ID of the branch to work on, as returned by List branches. Omit it to work on the app's main branch.
Request body
Example request
{
"query": "useState("
}Response
The matching lines, grouped by file.
Example response
{
"files": [
{
"matches": [
{
"line_number": 12,
"preview": " const [count, setCount] = useState(0);"
}
],
"path": "src/pages/Home.jsx"
}
]
}Changes
- info
added the new optional
queryrequest parameterbranch_id - info
added the non-success response with the status
- info
- info
the endpoint scheme security
PersonalAccessTokenAuthwas added to the API
- info