Skip to content

Missile05/erlcPY

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 

Repository files navigation

Important

This project has been abandoned, however due to no new features being added to the API as of September 1st 2024, should still continue to function.


ER:LC API Wrapper

The first Python API wrapper for the ER:LC API.

Important

Full coverage of the ER:LC API as of July 20th 2024.

Capabilities:

  • Run ER:LC Commands Remotely
  • Show Server Information
  • Show Current Players
  • Show Join Logs
  • Show Queue Information
  • Show Kill logs
  • Show Command Logs
  • Show Mod Calls
  • Show Banned Players
  • Show Current Vehicles
  • Dynamic Rate Limiting

Installation

First you need to install the package.

pip install erlcpy

Setup

Setup is easy:

from erlcpy import command

# Define your API credentials
base_url = "https://api.policeroleplay.community/v1" # !! Never change this !!
server_key = "your_server_key" # API key from a ER:LC server
global_api_key = "your_global_key" # !! Remove if unnecessary !!

# Instantiate the objects

## Create an instance of the Command class to use command related functions
command_api = Command(base_url, server_key) # Add global_api_key if necessary (normally not)

## Create an instance of the Information class to use information related functions
info_api = Information(base_url, server_key) # Add global_api_key if necessary (normally not)

Now you can start using the API - here are some examples:

# Create an instance of the Command Class with your credentials
command_api = Command(base_url, server_key)

# Use the send_command method to send a remote command
try:
    response = command_api.send_command(":kick missile") #Example

    # Handle the API's Response
    if response:
        print(f"Command sent successfully. {response}")
except Exception as e:
    # Handle any Errors
    print(f"An error occurred: {e}")
# Create an instance of the Information class
info_api = Information(base_url, server_key) # Add global_api_key if necessary (normally not)

try:
    # Use the get_queue method to retrieve the queue information of your server
    queue_info = info_api.get_queue()

    # Handle the queue information
    if queue_info:
        print("Queue information:")
        print(queue_info)
        print(f"Queue info: {queue_info}")
    else:
        print("Failed to retrieve queue information.")
except Exception as e:
    # Print the error message
    print(f"An error occurred: {e}")

Classes and their methods:

Remote Commands

Create an instance ( command_api = Command(base_url, server_key) )
  • command_api.send_command(command)

Logs

  • get_join_logs()
  • get_command_logs()
  • get_kill_logs()
  • get_bans()
  • get_mod_calls()

Information

Create an instance ( info_api = Information(base_url, server_key) )
  • info_api.get_server_info()
  • info_api.get_players()
  • info_api.get_queue()
  • info_api.get_vehicles()

Links

Credits

Head Developer / Project Lead - Missile05

Documentation Inspiration - 0xRaptor

Documentation / Former Project Lead - Arimuon

Former Collaborator - Yodmin