Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

MCPI-Revival/mcpi-central

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCPI-Central

A Minecraft Pi centralized API.

Getting started

Prerequisites

To use the API you need to have Python >= 3.7.x installed on your pi.

Installation

To install the API server and client, download or clone the repository and install the Python 3.x module using pip:

git clone https://github.com/MCPI-Devs/mcpi-central.git
cd mcpi-central
pip3 install .

API

The client API exposes the following methods through the APIClient class:

def login()

Authentication required Endpoint Method Query parameters
/auth GET code

Listens to http://localhost/callback, waits for a Discord OAuth callback and exchanges the code for the token. You can generate this callback by opening this link, logging-in and authorizing the app in a web browser.

def new_server(name, ip, port)

Authentication required Endpoint Method Query parameters
✔️ /servers/new GET name, ip, port

Adds a new server to the database. The server should not already exist, to update a server information, use update_server.

def update_server(name, ip, port)

Authentication required Endpoint Method Query parameters
✔️ /servers/update GET name, ip, port

Updates an existing server in the database. The user requesting this action should be the owner of the server.

def get_server(name)

Authentication required Endpoint Method Query parameters
/server GET name

Returns the information of an existing server in the database.

def get_servers()

Authentication required Endpoint Method Query parameters
/servers GET None

Returns the names of the first 50 servers in the database.

FAQ

Where can I find an example of this in action?

There is a test.py in the src folder. It contains a basic usage example.

Why doesn't the login function open a web browser directly?

Because some developers could want to use custom methods to open the authorization page, like WebViews.

Licensing

All the code of this project is licensed under the GNU General Public License version 2.0 (GPL-2.0).

All the documentation of this project is licensed under the Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

CC BY-SA 4.0