The search endpoint behaves very similarly to the fetch endpoint, and is designed specifically for searching throughout the scripts catalogue. Unlike the fetch endpoint, the search query (q) is required.
The API path for this endpoint is /api/script/search
Like the fetch endpoint, the search endpoint also accepts a list of parameters to make more targetted and narrower queries.
The accepted parameters are:
Parameter | Description | Required | Type | Default |
---|---|---|---|---|
q | The search query | ✅ | string | - |
page | The page to start fetching from (useful for paginating content) | ❌ | number | 1 |
max | Maximum amount of scripts to fetch in a batch | ❌ | Any positive number up to 20 | 20 |
mode | The script type | ❌ | free or paid | - |
patched | Whether or not the script is patched | ❌ | 1 (yes) or 0 (no) | - |
key | Whether or not the script has a key system | ❌ | 1 (yes) or 0 (no) | - |
universal | Whether or not the script is universal | ❌ | 1 (yes) or 0 (no) | - |
verified | Whether or not the script is verified | ❌ | 1 (yes) or 0 (no) | - |
sortBy | Used to control the criteria by which to sort the results | ❌ | views | likeCount | createdAt | updatedAt | dislikeCount | accuracy | updatedAt |
order | The sort order | ❌ | asc (ascending) or desc (descending) | desc |
strict | Whether to enable strict searching | ❌ | true (yes) or false (no) | true |
The response, unless errored, would be of the following structure:
{
"result": {
"totalPages": number,
"scripts": [
{
"_id": "string",
"title": "string",
"game": {
"_id": "string",
"name": "string",
"imageUrl": "string"
},
"slug": "string",
"verified": boolean,
"key": boolean,
"views": number,
"scriptType": "string",
"isUniversal": boolean,
"isPatched": boolean,
"createdAt": "string",
"updatedAt": "string",
"image": "string",
"script": "string",
"matched": [
"string",
...
]
},
...
]
}
}
If an error occurs, the response will contain a single message
field:
{
"message": "string"
}
using System.Text.Json;
using System.Net.Http.Json;
public async Task FetchScripts() {
HttpClient client = new HttpClient();
try {
JsonElement scripts = await client.GetFromJsonAsync<JsonElement>("https://scriptblox.com/api/script/search?q=admin"); // 20 most recent scripts that relate to "admin"
foreach(JsonElement script in scripts.GetProperty("result").GetProperty("scripts")) {
// Use the script to, for example, display it in a window/page
Application.Current.Dispatcher.Invoke(() => {
// Example: ScriptPanel is a StackPanel defined in your XAML
ScriptPanel.Children.Add(new TextBlock(){
Text = $"Title: {script.GetProperty("title").GetString()}\nSlug: \n{script.GetProperty("slug").GetString()}"
});
});
}
}
catch (HttpRequestException e)
{
// Network error or invalid URL
Application.Current.Dispatcher.Invoke(() =>
{
ScriptPanel.Children.Add(new TextBlock()
{
Text = $"Network error while fetching scripts:\n{e.Message}",
Margin = new Thickness(10)
});
});
}
catch (JsonException e)
{
// JSON parsing error
Application.Current.Dispatcher.Invoke(() =>
{
ScriptPanel.Children.Add(new TextBlock()
{
Text = $"Error parsing JSON response:\n{e.Message}",
Margin = new Thickness(10)
});
});
}
catch (Exception e)
{
// General exception
Application.Current.Dispatcher.Invoke(() =>
{
ScriptPanel.Children.Add(new TextBlock()
{
Text = $"Unexpected error:\n{e.Message}",
Margin = new Thickness(10)
});
});
}
}
fetch("https://scriptblox.com/api/script/search?q=admin"); // 20 most recent scripts that relate to "admin"
.then((res) => res.json())
.then((data) => {
// Example: the page contains an element with id="results"
const results = document.getElementById('results');
// Loop through the scripts and display them on the page
for (const script of data.result.scripts) {
// Create a new div to hold each script's information
const scriptElement = document.createElement('div');
scriptElement.classList.add('script');
// Add script title
const titleElement = document.createElement('h3');
titleElement.textContent = `Title: ${script.title}`;
scriptElement.appendChild(titleElement);
// Add script slug
const slugElement = document.createElement('p');
slugElement.textContent = `Slug: ${script.slug}`;
scriptElement.appendChild(slugElement);
// Add the script to the container
scriptsContainer.appendChild(scriptElement);
}
})
.catch((error) => {
console.error('Error while fetching scripts', error);
// Display an error message on the page
const errorMessage = document.createElement('p');
errorMessage.textContent = `Error while fetching scripts: ${error.message}`;
document.getElementById('results').appendChild(errorMessage);
});
local ScreenGui = Instance.new("ScreenGui",game:GetService("CoreGui"))
local Frame = Instance.new("Frame", ScreenGui)
local HttpService = game:GetService("HttpService")
local success, result = pcall(function()
return HttpService:GetAsync("https://scriptblox.com/api/script/search?q=admin") -- 20 most recent scripts that relate to "admin"
end)
if success then
local scripts = HttpService:JSONDecode(result)
for i, script in next, scripts.result.scripts do
-- Example: create a TextLabel for each script
local newTextLabel = Instance.new("TextLabel")
newTextLabel.Text = "Title: " .. script.title .. "\nSlug: " .. script.slug
newTextLabel.Size = UDim2.new(1, 0, 0, 50)
newTextLabel.Parent = Frame
end
else
warn("Failed to fetch scripts: " .. result)
end
local ScreenGui = Instance.new("ScreenGui",game:GetService("CoreGui"))
local Frame = Instance.new("Frame", ScreenGui)
local scriptJson = game:HttpGet("https://scriptblox.com/api/script/search?q=admin") -- 20 most recent scripts that relate to "admin"
local scripts = game:GetService("HttpService"):JSONDecode(scriptJson)
for i, script in next, scripts.result.scripts do
-- Example: create a TextLabel for each script
local newTextLabel = Instance.new("TextLabel")
newTextLabel.Text = "Title: " .. script.title .. "\nSlug: " .. script.slug
newTextLabel.Size = UDim2.new(1, 0, 0, 50)
newTextLabel.Parent = Frame
end
::