Shattered Pixel Dungeon player API

Default

state

Observe the current player decision point

Waits up to 30 seconds. Every capture invalidates previous observation IDs and handles. Human input is not locked out; obtain a fresh observation after manual play.


/state

Usage and SDK Samples

curl -X GET \
 -H "Authorization: Bearer [[accessToken]]" \
 -H "Accept: application/json" \
 "http://127.0.0.1:8765/state"
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
import org.openapitools.client.api.DefaultApi;

import java.io.File;
import java.util.*;

public class DefaultApiExample {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        // Configure Bearer access token for authorization: bearerAuth
        HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth");
        bearerAuth.setBearerToken("BEARER TOKEN");

        // Create an instance of the API class
        DefaultApi apiInstance = new DefaultApi();

        try {
            Observation result = apiInstance.state();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling DefaultApi#state");
            e.printStackTrace();
        }
    }
}
import 'package:openapi/api.dart';

final api_instance = DefaultApi();


try {
    final result = await api_instance.state();
    print(result);
} catch (e) {
    print('Exception when calling DefaultApi->state: $e\n');
}

import org.openapitools.client.api.DefaultApi;

public class DefaultApiExample {
    public static void main(String[] args) {
        DefaultApi apiInstance = new DefaultApi();

        try {
            Observation result = apiInstance.state();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling DefaultApi#state");
            e.printStackTrace();
        }
    }
}
Configuration *apiConfig = [Configuration sharedConfig];

// Configure Bearer access token for authorization: bearerAuth
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];

// Create an instance of the API class
DefaultApi *apiInstance = [[DefaultApi alloc] init];

// Observe the current player decision point
[apiInstance stateWithCompletionHandler: 
              ^(Observation output, NSError* error) {
    if (output) {
        NSLog(@"%@", output);
    }
    if (error) {
        NSLog(@"Error: %@", error);
    }
}];
var ShatteredPixelDungeonPlayerApi = require('shattered_pixel_dungeon_player_api');
var defaultClient = ShatteredPixelDungeonPlayerApi.ApiClient.instance;

// Configure Bearer access token for authorization: bearerAuth
var bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN";

// Create an instance of the API class
var api = new ShatteredPixelDungeonPlayerApi.DefaultApi()
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.state(callback);
using System;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;

namespace Example
{
    public class stateExample
    {
        public void main()
        {
            // Configure Bearer access token for authorization: bearerAuth
            Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";

            // Create an instance of the API class
            var apiInstance = new DefaultApi();

            try {
                // Observe the current player decision point
                Observation result = apiInstance.state();
                Debug.WriteLine(result);
            } catch (Exception e) {
                Debug.Print("Exception when calling DefaultApi.state: " + e.Message );
            }
        }
    }
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure Bearer access token for authorization: bearerAuth
OpenAPITools\Client\Configuration::getDefaultConfiguration()->setAccessToken('', 'YOUR_ACCESS_TOKEN');

// Create an instance of the API class
$api_instance = new OpenAPITools\Client\Api\DefaultApi();

try {
    $result = $api_instance->state();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->state: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::OPenAPIClient::Configuration;
use WWW::OPenAPIClient::DefaultApi;

# Configure Bearer access token for authorization: bearerAuth
$WWW::OPenAPIClient::Configuration::access_token = 'YOUR_ACCESS_TOKEN';

# Create an instance of the API class
my $api_instance = WWW::OPenAPIClient::DefaultApi->new();

eval {
    my $result = $api_instance->state();
    print Dumper($result);
};
if ($@) {
    warn "Exception when calling DefaultApi->state: $@\n";
}
from __future__ import print_statement
import time
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint

# Configure Bearer access token for authorization: bearerAuth
openapi_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'

# Create an instance of the API class
api_instance = openapi_client.DefaultApi()

try:
    # Observe the current player decision point
    api_response = api_instance.state()
    pprint(api_response)
except ApiException as e:
    print("Exception when calling DefaultApi->state: %s\n" % e)
extern crate DefaultApi;

pub fn main() {

    let mut context = DefaultApi::Context::default();
    let result = client.state(&context).wait();

    println!("{:?}", result);
}

Scopes

Parameters

Responses


step

Perform one input and observe the result

Uses the latest observation_id. Serial controllers only. A cell click may start multi-step pathfinding. Modal UI must be handled using its buttons, text, or back. On timeout or an uncertain failure, read /state instead of repeating the action.


/action

Usage and SDK Samples

curl -X POST \
 -H "Authorization: Bearer [[accessToken]]" \
 -H "Accept: application/json" \
 -H "Content-Type: application/json" \
 "http://127.0.0.1:8765/action" \
 -d '{
  "observation_id" : 1,
  "type" : "cell",
  "cell" : 123
}'
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
import org.openapitools.client.api.DefaultApi;

import java.io.File;
import java.util.*;

public class DefaultApiExample {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        // Configure Bearer access token for authorization: bearerAuth
        HttpBearerAuth bearerAuth = (HttpBearerAuth) defaultClient.getAuthentication("bearerAuth");
        bearerAuth.setBearerToken("BEARER TOKEN");

