The first endpoint, and likely one of those that will be used the most in your executor/script hub, is the fetch endpoint. This endpoint handles all general querying of ScriptBlox's script catalogue, and can be used along with filters to narrow down results.
The API path for this endpoint is /api/script/fetch
In addition to plain requests for home page scripts, this endpoint accepts additional query parameters (filters) to narrow down results and make more targetted queries.
The accepted parameters are:
| Parameter | Description | Required | Type | Default |
|---|---|---|---|---|
| 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 |
| exclude | Mainly internal, used to exclude a certain script from the results. | ❌ | Valid script ID | - |
| 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 | updatedAt |
| order | The sort order | ❌ | asc (ascending) or desc (descending) | desc |
| owner | The username to filter by | ❌ | string | - |
| placeId | The game ID to filter by | ❌ | number | - |
The response, unless errored, would be of the following structure:
{
"result": {
"totalPages": number,
"nextPage": number,
"max": 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,
"image": "string",
"createdAt": "string",
"script": "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/fetch"); // 20 most recent scripts. Also known as home page scripts.
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/fetch") // 20 most recent scripts. Also known as home page scripts.
.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/fetch") -- 20 most recent scripts. Also known as home page scripts.
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/fetch") -- 20 most recent scripts. Also known as home page scripts.
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