JasX API Reference



Basic usage

in: 
{
    "k":(str)api_key[optional for some tasks], 
    "t":[{t:(int)task, d:(var)data, c:(var)callback}...]
}
out: 
{
    "m":(arr)messages, 
    "t":[{t:(int)task, d:(var)data, c:(var)callback, s:(int)status_code}...]
}

My API Key

Your API key is used to interact with the JasX API, make sure to keep it secret as it can be used to change your settings and see private info about your account.

Please log in at http://jasx.org then reload this page.


Example Script

#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, "jasx_users", // We will fetch from the jasx users table
                
                DATA_FIELDS, llList2Json(JSON_ARRAY, [ // We want id, character key and username returned
                    "id", "charkey", "username"
                ]),
                
                DATA_LIMIT, llList2Json(JSON_ARRAY, [ // We limit it to script owner
                    "charkey="+(string)llGetOwner()
                ]),
                
                DATA_NR_FIELDS, 1  // We want only 1 user's data
                
            ]), 
            
            "" // Optional callback
        );
        
        sendAPI("", [call]);  // Send the API call here. The first value is an API key you can generate above
    }
    
    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{ // 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.");
                    }
                    
                }
            }
            
        }
    }