Skip to main content

Python wrapper for the Oxford Response API

Project description

oxrpy

A Python wrapper for the Oxford Response API.

Installation

Install from PyPI:

pip install oxrpy

Or from source:

pip install -r requirements.txt

Usage

from oxrpy import OxfordAPI

# Initialize with your server ID and key
api = OxfordAPI(server_id="your_server_id", server_key="your_server_key")

# Use all methods directly
server_info = api.get_server()
players = api.get_players()

# Or use grouped managers via properties
servers = api.servers
server_info = servers.get_server()
players = servers.get_players()
bans = servers.get_bans()

logs = api.logs
kill_logs = logs.get_killlogs()
mod_calls = logs.get_modcalls()

commands = api.commands
result = commands.execute_command("announce Hello!")

Advanced Configuration

# Default rate limiting (recommended for most users) - ~29 requests/second
# Note: Optimized for GET endpoints (30/sec limit). For command execution (1/sec limit),
# use custom rate limiting or disable rate limiting.
api = OxfordAPI(server_id="your_server_id", server_key="your_server_key")
# or explicitly:
api = OxfordAPI(server_id="your_server_id", server_key="your_server_key", rate_limit="auto")

# For heavy command usage (execute_command), use stricter rate limiting
api = OxfordAPI(server_id="your_server_id", server_key="your_server_key", rate_limit=1.0)

# Disable rate limiting entirely (use with caution)
api = OxfordAPI(server_id="your_server_id", server_key="your_server_key", rate_limit="none")

# Custom rate limiting (specify seconds between requests)
api = OxfordAPI(server_id="your_server_id", server_key="your_server_key", rate_limit=0.5)  # 0.5 seconds

You can also import the managers directly:

from oxrpy import OxfordAPI, Servers, Logs, Commands

api = OxfordAPI(server_id="your_server_id", server_key="your_server_key")

servers = Servers(api)
logs = Logs(api)
commands = Commands(api)

# Now use them
server_info = servers.get_server()
kill_logs = logs.get_killlogs()
result = commands.execute_command("kick PlayerOne")

Error Handling

from oxrpy import OxfordAPI, OxfordAPIError

api = OxfordAPI(server_id="your_id", server_key="your_key")

try:
    server_info = api.get_server()
    print("Server info:", server_info)
except OxfordAPIError as e:
    print(f"API Error: {e}")

Features

  • Configurable rate limiting ("auto" ~29 req/sec, "none", or custom seconds)
  • Comprehensive error handling with custom exceptions
  • Request timeouts
  • Logging support
  • Input validation

Supported Endpoints

  • get_server(): Returns general server information.
  • get_players(): Returns list of current players.
  • get_queue(): Returns the reserved server queue.
  • get_bans(): Returns active bans.
  • get_killlogs(): Returns recent kill logs (max 100 entries).
  • get_commandlogs(): Returns recent command execution logs.
  • get_modcalls(): Returns recent moderator call requests.
  • get_vehicles(): Returns vehicles currently spawned.
  • execute_command(command): Executes a permitted command (e.g., "announce Hello!"). get_robberies(): Returns the current status of all robbery locations (Name, Alarm, Available).
  • get_radiocalls(): Returns recent radio calls (last 100).

API Endpoints

get_server(): Returns general server information. Example response:

{
  "Name": "Oxford Roleplay",
  "StyledName": "Oxford RP",
  "Description": "UK emergency roleplay server",
  "Tags": ["UK", "RP"],
  "ThemeColour": "#ffffff",
  "OwnerId": 123456789,
  "CurrentPlayers": 18,
  "MaxPlayers": 32,
  "JoinCode": "OXFD-ABCD",
  "CreatedAt": 1700000000,
  "Packages": []
}

get_players(): Returns list of current players. Example response:

[
  {
    "Username": "PlayerOne",
    "DisplayName": "PlayerOne",
    "UserId": 12345,
    "Team": "Civilian",
    "WantedLevel": 0,
    "Permission": "Admin",
    "Callsign": "A12",
    "Location": "Near Oxford City Centre"
  }
]

get_queue(): Returns the reserved server queue. Example response:

{
  "total": 2,
  "users": [12345, 67890]
}

get_bans(): Returns active bans. Example response:

[
  {
    "UserId": 12345,
    "Username": "BannedUser",
    "Reason": "Fail RP",
    "BannedBy": "API",
    "BannedById": 2,
    "Expiry": 1701000000
  }
]

get_killlogs(): Returns recent kill logs (maximum 100 entries). Example response:

[
  {
    "Timestamp": 1700000100,
    "KillerUserId": 123,
    "KillerUsername": "OfficerA",
    "VictimUserId": 456,
    "VictimUsername": "SuspectB",
    "Distance": 42,
    "Weapon": "Taser"
  }
]

get_commandlogs(): Returns recent command execution logs. Example response:

[
  {
    "Timestamp": 1700000200,
    "UserId": 789,
    "Username": "AdminUser",
    "Command": "kick",
    "Args": ["PlayerOne"]
  }
]

get_modcalls(): Returns recent moderator call requests. Example response:

[
  {
    "Timestamp": 1700000300,
    "CallerUserId": 123,
    "CallerUsername": "PlayerOne",
    "CallerDisplayName": "Player One",
    "CaseId": "CASE-001",
    "Responders": [
      {
        "UserId": 789,
        "Username": "ModeratorA"
      }
    ]
  }
]

get_vehicles(): Returns vehicles currently spawned in the server. Example response:

[
  {
    "OwnerUserId": 123,
    "OwnerUsername": "PlayerOne",
    "Registration": "OX12 ABC",
    "Model": "Volvo XC90",
    "Electric": false,
    "ELS": true,
    "ELS_Style": "UK"
  }
]

execute_command(command): Executes a permitted command on the server. Example response:

{
  "message": "Command sent successfully"
}

get_robberies(): Returns the current status of all robbery locations. Example response:

[
  {
    "Name": "Berry",
    "Alarm": false,
    "Available": true
  },
  {
    "Name": "Jewellers",
    "Alarm": true,
    "Available": false
  }
]

get_radiocalls(): Returns recent radio calls. Example response:

[
  {
    "Timestamp": 1765814500,
    "AuthorUserId": 123456789,
    "AuthorUsername": "Officer_Johnson",
    "Location": "City Hall",
    "Description": "Armed robbery in progress",
    "Channel": "Police"
  }
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oxrpy-1.2.8.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oxrpy-1.2.8-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file oxrpy-1.2.8.tar.gz.

File metadata

  • Download URL: oxrpy-1.2.8.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for oxrpy-1.2.8.tar.gz
Algorithm Hash digest
SHA256 9158f768df92d6e78fee6da4e39b17d6efd17abf0bc89c9964eaa03d94043dde
MD5 5d8e4897bc2ae1e67f7fb9eca607661a
BLAKE2b-256 77ee2dfc07cca022753323d2f15fe2dfe3033998f6546e46f022c5090beb8680

See more details on using hashes here.

File details

Details for the file oxrpy-1.2.8-py3-none-any.whl.

File metadata

  • Download URL: oxrpy-1.2.8-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for oxrpy-1.2.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5b156be0d520876f5d03de5a01ff38aea5b0e91a1c835ac4108b73209f43322d
MD5 9a8f2b5d9c18089b8bc2b34f738a3cc0
BLAKE2b-256 5abb011aaa05865a149956a58131b68463aabdcc2612cf9585284811a7ef95e0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page