/webapi-client-python

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

Primary LanguagePython

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 (https:/github.com/Valandur/Web-API/tree/master/docs/DATA.md)

Swagger

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

  • API version: 5.4.2-S7.1.0
  • 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
configuration = swagger_client.Configuration()
configuration.api_key['X-WebAPI-Key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['X-WebAPI-Key'] = 'Bearer'
# Configure API key authorization: ApiKeyQuery
configuration = swagger_client.Configuration()
configuration.api_key['key'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['key'] = 'Bearer'

# create an instance of the API class
api_instance = swagger_client.ActiveTimeApi(swagger_client.ApiClient(configuration))
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
HistoryApi get_chat GET /history/message Get message history
HistoryApi get_commands GET /history/cmd Get command history
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
InventoryApi add_element POST /megamenus/menu/{mid}/{page}/{y}/{x} Add element
InventoryApi close_renderer DELETE /megamenus/render/{mid}/{viewer} Close renderer
InventoryApi create_menu POST /megamenus/menu Create menu
InventoryApi create_renderer POST /megamenus/render/{mid} Create menu
InventoryApi delete_element DELETE /megamenus/menu/{mid}/{page}/{y}/{x} Delete menu
InventoryApi delete_menu DELETE /megamenus/menu/{mid} Delete menu
InventoryApi delete_page DELETE /megamenus/menu/{mid}/{page} Delete a page of elements
InventoryApi delete_renderer DELETE /megamenus/renderer/{mid} Delete menu
InventoryApi find_renderer GET /megamenus/render/find/{viewer} Get the renderer for viewer
InventoryApi get_element GET /megamenus/menu/{mid}/{page}/{y}/{x} Get menu
InventoryApi get_menu GET /megamenus/menu/{mid} Get menu
InventoryApi get_page GET /megamenus/menu/{mid}/{page} Reads a single page of elements
InventoryApi get_renderer GET /megamenus/render/{mid} Get the renderer for this menu
InventoryApi list_menus GET /megamenus/menu List menus
InventoryApi list_renderer GET /megamenus/render List renderer
InventoryApi open_renderer PUT /megamenus/render/{mid}/{viewer} Open renderer
InventoryApi set_element PUT /megamenus/menu/{mid}/{page}/{y}/{x} Update menu
InventoryApi set_menu PUT /megamenus/menu/{mid} Update menu
MapApi get_map GET /map/{world}/{x}/{z} Get a map tile
MegaMenusApi add_element POST /megamenus/menu/{mid}/{page}/{y}/{x} Add element
MegaMenusApi close_renderer DELETE /megamenus/render/{mid}/{viewer} Close renderer
MegaMenusApi create_menu POST /megamenus/menu Create menu
MegaMenusApi create_renderer POST /megamenus/render/{mid} Create menu
MegaMenusApi delete_element DELETE /megamenus/menu/{mid}/{page}/{y}/{x} Delete menu
MegaMenusApi delete_menu DELETE /megamenus/menu/{mid} Delete menu
MegaMenusApi delete_page DELETE /megamenus/menu/{mid}/{page} Delete a page of elements
MegaMenusApi delete_renderer DELETE /megamenus/renderer/{mid} Delete menu
MegaMenusApi find_renderer GET /megamenus/render/find/{viewer} Get the renderer for viewer
MegaMenusApi get_element GET /megamenus/menu/{mid}/{page}/{y}/{x} Get menu
MegaMenusApi get_menu GET /megamenus/menu/{mid} Get menu
MegaMenusApi get_page GET /megamenus/menu/{mid}/{page} Reads a single page of elements
MegaMenusApi get_renderer GET /megamenus/render/{mid} Get the renderer for this menu
MegaMenusApi list_menus GET /megamenus/menu List menus
MegaMenusApi list_renderer GET /megamenus/render List renderer
MegaMenusApi open_renderer PUT /megamenus/render/{mid}/{viewer} Open renderer
MegaMenusApi set_element PUT /megamenus/menu/{mid}/{page}/{y}/{x} Update menu
MegaMenusApi set_menu PUT /megamenus/menu/{mid} Update menu
MenuApi add_element POST /megamenus/menu/{mid}/{page}/{y}/{x} Add element
MenuApi close_renderer DELETE /megamenus/render/{mid}/{viewer} Close renderer
MenuApi create_menu POST /megamenus/menu Create menu
MenuApi create_renderer POST /megamenus/render/{mid} Create menu
MenuApi delete_element DELETE /megamenus/menu/{mid}/{page}/{y}/{x} Delete menu
MenuApi delete_menu DELETE /megamenus/menu/{mid} Delete menu
MenuApi delete_page DELETE /megamenus/menu/{mid}/{page} Delete a page of elements
MenuApi delete_renderer DELETE /megamenus/renderer/{mid} Delete menu
MenuApi find_renderer GET /megamenus/render/find/{viewer} Get the renderer for viewer
MenuApi get_element GET /megamenus/menu/{mid}/{page}/{y}/{x} Get menu
MenuApi get_menu GET /megamenus/menu/{mid} Get menu
MenuApi get_page GET /megamenus/menu/{mid}/{page} Reads a single page of elements
MenuApi get_renderer GET /megamenus/render/{mid} Get the renderer for this menu
MenuApi list_menus GET /megamenus/menu List menus
MenuApi list_renderer GET /megamenus/render List renderer
MenuApi open_renderer PUT /megamenus/render/{mid}/{viewer} Open renderer
MenuApi set_element PUT /megamenus/menu/{mid}/{page}/{y}/{x} Update menu
MenuApi set_menu PUT /megamenus/menu/{mid} Update menu
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
UIApi add_element POST /megamenus/menu/{mid}/{page}/{y}/{x} Add element
UIApi close_renderer DELETE /megamenus/render/{mid}/{viewer} Close renderer
UIApi create_menu POST /megamenus/menu Create menu
UIApi create_renderer POST /megamenus/render/{mid} Create menu
UIApi delete_element DELETE /megamenus/menu/{mid}/{page}/{y}/{x} Delete menu
UIApi delete_menu DELETE /megamenus/menu/{mid} Delete menu
UIApi delete_page DELETE /megamenus/menu/{mid}/{page} Delete a page of elements
UIApi delete_renderer DELETE /megamenus/renderer/{mid} Delete menu
UIApi find_renderer GET /megamenus/render/find/{viewer} Get the renderer for viewer
UIApi get_element GET /megamenus/menu/{mid}/{page}/{y}/{x} Get menu
UIApi get_menu GET /megamenus/menu/{mid} Get menu
UIApi get_page GET /megamenus/menu/{mid}/{page} Reads a single page of elements
UIApi get_renderer GET /megamenus/render/{mid} Get the renderer for this menu
UIApi list_menus GET /megamenus/menu List menus
UIApi list_renderer GET /megamenus/render List renderer
UIApi open_renderer PUT /megamenus/render/{mid}/{viewer} Open renderer
UIApi set_element PUT /megamenus/menu/{mid}/{page}/{y}/{x} Update menu
UIApi set_menu PUT /megamenus/menu/{mid} Update menu
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
VShopsApi add_shop_item POST /vshop/shop/{id}/item Add Shop Item
VShopsApi create_shop POST /vshop/shop Create Shops
VShopsApi delete_shop DELETE /vshop/shop/{id} Delete a Shop
VShopsApi delete_shop_item DELETE /vshop/shop/{id}/item/{item} Removes a Shop Item
VShopsApi get_shop GET /vshop/shop/{id} Get a Shop
VShopsApi get_shop_item GET /vshop/shop/{id}/item/{item} Get a Shop
VShopsApi list_shop_items GET /vshop/shop/{id}/item List Shop Items
VShopsApi list_shops GET /vshop/shop List Shops
VShopsApi update_shop PUT /vshop/shop/{id} Change Shop
VShopsApi update_shop_item PUT /vshop/shop/{id}/item/{item} Change Shop Item
VillagerShopsApi add_shop_item POST /vshop/shop/{id}/item Add Shop Item
VillagerShopsApi create_shop POST /vshop/shop Create Shops
VillagerShopsApi delete_shop DELETE /vshop/shop/{id} Delete a Shop
VillagerShopsApi delete_shop_item DELETE /vshop/shop/{id}/item/{item} Removes a Shop Item
VillagerShopsApi get_shop GET /vshop/shop/{id} Get a Shop
VillagerShopsApi get_shop_item GET /vshop/shop/{id}/item/{item} Get a Shop
VillagerShopsApi list_shop_items GET /vshop/shop/{id}/item List Shop Items
VillagerShopsApi list_shops GET /vshop/shop List Shops
VillagerShopsApi update_shop PUT /vshop/shop/{id} Change Shop
VillagerShopsApi update_shop_item PUT /vshop/shop/{id}/item/{item} Change Shop Item
VillagerShopsApi add_shop_item POST /vshop/shop/{id}/item Add Shop Item
VillagerShopsApi create_shop POST /vshop/shop Create Shops
VillagerShopsApi delete_shop DELETE /vshop/shop/{id} Delete a Shop
VillagerShopsApi delete_shop_item DELETE /vshop/shop/{id}/item/{item} Removes a Shop Item
VillagerShopsApi get_shop GET /vshop/shop/{id} Get a Shop
VillagerShopsApi get_shop_item GET /vshop/shop/{id}/item/{item} Get a Shop
VillagerShopsApi list_shop_items GET /vshop/shop/{id}/item List Shop Items
VillagerShopsApi list_shops GET /vshop/shop List Shops
VillagerShopsApi update_shop PUT /vshop/shop/{id} Change Shop
VillagerShopsApi update_shop_item PUT /vshop/shop/{id}/item/{item} Change Shop Item
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