API_GET_DATA [1]

This task lets you get data directly from the JasX database. The task has the following input:

#define DATA_TABLE "a"                    // (str) Table name
#define DATA_FIELDS "b"                    // (arr) data fields
#define DATA_LIMIT "c"                    // (arr)(nested) You can use = & != !& > <  [["field=val", AND "field<val"], OR "field!=val"]...
#define DATA_NR_FIELDS "d"                // (int)nr_results
#define DATA_ORDER_BY "e"                // (array)[{"f":(str)field, "d":(int)descending}...]

And returns (array)data - An array containing all the matched table rows.

Limits lets you search the tables. Examples:

// Root values are ORED, ex:
llList2Json(JSON_ARRAY, [ // Search for charkey of llGetOwner OR id=2
   "charkey="+(string)llGetOwner(), "id=2"
])

// A sub array uses AND
llList2Json(JSON_ARRAY, [ // Search sex = male AND species = cat 
   llList2Json(JSON_ARRAY, ["sex=1","species=cat"])
])


Example: Get the last 3 registered jFish users.

// Get the XOBJ library: https://github.com/JasXSL/JasX-HUD
#include "jasx_hud/_core.lsl" 

default
{
    state_entry()
    {
        // Get JasX ID, and username of owner
        string call = apiTask(
            // Task to get data from a table
            API_GET_DATA, 
            
            // This is the data that gets passed along
            llList2Json(JSON_OBJECT, [
            
                DATA_TABLE, "jfish_users", // We will fetch from the jfish_users table
                
                DATA_FIELDS, llList2Json(JSON_ARRAY, [ // Get ID and username
                    "id", "username"
                ]),
                
                DATA_NR_FIELDS, 3,  // Get the last 3
                
                DATA_ORDER_BY, llList2Json(JSON_ARRAY, [
                    llList2Json(JSON_OBJECT, ["f","id", "d",1])
                ])
            ]), 
            
            "" // Optional callback
        );
        
        sendAPI("", [call]);  // Send the API call here. The first value is an API key you can get on your jasx control panel. It is only needed for private values and SETTING values.
    }
    
    http_response(key id, integer status, list meta, string body){
        
        if(llJsonValueType(body,[]) != JSON_OBJECT)llOwnerSay("Error:\n"+body);
        else{
            
            // There were some messages from the server included, let's output them
            if(llJsonValueType(body, [API_MESSAGES]) != JSON_INVALID){
                list m = llJson2List(llJsonGetValue(body, [API_MESSAGES]));
                while(llGetListLength(m)){
                    llOwnerSay(llList2String(m,0));
                    m = llDeleteSubList(m,0,0);
                }
            }
            
            // Let's check what tasks we got back
            if(llJsonValueType(body, [API_TASKS]) != JSON_INVALID){            
                list d = llJson2List(llJsonGetValue(body, [API_TASKS]));
                while(llGetListLength(d)){
                    string data = llList2String(d,0);
                    d = llDeleteSubList(d, 0,0);
                    
                    integer task = (integer)llJsonGetValue(data, [API_TASK]);
                    string taskData = llJsonGetValue(data, [API_DATA]);
                    string callback = llJsonGetValue(data, [API_CALLBACK]);
                    integer status = (integer)llJsonGetValue(data, [API_STATUS]);
                    
                    // Success! The API call worked!
                    if(status == STATUS_SUCCESS){
                        llOwnerSay((string)task+" was executed successfully!");
                        if(callback != JSON_INVALID)llOwnerSay("Callback: "+callback);
                        if(taskData != JSON_INVALID)llOwnerSay("Data returned: "+taskData);
                        else llOwnerSay("Server returned no data. Perhaps it didn't find anything?");
                    }
                    else{ // There was an error
                        llOwnerSay((string)task+" failed:");
                        if(status == STATUS_FAIL_ACCESS_DENIED)llOwnerSay("Access denied");
                        else if(status == STATUS_FAIL_DATA_MISSING)llOwnerSay("Data fields missing");
                        else llOwnerSay("See messages.");
                    }
                    
                }
            }
            
        }
    }
}

List of available tables and fields

Public values can be accessed by anyone. Private values can only be accessed by the owner in calls utilizing their API key.

jasx_users
FieldDescription
idinteger - A unique ID.
usernamestr - JasX Username (NOT SL NAME)
accountstatusint - 0 = banned, 1 = registered, >1 = admin
charkeykey - SL Character UUID
signupdatetimestamp - Date signed up
abouttextstr - Profile text
available_titlesarr - Available title IDs
currenttitleint - Current active title
achievementsarr - [{id:(int)id, progress:(int)progress}]
bitflagsint - Bitfield:
FLAG_SHOW_ADULT_ACHIEVEMENTS = 1;
FLAG_CREDITS_TERMS_ACCEPTED = 2;
FLAG_HIDDEN = 4;
games_ownedarray - Games owned. You can use the jasx_games view to get info about games by ID.
sexint - Genitals. 0x1 = Penis, 0x2 = Vagina, 0x4 = breasts
last_lfpint - Last update. If this value is less than unix_time-60, the player is NOT currently listed as LFP
outfit(str)active_rlv_outfit
roleplay_statusint - Status. 0 = No RP, 1 = either, 2 = only RP
fliststr - Active F-list character
lfp_forarray - Games LFP for (see games_owned for game IDs)
lfp_prefsobj - LFP Filters {sexes:(arr)allowed_sexes, games:(arr)allowed_games, avtypes:(arr)allowed_avtypes, roleplay:(int)roleplay_status}
jasx_titles
FieldDescription
idinteger - A unique ID.
suffixstr - Text going after your name.
prefixstr - Text going before your name
rewardfromstr - Where to get it.
jasx_versions
FieldDescription
idint - A unique ID.
itemstr - Item name
versionItem version
jasx_assets
FieldDescription
idint - A unique ID.
gameint - Game ID.
gameidstr - Game legacy ID.
itemnamestr - Asset name
bitfieldint - Bitfield values:
FLAG_NOTRADE = 1; // Unable to trade this item
FLAG_ADULT = 4; // Adult item
FLAG_NOCONSUME = 8; // Not consumed on use
FLAG_NO_SALE = 16; // Not included in random sales
descstr - Item description
rarityint - Rarity between 0->3
storevalueint - JXC cost.
dateaddedtimestamp - Date added
jasx_achievements
FieldDescription
idint - A unique ID
gameint - Game ID
gameidstr - Game legacy ID
namestr - Name
descriptionstr - Description
unobtainableint - Achievement cannot be obtained anymore
jasx_events
FieldDescription
idinteger - A unique ID.
titlestr - Title of the event
descriptionstr - Event description
SLURLurl - SL URL to event.
creatorint - jasx_users ID of creator
timeint - Unix timestamp of event.
gameidint - ID of game.
added_datetimestamp - Timestamp of event
jasx_games
FieldDescription
idint - A unique ID
labelstr - Legacy ID
namestr - Name
descriptionstr - Description
creatorint - Jasx user ID
flagsint - 0x2 = Adult
store_assetsarr - Related asset IDs
assetint - Unpacker asset
lfp_enabledbool - Players can be LFP for this game

Back to Start