A Python library to interact with the Luogu online judge system
Project description
luogu-api-python
A Python implementation of the Luogu API.
Project Description
luogu-api-python is a Python library that provides an interface to interact with the Luogu online judge system. It allows users to programmatically manage problems, and user operations on Luogu. This library aims to simplify the process of automating tasks on Luogu by providing easy-to-use methods and classes.
Upstream docs: https://github.com/sjx233/luogu-api-docs
Installation
To install the package, use pip:
$ pip3 install luogu-api-python
To install the package from source, follow these steps:
-
Clone the repository:
$ git clone https://github.com/NekoOS-Group/luogu-api-python.git $ cd luogu-api-python
-
Install the package:
$ python3 -m pip install .
Usage
Synchronous API
Here is an example of how to use the package:
import pyLuogu
# Initialize the API without cookies
luogu = pyLuogu.luoguAPI()
# Get a list of problems
problems = luogu.get_problem_list().problems
for problem in problems:
print(problem.title)
Asynchronous API (Experimental)
The package also provides experimental support for async operations:
import asyncio
import pyLuogu
# Initialize the async API without cookies
luogu = pyLuogu.asyncLuoguAPI()
async def main():
async with luogu:
problems = (await luogu.get_problem_list()).problems
for problem in problems:
print(problem.title)
asyncio.run(main())
Note: The async API is currently experimental and subject to changes.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Pull Request
- Fork the repository on GitHub.
- Clone your forked repository to your local machine:
$ git clone https://github.com/your-username/luogu-api-python.git $ cd luogu-api-python
- Create a new branch for your feature or bugfix:
$ git checkout -b feature-or-bugfix-name
- Make your changes and commit them with a descriptive commit message:
$ git add . $ git commit -m "Description of your changes"
- Push your changes to your forked repository:
$ git push origin feature-or-bugfix-name
- Open a pull request on the original repository and provide a detailed description of your changes.
Reporting Issues
If you find a bug or have a feature request, please open an issue on GitHub. Provide as much detail as possible to help us understand and address the issue.
Todo List
API Implementation Status
Core APIs
-
Problem API
- get_problem_list
- get_team_problem_list
- get_problem
- get_problem_settings
- update_problem_settings
- update_testcases_settings
- create_problem
- delete_problem
- transfer_problem
- download_testcases
- upload_testcases
-
User API
- get_user
- get_user_info
- get_user_followings_list
- get_user_followers_list
- get_user_blacklist
- search_user
-
[-] User Operations
- login
- logout
- me
- submit_code
- get_created_problem_list
- get_created_problemset_list
- get_created_content_list
- update_setting
-
[-] Miscellaneous
- get_tags
- get_captcha
- sign_up
Alternative API Implementations
-
asyncLuoguAPI (Experimental)
- Async versions of all implemented core APIs
- Performance optimizations
- Comprehensive error handling
-
staticLuoguAPI
- Initial implementation
- Documentation
Test Cases and Documentation
Note: Test suite and documentation are planned for implementation after API features are stabilized. This includes:
- Comprehensive test coverage for both sync and async APIs
- API reference documentation with examples
- Integration test scenarios
- Development guides and best practices
These will be prioritized once the core functionality reaches a stable state.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file luogu_api_python-0.0.2.tar.gz.
File metadata
- Download URL: luogu_api_python-0.0.2.tar.gz
- Upload date:
- Size: 55.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
375034c3936e85de7cb4e15aa93792a31b76d3e4e28fa958b6a40042d2f06b65
|
|
| MD5 |
8ba07f8c444e5122f7df593462ea265a
|
|
| BLAKE2b-256 |
08256756d9bb762fd9564070bb63a171b2aa6b0d7359aa40b98b613c3df3a139
|
File details
Details for the file luogu_api_python-0.0.2-py3-none-any.whl.
File metadata
- Download URL: luogu_api_python-0.0.2-py3-none-any.whl
- Upload date:
- Size: 45.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
145760e58287c5c216c20e4b5de4f256bc2620a312239b1de752c1ee40067bc4
|
|
| MD5 |
337bc1ce6cee7d9172c6d7f12ed375be
|
|
| BLAKE2b-256 |
1659b5375e133f97c75e077eed48ffa7a8340b456de605c7a60e1c122e192154
|