Skip to content

Repository files navigation

Web-API - C# 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 C# SDK is automatically generated by the Swagger Codegen project:

  • API version: 5.4.2-S7.1.0
  • SDK version: 1.0.0
  • Build package: io.swagger.codegen.languages.CSharpClientCodegen For more information, please visit https://github.com/Valandur

Frameworks supported

  • .NET 4.0 or later
  • Windows Phone 7.1 (Mango)

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes

NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742

Installation

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

usingIO.Swagger.Api;usingIO.Swagger.Client;usingIO.Swagger.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out IO.Swagger.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Getting Started

usingSystem;usingSystem.Diagnostics;usingIO.Swagger.Api;usingIO.Swagger.Client;usingIO.Swagger.Model;namespaceExample{publicclassExample{publicvoidmain(){// Configure API key authorization: ApiKeyHeaderConfiguration.Default.ApiKey.Add("X-WebAPI-Key","YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.ApiKeyPrefix.Add("X-WebAPI-Key", "Bearer");// Configure API key authorization: ApiKeyQueryConfiguration.Default.ApiKey.Add("key","YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.ApiKeyPrefix.Add("key", "Bearer");varapiInstance=newActiveTimeApi();vardetails=true;// bool? | Add to include additional details, omit or false otherwise (optional) varaccept=accept_example;// string | Override the 'Accept' request header (useful for debugging your requests) (optional) varpretty=true;// bool? | Add to make the Web-API pretty print the response (useful for debugging your requests) (optional) try{// Server reportServerReportresult=apiInstance.GetServerReport(details,accept,pretty);Debug.WriteLine(result);}catch(Exceptione){Debug.Print("Exception when calling ActiveTimeApi.GetServerReport: "+e.Message);}}}}

Documentation for API Endpoints

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

ClassMethodHTTP requestDescription
ActiveTimeApiGetServerReportGET /active-timeServer report
ActiveTimeApiGetUserReportGET /active-time/user/{uuid}User report
BlockApiCreateBlockOperationPOST /block/opCreate a block operation
BlockApiDeleteBlockOperationDELETE /block/op/{uuid}Stop a block operation
BlockApiGetBlockGET /block/{world}/{x}/{y}/{z}Get a block
BlockApiGetBlockOperationGET /block/op/{uuid}Get a block operation
BlockApiListBlockOperationsGET /block/opList block operations
BlockApiModifyBlockOperationPUT /block/op/{uuid}Modify a block operation
ChunkApiCreateChunkAtPOST /chunk/{world}/{x}/{z}Load & Generate a chunk
ChunkApiGetChunkAtGET /chunk/{world}/{x}/{z}Get a chunk
ChunkApiListChunksGET /chunk/{world}List chunks
CmdSchedulerApiDeleteTaskDELETE /cmd-scheduler/{name}Delete a task
CmdSchedulerApiListTasksGET /cmd-schedulerList tasks
CommandApiGetCommandGET /cmd/{cmd}Get a command
CommandApiListCommandsGET /cmdList commands
CommandApiRunCommandsPOST /cmdExecute a command
EconomyApiGetAccountGET /economy/account/{id}List currencies
EconomyApiGetCurrenciesGET /economy/currencyList currencies
EntityApiCreateEntityPOST /entitySpawn an entity
EntityApiExecuteMethodPOST /entity/{entity}/methodExecute a method
EntityApiGetEntityGET /entity/{entity}Get entity
EntityApiListEntitiesGET /entityList entities
EntityApiModifyEntityPUT /entity/{entity}Modify an entity
EntityApiRemoveEntityDELETE /entity/{entity}Destroy an entity
HistoryApiGetChatGET /history/messageGet message history
HistoryApiGetCommandsGET /history/cmdGet command history
InfoApiGetInfoGET /infoServer info
InfoApiGetStatsGET /info/statsServer stats
InfoApiListServletsGET /info/servletsList servlets
InteractiveMessageApiGetMessageGET /interactive-message/{uuid}Get a message
InteractiveMessageApiListMessagesGET /interactive-messageList messages
InteractiveMessageApiSendMessagePOST /interactive-messageSend a message
InventoryApiAddElementPOST /megamenus/menu/{mid}/{page}/{y}/{x}Add element
InventoryApiCloseRendererDELETE /megamenus/render/{mid}/{viewer}Close renderer
InventoryApiCreateMenuPOST /megamenus/menuCreate menu
InventoryApiCreateRendererPOST /megamenus/render/{mid}Create menu
InventoryApiDeleteElementDELETE /megamenus/menu/{mid}/{page}/{y}/{x}Delete menu
InventoryApiDeleteMenuDELETE /megamenus/menu/{mid}Delete menu
InventoryApiDeletePageDELETE /megamenus/menu/{mid}/{page}Delete a page of elements
InventoryApiDeleteRendererDELETE /megamenus/renderer/{mid}Delete menu
InventoryApiFindRendererGET /megamenus/render/find/{viewer}Get the renderer for viewer
InventoryApiGetElementGET /megamenus/menu/{mid}/{page}/{y}/{x}Get menu
InventoryApiGetMenuGET /megamenus/menu/{mid}Get menu
InventoryApiGetPageGET /megamenus/menu/{mid}/{page}Reads a single page of elements
InventoryApiGetRendererGET /megamenus/render/{mid}Get the renderer for this menu
InventoryApiListMenusGET /megamenus/menuList menus
InventoryApiListRendererGET /megamenus/renderList renderer
InventoryApiOpenRendererPUT /megamenus/render/{mid}/{viewer}Open renderer
InventoryApiSetElementPUT /megamenus/menu/{mid}/{page}/{y}/{x}Update menu
InventoryApiSetMenuPUT /megamenus/menu/{mid}Update menu
MapApiGetMapGET /map/{world}/{x}/{z}Get a map tile
MegaMenusApiAddElementPOST /megamenus/menu/{mid}/{page}/{y}/{x}Add element
MegaMenusApiCloseRendererDELETE /megamenus/render/{mid}/{viewer}Close renderer
MegaMenusApiCreateMenuPOST /megamenus/menuCreate menu
MegaMenusApiCreateRendererPOST /megamenus/render/{mid}Create menu
MegaMenusApiDeleteElementDELETE /megamenus/menu/{mid}/{page}/{y}/{x}Delete menu
MegaMenusApiDeleteMenuDELETE /megamenus/menu/{mid}Delete menu
MegaMenusApiDeletePageDELETE /megamenus/menu/{mid}/{page}Delete a page of elements
MegaMenusApiDeleteRendererDELETE /megamenus/renderer/{mid}Delete menu
MegaMenusApiFindRendererGET /megamenus/render/find/{viewer}Get the renderer for viewer
MegaMenusApiGetElementGET /megamenus/menu/{mid}/{page}/{y}/{x}Get menu
MegaMenusApiGetMenuGET /megamenus/menu/{mid}Get menu
MegaMenusApiGetPageGET /megamenus/menu/{mid}/{page}Reads a single page of elements
MegaMenusApiGetRendererGET /megamenus/render/{mid}Get the renderer for this menu
MegaMenusApiListMenusGET /megamenus/menuList menus
MegaMenusApiListRendererGET /megamenus/renderList renderer
MegaMenusApiOpenRendererPUT /megamenus/render/{mid}/{viewer}Open renderer
MegaMenusApiSetElementPUT /megamenus/menu/{mid}/{page}/{y}/{x}Update menu
MegaMenusApiSetMenuPUT /megamenus/menu/{mid}Update menu
MenuApiAddElementPOST /megamenus/menu/{mid}/{page}/{y}/{x}Add element
MenuApiCloseRendererDELETE /megamenus/render/{mid}/{viewer}Close renderer
MenuApiCreateMenuPOST /megamenus/menuCreate menu
MenuApiCreateRendererPOST /megamenus/render/{mid}Create menu
MenuApiDeleteElementDELETE /megamenus/menu/{mid}/{page}/{y}/{x}Delete menu
MenuApiDeleteMenuDELETE /megamenus/menu/{mid}Delete menu
MenuApiDeletePageDELETE /megamenus/menu/{mid}/{page}Delete a page of elements
MenuApiDeleteRendererDELETE /megamenus/renderer/{mid}Delete menu
MenuApiFindRendererGET /megamenus/render/find/{viewer}Get the renderer for viewer
MenuApiGetElementGET /megamenus/menu/{mid}/{page}/{y}/{x}Get menu
MenuApiGetMenuGET /megamenus/menu/{mid}Get menu
MenuApiGetPageGET /megamenus/menu/{mid}/{page}Reads a single page of elements
MenuApiGetRendererGET /megamenus/render/{mid}Get the renderer for this menu
MenuApiListMenusGET /megamenus/menuList menus
MenuApiListRendererGET /megamenus/renderList renderer
MenuApiOpenRendererPUT /megamenus/render/{mid}/{viewer}Open renderer
MenuApiSetElementPUT /megamenus/menu/{mid}/{page}/{y}/{x}Update menu
MenuApiSetMenuPUT /megamenus/menu/{mid}Update menu
PermissionApiGetCollectionGET /permission/collection/{id}Get collection
PermissionApiGetSubjectGET /permission/collection/{id}/subject/{subId}Get subject
PermissionApiListCollectionsGET /permission/collectionList collections
PermissionApiListSubjectsGET /permission/collection/{id}/subjectList subjects
PlayerApiExecuteMethodPOST /player/{player}/methodExecute a method
PlayerApiGetPlayerGET /player/{player}Get a player
PlayerApiListPlayersGET /playerList players
PlayerApiModifyPlayerPUT /player/{player}Modify a player
PluginApiChangePluginConfigPOST /plugin/{plugin}/configChange plugin configs
PluginApiGetPluginGET /plugin/{plugin}Get a plugin
PluginApiGetPluginConfigGET /plugin/{plugin}/configGet plugin configs
PluginApiListPluginsGET /pluginList plugins
PluginApiTogglePluginPUT /plugin/{plugin}Toggle a plugin
RecipeApiListRecipesGET /recipeList recipes
RedProtectApiCreateRegionPOST /red-protect/regionCreate a region
RedProtectApiDeleteRegionDELETE /red-protect/region/{id}Delete a region
RedProtectApiGetRegionGET /red-protect/region/{id}Get a region
RedProtectApiListRegionsGET /red-protect/regionList regions
RedProtectApiModifyRegionPUT /red-protect/region/{id}Modify a region
RegistryApiGetRegistryGET /registry/{class}Get a catalog type
ServerApiListPropertiesGET /server/propertiesList server properties
ServerApiModifyPropertiesPUT /server/propertiesModify server properties
TileEntityApiExecuteMethodPOST /tile-entity/{world}/{x}/{y}/{z}/methodExecute a method
TileEntityApiGetTileEntityGET /tile-entity/{world}/{x}/{y}/{z}Get tile entity
TileEntityApiListTileEntitiesGET /tile-entityList tile entities
TileEntityApiModifyTileEntityPUT /tile-entity/{world}/{x}/{y}/{z}Modify tile entity
UIApiAddElementPOST /megamenus/menu/{mid}/{page}/{y}/{x}Add element
UIApiCloseRendererDELETE /megamenus/render/{mid}/{viewer}Close renderer
UIApiCreateMenuPOST /megamenus/menuCreate menu
UIApiCreateRendererPOST /megamenus/render/{mid}Create menu
UIApiDeleteElementDELETE /megamenus/menu/{mid}/{page}/{y}/{x}Delete menu
UIApiDeleteMenuDELETE /megamenus/menu/{mid}Delete menu
UIApiDeletePageDELETE /megamenus/menu/{mid}/{page}Delete a page of elements
UIApiDeleteRendererDELETE /megamenus/renderer/{mid}Delete menu
UIApiFindRendererGET /megamenus/render/find/{viewer}Get the renderer for viewer
UIApiGetElementGET /megamenus/menu/{mid}/{page}/{y}/{x}Get menu
UIApiGetMenuGET /megamenus/menu/{mid}Get menu
UIApiGetPageGET /megamenus/menu/{mid}/{page}Reads a single page of elements
UIApiGetRendererGET /megamenus/render/{mid}Get the renderer for this menu
UIApiListMenusGET /megamenus/menuList menus
UIApiListRendererGET /megamenus/renderList renderer
UIApiOpenRendererPUT /megamenus/render/{mid}/{viewer}Open renderer
UIApiSetElementPUT /megamenus/menu/{mid}/{page}/{y}/{x}Update menu
UIApiSetMenuPUT /megamenus/menu/{mid}Update menu
UniversalMarketApiListMarketItemsGET /universal-market/itemList items
UserApiCreateUserPOST /userCreate a user
UserApiDeleteUserDELETE /user/{name}Delete a user
UserApiGetMeGET /user/meCheck info
UserApiGetUsersGET /userList users
UserApiLoginPOST /user/loginLogin
UserApiLogoutPOST /user/logoutLogout
UserApiLogoutRedirectGET /user/logout
UserApiModifyUserPUT /user/{name}Update a user
VShopsApiAddShopItemPOST /vshop/shop/{id}/itemAdd Shop Item
VShopsApiCreateShopPOST /vshop/shopCreate Shops
VShopsApiDeleteShopDELETE /vshop/shop/{id}Delete a Shop
VShopsApiDeleteShopItemDELETE /vshop/shop/{id}/item/{item}Removes a Shop Item
VShopsApiGetShopGET /vshop/shop/{id}Get a Shop
VShopsApiGetShopItemGET /vshop/shop/{id}/item/{item}Get a Shop
VShopsApiListShopItemsGET /vshop/shop/{id}/itemList Shop Items
VShopsApiListShopsGET /vshop/shopList Shops
VShopsApiUpdateShopPUT /vshop/shop/{id}Change Shop
VShopsApiUpdateShopItemPUT /vshop/shop/{id}/item/{item}Change Shop Item
VillagerShopsApiAddShopItemPOST /vshop/shop/{id}/itemAdd Shop Item
VillagerShopsApiAddShopItem_0POST /vshop/shop/{id}/itemAdd Shop Item
VillagerShopsApiCreateShopPOST /vshop/shopCreate Shops
VillagerShopsApiCreateShop_0POST /vshop/shopCreate Shops
VillagerShopsApiDeleteShopDELETE /vshop/shop/{id}Delete a Shop
VillagerShopsApiDeleteShopItemDELETE /vshop/shop/{id}/item/{item}Removes a Shop Item
VillagerShopsApiDeleteShopItem_0DELETE /vshop/shop/{id}/item/{item}Removes a Shop Item
VillagerShopsApiDeleteShop_0DELETE /vshop/shop/{id}Delete a Shop
VillagerShopsApiGetShopGET /vshop/shop/{id}Get a Shop
VillagerShopsApiGetShopItemGET /vshop/shop/{id}/item/{item}Get a Shop
VillagerShopsApiGetShopItem_0GET /vshop/shop/{id}/item/{item}Get a Shop
VillagerShopsApiGetShop_0GET /vshop/shop/{id}Get a Shop
VillagerShopsApiListShopItemsGET /vshop/shop/{id}/itemList Shop Items
VillagerShopsApiListShopItems_0GET /vshop/shop/{id}/itemList Shop Items
VillagerShopsApiListShopsGET /vshop/shopList Shops
VillagerShopsApiListShops_0GET /vshop/shopList Shops
VillagerShopsApiUpdateShopPUT /vshop/shop/{id}Change Shop
VillagerShopsApiUpdateShopItemPUT /vshop/shop/{id}/item/{item}Change Shop Item
VillagerShopsApiUpdateShopItem_0PUT /vshop/shop/{id}/item/{item}Change Shop Item
VillagerShopsApiUpdateShop_0PUT /vshop/shop/{id}Change Shop
WebBooksApiCreateWebBookPOST /web-books/bookCreate a book
WebBooksApiDeleteWebBookDELETE /web-books/book/{id}Delete a book
WebBooksApiGetWebBookGET /web-books/book/{id}Get a book
WebBooksApiGetWebBookContentGET /web-books/book/{id}/htmlBook HTML
WebBooksApiGetWebBookContentPostPOST /web-books/book/{id}/htmlBook HTML
WebBooksApiListWebBooksGET /web-books/bookList books
WebBooksApiModifyWebBookPUT /web-books/book/{id}Modify a book
WorldApiCreateWorldPOST /worldCreate a world
WorldApiDeleteWorldDELETE /world/{world}Delete a world
WorldApiExecuteMethodPOST /world/{world}/methodExecute a method
WorldApiGetWorldGET /world/{world}Get a world
WorldApiListWorldsGET /worldList worlds
WorldApiModifyWorldPUT /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

About

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

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages