Language…
5 users online: MrChompinkski, mt_meta_z_alpha_and_omega, Neuromancer, Rodrigo56, sL0Thiie - Guests: 46 - Bots: 249
Users: 66,267 (2,222 active)
Latest user: gulab118

SMW Central API Python Wrapper - you're easier way to interact with the new SMWC API!



SMW Central API Python Wrapper

Hey there, thanks for stopping by! Today, I bring you the first release of my Python wrapper for the recently released SMW Central API! This wrapper is currently supporting all features of revision 1 of the API.

Example usage

Using this is quite simple. It's made sure that all identifiers reflect how the site and API names their counterparts. So if you're familiar with the site, this should be easy to get used to. All parameter and attributes are explained in the attached docstrings! To some extent, you can even see the proper website and API specification as a documentation for this!

Code
from api import get_section_list
from smwc_filters import SMW, SMWDifficulty
from smwc_types.section import Section

if __name__ == "__main__":
    # Create filter parameter for the SMW Hacks section
    filter_param = SMW.get_smwhacks_param(
        name="Mario",
        difficulty=SMWDifficulty.NORMAL
    )

    # Get results from SMW Hacks section
    # ! Make sure to use right section !
    results = get_section_list(Section.SMW.HACKS, filters=filter_param)

    # Print results
    print(results.total)
    for file in results.data:
        print(file.id, file.name)


Get section entries

To get all sections entries, you use the `get_section_list()`. As shown in the example above, to get all SMW hacks, having the word “Mario” in the name and being a kaizo beginner hack. First create yourself a filter parameter object, which you can then hand together with the associated section to the API.

Every `xxx_filters.get_xxx_param()` function offers all the parameter, the site offers you for this section. The `api.get_section_list()` has more parameter, what and how to display the results!

A call to the `api.get_section_list()` will return a `Pagination` object. Those are essentially a page of the sections catalogs entries. They have attributes like a link to the next page, how many entries are on that page and most importantly, the `data` list, with the entries.

Get a file

A file is any submission on SMW Central. To retrieve a files details, you use the `api.get_file()` function. This expects a file ID from you. Those you can get from the `File` objects, a `Pagination` object may hold within their `data` list.

Download
To use this wrapper or for more information, head over to the projects GitHub page! Thanks!