The ScriptBlox API has had major changes. If you are using the API, please migrate to the new structure. Details in https://scriptblox.com/docs/migration

Search scripts

Search for scripts based on a query and filters

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.

API Path

The API path for this endpoint is /api/script/search

Parameters

Like the fetch endpoint, the search endpoint also accepts a list of parameters to make more targetted and narrower queries.

The accepted parameters are:

ParameterDescriptionRequiredTypeDefault
qThe search querystring-
pageThe page to start fetching from (useful for paginating content)number1
maxMaximum amount of scripts to fetch in a batchAny positive number up to 2020
modeThe script typefree or paid-
patchedWhether or not the script is patched1 (yes) or 0 (no)-
keyWhether or not the script has a key system1 (yes) or 0 (no)-
universalWhether or not the script is universal1 (yes) or 0 (no)-
verifiedWhether or not the script is verified1 (yes) or 0 (no)-
sortByUsed to control the criteria by which to sort the resultsviews | likeCount | createdAt | updatedAt | dislikeCount | accuracyupdatedAt
orderThe sort orderasc (ascending) or desc (descending)desc
strictWhether to enable strict searchingtrue (yes) or false (no)true

Response

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"
}

Usage

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)
            });
        });
    }
}