Simplifying Data Fetching for the RageMP Server

Blake Bradford Avatar

·

Unofficial Python API Wrapper for Liberty.MP: Simplifying Data Fetching for the RageMP Server

Are you a developer looking for an easy way to fetch data from the Liberty.MP RageMP Server? Look no further! The LibertyWrapper is here to simplify your data fetching process. In this article, we will explore the installation, usage, and key features of this unofficial Python API wrapper.

Installation

Getting started with LibertyWrapper is as simple as running a pip command. Just open your terminal and type the following command:

shell
pip install libertywrapper

Once the installation is complete, you are ready to start using the LibertyWrapper in your Python projects.

Usage

To begin fetching data, you need to create a Wrapper object. Here’s an example:

“`python
import libertywrapper.bot

wrapper = libertywrapper.bot.Wrapper()
“`

If you have credentials from the Liberty.MP UCP (User Control Panel), you can also provide them while creating the Wrapper object:

python
wrapper = libertywrapper.bot.Wrapper(username='your_username', password='your_password')

Methods

The LibertyWrapper provides several useful methods for fetching data. Here’s an overview:

| Method name | Return | Requires credentials |
| ———————- | —————————— | ——————- |
| fetch_homepage() | General() object | ❌ |
| fetch_staff() | Staff() object | ❌ |
| fetch_online_players()| List of BriefUser() objects | ❌ |
| fetch_map_blips() | List of MapBlip() objects | ❌ |
| search_user(nickname) | List of UserSearchResult() objects | ❌ |
| fetch_factions() | List of Faction() objects | ❌ |
| fetch_user(nickname) | Player() object | ✔ |

These methods allow you to fetch various types of data from the Liberty.MP RageMP Server.

Example

Let’s take a look at an example that demonstrates how to use the LibertyWrapper to fetch data:

“`python
homepage = wrapper.fetch_homepage()

online_players = homepage.total_online
posts_number = homepage.total_posts

print(online_players, posts_number) # Output: integers

for user in homepage.top_users_activity:
print(user.name, user.level, user.avatar)
# Output: “username”, 10, https://imgur.com/example
print(user.playtime)
# Output: 10:23:00 (datetime.timedelta object)
“`

In this example, we fetch the homepage data using the fetch_homepage() method. We then access various properties of the returned object to retrieve information such as the total number of online players and the total number of posts. We also iterate over the top users and print their names, levels, avatars, and playtime.

Updates and Documentation

Please note that the LibertyWrapper is an ongoing project, and complete documentation will be added in future releases. Keep an eye out for updates to gain a deeper understanding of the wrapper’s capabilities and how to utilize them effectively.

In conclusion, the LibertyWrapper is an unofficial Python API wrapper that simplifies data fetching from the Liberty.MP RageMP Server. By following the installation instructions and utilizing the provided methods, developers can easily access various types of data. Stay tuned for updates and explore the complete documentation once it becomes available.

If you have any questions or need further assistance, feel free to ask. Happy coding!

References:
– LibertyWrapper GitHub Repository: Link
– Liberty.MP RageMP Server: Link

Leave a Reply

Your email address will not be published. Required fields are marked *