Skip to main content

A wrapper for the Eternal (CurseForge) API

Project description

CurseForgeAPy

GitHub issues GitHub stars GitHub license

CurseForgeAPy is a Python package that provides a wrapper for the CurseForge API / Eternal API. With CurseForgeAPy, you can easily access and interact with the API in your Python scripts and applications. Currently, the entire API has been wrapped and each data structure has been reconstructed into seperate classes, which can be found within schemaClasses.py.

Installation

To install CurseForgeAPy, simply use pip:

pip install CurseForgeAPy

Usage

To use CurseForgeAPy, you will need to obtain an API key from CurseForge. You can do this by creating an account on CurseForge and requesting an API key from the developer portal.

Once you have obtained an API key, you can use CurseForgeAPy as follows:

from CurseForgeAPy import CurseForgeAPI

# Instantiate the CurseForgeAPy client
client = CurseForgeAPI('YOUR_API_KEY')

# Use the client to make API requests
response = client.getGames() # -> returns a GetGamesResponse

print(response)

Documentation

For full documentation of the CurseForge API, please see the official CurseForge API documentation at https://docs.curseforge.com/. Docstrings are also available for some functions, however complete docstring creation for all functions is ongoing.

Examples

Here are some examples of how you can use CurseForgeAPy to access and interact with the CurseForge API:

Games

# get all games
games = cf.getGames()

# get specific game
game = cf.getGame(432)

# get version of specific game
versions = cf.getVersions(432)

# get version type of specific game
versionTypes = cf.getVersionTypes(432)

# get all mod categories of specific game
categories = cf.getCategories(432)

Mods

import CurseForgeAPy.schemaClasses as schemas

# search for mods within specific game
searchResults = cf.searchMods(432)

# get specific mod
mod = cf.getMod(729219)

# get an array of mods from ids
mods = cf.getMods([729219])

# initialise GetFeaturedModsRequestBody object for use in get_featured_mods
featuredModsSearch = schemas.GetFeaturedModsRequestBody(432, [], 73242)

# get featured mods within specific game
featuredMods = cf.GetFeaturedMods(featuredModsSearch)

# get string description of specific mod
modDescription = cf.getModDescription(729219)

# get specific file within specific mod
modFile = cf.getModFile(729219, 4159320)

# get files based off of FileId
modFiles = cf.getModFiles(729219)

Files

# get files from list of ids
files = cf.getFiles(schemas.GetModFilesRequestBody([4159320]))

# get changelog of a specified mod and file id
changelog = cf.getModFileChangelog(729219, 4159320)

# get download url for a mod file
modFileDownloadUrl = cf.getModFIleDownloadUrl(729219, 4159320)

Fingerprints

# get exact matches for a fingerprint
fingerprintsMatches = cf.getFingerprintsMatches(schemas.GetFingerprintMatchesRequestBody([2352728825]))

# get fuzzy matches for a partial fingerprint
fuzzyMatches = cf.getFingerprintsFuzzyMatches(schemas.GetFuzzyMatchesRequestBody(432, [schemas.FolderFingerprint("test", [2352728825])]))

Minecraft

# get minecraft versions
minecraftVersions = cf.getMinecraftVersions()

# get a specific minecraft version
minecraftVersion = cf.getSpecificMinecraftVersion("1.16.5")

# get a list of minecraft modloaders
minecraftModloaders = cf.getMinecraftModloaders()

# get a specific minecraft modloader
minecraftModloader = cf.getSpecificMinecraftModloader("forge-1.16.5-36.1.0")

Utilities

# Within the CurseForgeAPy package, there is a utility class that has a couple helper functions, mainly downloading files related.
# These functions shouldnt be called without a CurseForgeAPy client object, as they use the client to get the download url.

from CurseForgeAPy import utils
from CurseForgeAPy import schemaClasses as schemas

# Each function take in a CurseForgeAPy client object, and a specific parameter, finishing with a file path to save the file to.
cf = CFAPI('YOUR-API-KEY')

# Download a file from a url
utils.downloadFileFromURL(cf, "file-url", "file-path")

# Download a specified file from id
utils.downloadFileFromID(cf, 111111, "file-path")

# Download a specified file from a mod id
utils.downloadFileFromModID(cf, 111111, "file-path")

# Download a specified file from a mod id and file id
utils.downloadFileFromModIDAndFileID(cf, 111111, 222222, "file-path")

# Download a specified file from a mod id and version, with optional release type (defaults to None which is any release type)
# Can return an exception if the version is not found
utils.downloadFileFromModIDVersion(cf, 111111, "1.16.5", "file-path", schemas.ReleaseType.Release)

# Create a datetime
# This is an internal function that is used to convert the CurseForge API's datetime format to a python datetime object
# This is due to the API returning varying formats for the datetime, so this function uses string parsing to convert it to a datetime object
utils.create_datetime("2021-01-01T00:00:00.000Z")

Support

If you have any issues or questions while using CurseForgeAPy, please feel free to open an issue on the GitHub repository or contact us through our support channels.

Contribution

We welcome contributions to CurseForgeAPy! Please feel free to open a pull requests or issue if you would like a new feature.

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

CurseForgeAPy-1.1.2.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

CurseForgeAPy-1.1.2-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file CurseForgeAPy-1.1.2.tar.gz.

File metadata

  • Download URL: CurseForgeAPy-1.1.2.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for CurseForgeAPy-1.1.2.tar.gz
Algorithm Hash digest
SHA256 dae097eb36bbae7e91e92827b6c6379294d88739881ce4bc2ea3658d55e48818
MD5 ec80d095ab4feff2b2dcd295f8e5ecf4
BLAKE2b-256 e44d1b275b28220b9105ab787df50683cf22199605a96da598cd32e38a2c7897

See more details on using hashes here.

File details

Details for the file CurseForgeAPy-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for CurseForgeAPy-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5e3d98f4a9232b8acbaed3eab965983427ff913e15fc1dd5ec49300091dbe87d
MD5 8c92389672c5bd53189cfa9d95533108
BLAKE2b-256 8fd2886df802e30f29ff962d80c7d2875ea66204f9adba35a72831286f25591a

See more details on using hashes here.

Supported by

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