curl --request POST \
--url https://app.base44.com/api/apps/{app_id}/code/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "useState(",
"case_sensitive": false
}
'import requests
url = "https://app.base44.com/api/apps/{app_id}/code/search"
payload = {
"query": "useState(",
"case_sensitive": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({query: 'useState(', case_sensitive: false})
};
fetch('https://app.base44.com/api/apps/{app_id}/code/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.base44.com/api/apps/{app_id}/code/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => 'useState(',
'case_sensitive' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.base44.com/api/apps/{app_id}/code/search"
payload := strings.NewReader("{\n \"query\": \"useState(\",\n \"case_sensitive\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.base44.com/api/apps/{app_id}/code/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"useState(\",\n \"case_sensitive\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.base44.com/api/apps/{app_id}/code/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"useState(\",\n \"case_sensitive\": false\n}"
response = http.request(request)
puts response.read_body{
"files": [
{
"matches": [
{
"line_number": 12,
"preview": " const [count, setCount] = useState(0);"
}
],
"path": "src/pages/Home.jsx"
}
],
"truncated": false,
"skipped_files": 0
}Search app code
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.
curl --request POST \
--url https://app.base44.com/api/apps/{app_id}/code/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"query": "useState(",
"case_sensitive": false
}
'import requests
url = "https://app.base44.com/api/apps/{app_id}/code/search"
payload = {
"query": "useState(",
"case_sensitive": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({query: 'useState(', case_sensitive: false})
};
fetch('https://app.base44.com/api/apps/{app_id}/code/search', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://app.base44.com/api/apps/{app_id}/code/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'query' => 'useState(',
'case_sensitive' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://app.base44.com/api/apps/{app_id}/code/search"
payload := strings.NewReader("{\n \"query\": \"useState(\",\n \"case_sensitive\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://app.base44.com/api/apps/{app_id}/code/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"query\": \"useState(\",\n \"case_sensitive\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.base44.com/api/apps/{app_id}/code/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"query\": \"useState(\",\n \"case_sensitive\": false\n}"
response = http.request(request)
puts response.read_body{
"files": [
{
"matches": [
{
"line_number": 12,
"preview": " const [count, setCount] = useState(0);"
}
],
"path": "src/pages/Home.jsx"
}
],
"truncated": false,
"skipped_files": 0
}Authorizations
Personal access token, sent as Authorization: Bearer <token>.
Path Parameters
ID of the app whose code to read.
Body
Response
The matching lines, grouped by file.
The files that contain the text.
Each file with at least one match.
Show child attributes
Show child attributes
[
{
"matches": [
{
"line_number": 12,
"preview": " const [count, setCount] = useState(0);"
}
],
"path": "src/pages/Home.jsx"
}
]
true when the search stopped at 500 matching lines or 10 seconds, so there can be more matches.
false
Number of files left out of the search because they're over 5 MB or aren't text.
0
Was this page helpful?