Skip to content

jstony/webapi-client-python

 
 

Repository files navigation

Web-API - Python Client

Access Sponge powered Minecraft servers through a WebAPI

Introduction

This is the documentation of the various API routes offered by the WebAPI plugin. This documentation assumes that you are familiar with the basic concepts of Web API's, such as GET, PUT, POST and DELETE methods, request HEADERS and RESPONSE CODES and JSON data.

By default this documentation can be found at http:/localhost:8080 (while your minecraft server is running) and the various routes start with http:/localhost:8080/api/v5... As a quick test try reaching the route http:/localhost:8080/api/v5/info (remember that you can only access \"localhost\" routes on the server on which you are running minecraft). This route should show you basic information about your server, like the motd and player count.

List endpoints

Lots of objects offer an endpoint to list all objects (e.g. GET: /world to get all worlds). These endpoints return only the properties marked 'required' by default, because the list might be quite large. If you want to return ALL data for a list endpoint add the query parameter details, (e.g. GET: /world?details).

Remember that in this case the data returned by the endpoint might be quite large.

Debugging endpoints

Apart from the ?details flag you can also pass some other flags for debugging purposes. Remember that you must include the first query parameter with ?, and further ones with &:

  • details: Includes details for list endpoints
  • accept=[json/xml]: Manually set the accept content type. This is good for browser testing, BUT DON'T USE THIS IN PRODUCTION, YOU CAN SUPPLY THE Accepts HEADER FOR THAT
  • pretty: Pretty prints the data, also good for debugging in the browser.

An example request might look like this: http://localhost:8080/api/v5/world?details&accpet=json&pretty&key=MY-API-KEY

Additional data

Certain endpoints (such as /player, /entity and /tile-entity have additional properties which are not documented here, because the data depends on the concrete object type (eg. Sheep have a wool color, others do not) and on the other plugins/mods that are running on your server which might add additional data. You can also find more information in the github docs

Swagger Codegen

This Python package is automatically generated by the Swagger Codegen project:

  • API version: 5.2.2
  • Package version: 1.0.0
  • Build package: io.swagger.codegen.languages.PythonClientCodegen For more information, please visit https://github.com/Valandur

Requirements

Python 2.7 and 3.4+

Installation & Usage

pip install

If the python package is hosted on Github, you can install directly from Github

pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/GIT_USER_ID/GIT_REPO_ID.git)

Then import the package:

import swagger_client

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import swagger_client

Getting Started

Please follow the installation procedure and then run the following:

from __future__ import print_function
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint

# Configure API key authorization: ApiKeyHeader
swagger_client.configuration.api_key['X-WebAPI-Key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# swagger_client.configuration.api_key_prefix['X-WebAPI-Key'] = 'Bearer'
# Configure API key authorization: ApiKeyQuery
swagger_client.configuration.api_key['key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# swagger_client.configuration.api_key_prefix['key'] = 'Bearer'
# create an instance of the API class
api_instance = swagger_client.ActiveTimeApi()
details = true # bool | Add to include additional details, omit or false otherwise (optional)
accept = 'accept_example' # str | Override the 'Accept' request header (useful for debugging your requests) (optional)
pretty = true # bool | Add to make the Web-API pretty print the response (useful for debugging your requests) (optional)

try:
    # Server report
    api_response = api_instance.get_server_report(details=details, accept=accept, pretty=pretty)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling ActiveTimeApi->get_server_report: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://localhost/api/v5

Class Method HTTP request Description
ActiveTimeApi get_server_report GET /active-time Server report
ActiveTimeApi get_user_report GET /active-time/user/{uuid} User report
BlockApi create_block_operation POST /block/op Create a block operation
BlockApi delete_block_operation DELETE /block/op/{uuid} Stop a block operation
BlockApi get_block GET /block/{world}/{x}/{y}/{z} Get a block
BlockApi get_block_operation GET /block/op/{uuid} Get a block operation
BlockApi list_block_operations GET /block/op List block operations
BlockApi modify_block_operation PUT /block/op/{uuid} Modify a block operation
ChunkApi create_chunk_at POST /chunk/{world}/{x}/{z} Load & Generate a chunk
ChunkApi get_chunk_at GET /chunk/{world}/{x}/{z} Get a chunk
ChunkApi list_chunks GET /chunk/{world} List chunks
CmdSchedulerApi delete_task DELETE /cmd-scheduler/{name} Delete a task
CmdSchedulerApi list_tasks GET /cmd-scheduler List tasks
CommandApi get_command GET /cmd/{cmd} Get a command
CommandApi list_commands GET /cmd List commands
CommandApi run_commands POST /cmd Execute a command
EconomyApi get_account GET /economy/account/{id} List currencies
EconomyApi get_currencies GET /economy/currency List currencies
EntityApi create_entity POST /entity Spawn an entity
EntityApi execute_method POST /entity/{entity}/method Execute a method
EntityApi get_entity GET /entity/{entity} Get entity
EntityApi list_entities GET /entity List entities
EntityApi modify_entity PUT /entity/{entity} Modify an entity
EntityApi remove_entity DELETE /entity/{entity} Destroy an entity
GWMCratesApi list_crates GET /gwm-crates/manager List managers
HistoryApi get_chat GET /history/message Get message history
HistoryApi get_commands GET /history/cmd Get command history
HuskyCratesApi create_crate POST /husky-crates/crate Create a crate
HuskyCratesApi delete_crate DELETE /husky-crates/crate/{id} Delete a crate
HuskyCratesApi get_crate GET /husky-crates/crate/{id} Get a crate
HuskyCratesApi list_crates GET /husky-crates/crate List crates
HuskyCratesApi modify_crate PUT /husky-crates/crate/{id} Change a crate
InfoApi get_info GET /info Server info
InfoApi get_stats GET /info/stats Server stats
InfoApi list_servlets GET /info/servlets List servlets
InteractiveMessageApi get_message GET /interactive-message/{uuid} Get a message
InteractiveMessageApi list_messages GET /interactive-message List messages
InteractiveMessageApi send_message POST /interactive-message Send a message
MMCRestrictApi add_item POST /mmc-restrict/item Add an item
MMCRestrictApi delete_item DELETE /mmc-restrict/item/{id} Delete an item
MMCRestrictApi list_items GET /mmc-restrict/item List items
MMCRestrictApi modify_item PUT /mmc-restrict/item/{id} Modify an item
MMCTicketsApi get_ticket GET /mmc-tickets/ticket/{id} Get a ticket
MMCTicketsApi list_tickets GET /mmc-tickets/ticket List tickets
MMCTicketsApi modify_ticket PUT /mmc-tickets/ticket/{id} Modify a ticket
MapApi get_map GET /map/{world}/{x}/{z} Get a map tile
NucleusApi create_jail POST /nucleus/jail Create a jail
NucleusApi create_kit POST /nucleus/kit Create a kit
NucleusApi delete_jail DELETE /nucleus/jail/{name} Delete a jail
NucleusApi delete_kit DELETE /nucleus/kit/{name} Delete a kit
NucleusApi get_jail GET /nucleus/jail/{name} Get a jail
NucleusApi get_kit GET /nucleus/kit/{name} Get a kit
NucleusApi list_homes GET /nucleus/home/{player} List homes
NucleusApi list_jails GET /nucleus/jail List jails
NucleusApi list_kits GET /nucleus/kit List kits
NucleusApi list_mail GET /nucleus/mail/{player} List mail
NucleusApi list_mail_0 GET /nucleus/module List modules
NucleusApi modify_jail PUT /nucleus/jail/{name} Modify a jail
NucleusApi modify_kit PUT /nucleus/kit/{name} Modify a kit
PermissionApi get_collection GET /permission/collection/{id} Get collection
PermissionApi get_subject GET /permission/collection/{id}/subject/{subId} Get subject
PermissionApi list_collections GET /permission/collection List collections
PermissionApi list_subjects GET /permission/collection/{id}/subject List subjects
PlayerApi execute_method POST /player/{player}/method Execute a method
PlayerApi get_player GET /player/{player} Get a player
PlayerApi list_players GET /player List players
PlayerApi modify_player PUT /player/{player} Modify a player
PluginApi change_plugin_config POST /plugin/{plugin}/config Change plugin configs
PluginApi get_plugin GET /plugin/{plugin} Get a plugin
PluginApi get_plugin_config GET /plugin/{plugin}/config Get plugin configs
PluginApi list_plugins GET /plugin List plugins
PluginApi toggle_plugin PUT /plugin/{plugin} Toggle a plugin
RecipeApi list_recipes GET /recipe List recipes
RedProtectApi create_region POST /red-protect/region Create a region
RedProtectApi delete_region DELETE /red-protect/region/{id} Delete a region
RedProtectApi get_region GET /red-protect/region/{id} Get a region
RedProtectApi list_regions GET /red-protect/region List regions
RedProtectApi modify_region PUT /red-protect/region/{id} Modify a region
RegistryApi get_registry GET /registry/{class} Get a catalog type
ServerApi list_properties GET /server/properties List server properties
ServerApi modify_properties PUT /server/properties Modify server properties
TileEntityApi execute_method POST /tile-entity/{world}/{x}/{y}/{z}/method Execute a method
TileEntityApi get_tile_entity GET /tile-entity/{world}/{x}/{y}/{z} Get tile entity
TileEntityApi list_tile_entities GET /tile-entity List tile entities
TileEntityApi modify_tile_entity PUT /tile-entity/{world}/{x}/{y}/{z} Modify tile entity
UniversalMarketApi list_market_items GET /universal-market/item List items
UserApi create_user POST /user Create a user
UserApi delete_user DELETE /user/{name} Delete a user
UserApi get_me GET /user/me Check info
UserApi get_users GET /user List users
UserApi login POST /user/login Login
UserApi logout POST /user/logout Logout
UserApi logout_redirect GET /user/logout
UserApi modify_user PUT /user/{name} Update a user
WebBooksApi create_web_book POST /web-books/book Create a book
WebBooksApi delete_web_book DELETE /web-books/book/{id} Delete a book
WebBooksApi get_web_book GET /web-books/book/{id} Get a book
WebBooksApi get_web_book_content GET /web-books/book/{id}/html Book HTML
WebBooksApi get_web_book_content_post POST /web-books/book/{id}/html Book HTML
WebBooksApi list_web_books GET /web-books/book List books
WebBooksApi modify_web_book PUT /web-books/book/{id} Modify a book
WorldApi create_world POST /world Create a world
WorldApi delete_world DELETE /world/{world} Delete a world
WorldApi execute_method POST /world/{world}/method Execute a method
WorldApi get_world GET /world/{world} Get a world
WorldApi list_worlds GET /world List worlds
WorldApi modify_world PUT /world/{world} Modify a world

Documentation For Models

Documentation For Authorization

ApiKeyHeader

  • Type: API key
  • API key parameter name: X-WebAPI-Key
  • Location: HTTP header

ApiKeyQuery

  • Type: API key
  • API key parameter name: key
  • Location: URL query string

Author

inithilian@gmail.com

About

Python client for the Web-API (https://github.com/Valandur/Web-API)

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 100.0%