Interact with Modrinth's Labrinth API through Python.
Project description
Modrinth.py
Interact with Modrinth's Labrinth API through Python.
To-do
- Search for projects
- (Un)follow projects
- Basic authentication
- Documentation
- Create and delete projects
- Modify projects (PATCH requests to
/project/{id|slug}
and/project/{id|slug}/gallery
requests) - Built-in function to get multiple projects at once
- Project dependencies management
- Get project versions
- Get project details
- Create, modify, and delete projects (POST requests to
/version
and PATCH/DELETE to/version/{id}
) - Built-in function to get multiple versions
- Upload files to version
- Get a version from
sha1
orsha512
- Delete a file from its hash (DELETE requests to
/version_file
) - Get latest project(s) version(s)
- Get project version from hash
- Read user(s) data
- Delete and modify user data
- Read team data
- Add users to teams
- Join a team
- Modify user roles/perms within a team
- Remove user(s) from a team
- Change team owner
- Get categories, mod loaders, game versions, licenses, donation sites, and report types. ("tags")
- Support for more branches (ie. staging)
API Documentation
Usage
Through pip
pip install modrinth
View the project page on GitHub or pip
Users (Users
)
User data includes their username, name, email, bio, etc. this class hold functions and objects that relate to authentication and user data.
Authentication is done using a GitHub token, in the request header. Modrinth.py will automatically add the token to the request header and Labrinth's documentation says that the token is required for these requests:
- those which create data (such as version creation)
- those which modify data (such as editing a project)
- those which access private data (such as draft projects and notifications)
For more information, see: https://docs.modrinth.com/api-spec/#section/Authentication
User
user = modrinth.Users.ModrinthUser('yyy') # Find a user with the username/ID yyy
print(user.name) # Print the user's name
Authentication
authedUser = modrinth.Users.AuthenticatedUser('ghp_xxx') # GitHub token
# After authentication we can interact with projects, such as following and unfollowing a mod.
project = modrinth.Projects.ModrinthProject('zzz')
project.unfollow(authedUser)
Getting project information
Projects (Projects
)
The Projects
class is used to interact with projects. These interactions include getting a project from slug/ID, searching for projects, and (un)following a project. With more projects being planned, this class will be expanded. Projects are mods and modpacks.
Searching for projects
projects = modrinth.Projects.Search('mod')
print(projects.hits[0].name) # Prints the name of the first project found
Get project from slug/ID
project = modrinth.Projects.ModrinthProject('zzz')
print(project.name) # Prints the name of the project
Getting version information
Versions (Versions
)
The Versions
class is used to interact with versions. It currently can only get version information, such as downloads and files.
Get version information
The suggested way to get a version is through the Project.ModrinthProject.getVersion()
shorthand, although you can also use the Versions.ModrinthVersion
class directly.
project = modrinth.Projects.ModrinthProject('zzz') # Get a project from slug/ID
version = project.getVersion('aaa111bb') # Get the version with ID 'aaa111bb'
primaryFile = version.getPrimaryFile() # Returns the hash of the primary file
print(version.getDownload(primaryFile)) # Returns the download URL of the primary file
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
Built Distribution
File details
Details for the file modrinth-0.1.5.tar.gz
.
File metadata
- Download URL: modrinth-0.1.5.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42f21585311be1422ca89a4aee2acf024fbea6edbfd9f2a10f74861029844cdd |
|
MD5 | fe61bb7b6132169e9dddfb0683c1200c |
|
BLAKE2b-256 | 953cafa6d8216a25bd6e17a9c7fd1f061b79890910c18831b89987795577a48b |
File details
Details for the file modrinth-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: modrinth-0.1.5-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7741815448a82e0c376656be0811ba73691e3d8e17d12eba159caf1151fd3ec |
|
MD5 | d2bca1647d746db7083297b323660374 |
|
BLAKE2b-256 | 78b542eaa53bef8b132c2a242486d77cb79e691382cbb06adab923b7f0181013 |