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. 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.

Internally this route can follow a feature branch, but the parameter that selects one isn't part of the public API, so reads come from the app's main line.

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>

post/api/apps/{app_id}/code/search

Request

  • Base URL: https://app.base44.com
  • URL: https://app.base44.com/api/apps/{app_id}/code/search
  • Auth: HTTP bearer

Path parameters

app_idstring required

ID of the app whose code to read.

Request body

querystring required

Text to find, 2 to 200 characters on a single line. It's matched literally.

case_sensitiveboolean

Whether the match respects case.

Example request

{
  "query": "useState("
}

Response

The matching lines, grouped by file.

truncatedboolean required

true when the search stopped at 500 matching lines or 10 seconds, so there can be more matches.

skipped_filesinteger required

Number of files left out of the search because they're over 5 MB or aren't text.

Example response

{
  "files": [
    {
      "matches": [
        {
          "line_number": 12,
          "preview": "  const [count, setCount] = useState(0);"
        }
      ],
      "path": "src/pages/Home.jsx"
    }
  ]
}

Changes