        // Create an instance of the API class
        DefaultApi apiInstance = new DefaultApi();
        Action action = ; // Action | 

        try {
            Observation result = apiInstance.step(action);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling DefaultApi#step");
            e.printStackTrace();
        }
    }
}
import 'package:openapi/api.dart';

final api_instance = DefaultApi();

final Action action = new Action(); // Action | 

try {
    final result = await api_instance.step(action);
    print(result);
} catch (e) {
    print('Exception when calling DefaultApi->step: $e\n');
}

import org.openapitools.client.api.DefaultApi;

public class DefaultApiExample {
    public static void main(String[] args) {
        DefaultApi apiInstance = new DefaultApi();
        Action action = ; // Action | 

        try {
            Observation result = apiInstance.step(action);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling DefaultApi#step");
            e.printStackTrace();
        }
    }
}
Configuration *apiConfig = [Configuration sharedConfig];

// Configure Bearer access token for authorization: bearerAuth
[apiConfig setAccessToken:@"YOUR_ACCESS_TOKEN"];

// Create an instance of the API class
DefaultApi *apiInstance = [[DefaultApi alloc] init];
Action *action = ; // 

// Perform one input and observe the result
[apiInstance stepWith:action
              completionHandler: ^(Observation output, NSError* error) {
    if (output) {
        NSLog(@"%@", output);
    }
    if (error) {
        NSLog(@"Error: %@", error);
    }
}];
var ShatteredPixelDungeonPlayerApi = require('shattered_pixel_dungeon_player_api');
var defaultClient = ShatteredPixelDungeonPlayerApi.ApiClient.instance;

// Configure Bearer access token for authorization: bearerAuth
var bearerAuth = defaultClient.authentications['bearerAuth'];
bearerAuth.accessToken = "YOUR ACCESS TOKEN";

// Create an instance of the API class
var api = new ShatteredPixelDungeonPlayerApi.DefaultApi()
var action = ; // {Action} 

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.step(action, callback);
using System;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;

namespace Example
{
    public class stepExample
    {
        public void main()
        {
            // Configure Bearer access token for authorization: bearerAuth
            Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";

            // Create an instance of the API class
            var apiInstance = new DefaultApi();
            var action = new Action(); // Action | 

            try {
                // Perform one input and observe the result
                Observation result = apiInstance.step(action);
                Debug.WriteLine(result);
            } catch (Exception e) {
                Debug.Print("Exception when calling DefaultApi.step: " + e.Message );
            }
        }
    }
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure Bearer access token for authorization: bearerAuth
OpenAPITools\Client\Configuration::getDefaultConfiguration()->setAccessToken('', 'YOUR_ACCESS_TOKEN');

// Create an instance of the API class
$api_instance = new OpenAPITools\Client\Api\DefaultApi();
$action = ; // Action | 

try {
    $result = $api_instance->step($action);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling DefaultApi->step: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::OPenAPIClient::Configuration;
use WWW::OPenAPIClient::DefaultApi;

# Configure Bearer access token for authorization: bearerAuth
$WWW::OPenAPIClient::Configuration::access_token = 'YOUR_ACCESS_TOKEN';

# Create an instance of the API class
my $api_instance = WWW::OPenAPIClient::DefaultApi->new();
my $action = WWW::OPenAPIClient::Object::Action->new(); # Action | 

eval {
    my $result = $api_instance->step(action => $action);
    print Dumper($result);
};
if ($@) {
    warn "Exception when calling DefaultApi->step: $@\n";
}
from __future__ import print_statement
import time
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint

# Configure Bearer access token for authorization: bearerAuth
openapi_client.configuration.access_token = 'YOUR_ACCESS_TOKEN'

# Create an instance of the API class
api_instance = openapi_client.DefaultApi()
action =  # Action | 

try:
    # Perform one input and observe the result
    api_response = api_instance.step(action)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling DefaultApi->step: %s\n" % e)
extern crate DefaultApi;

pub fn main() {
    let action = ; // Action

    let mut context = DefaultApi::Context::default();
    let result = client.step(action, &context).wait();

    println!("{:?}", result);
}

Scopes

Parameters

Body parameters
Name Description
action *

Responses