Skip to main content

A simple Python wrapper for the WarFrame API

Project description

PyLotus

PyLotus is a simple Python wrapper for the Warframe API.

Description

This is a super simple wrapper for the Warframe API, information about which can be found here. Most requests to the API have been implemented; any that haven't been can be retrieved by requesting the worldstate. Also provided are some basic prebuilt classes to hold common responses like individual Fissure objects, etc.

Dependencies

PyLotus only uses the built-in requests and json libraries, with pytest only being used to implement testing. These are all installable and upgradeable via pip.

Installation

Use the package manager pip to install PyLotus.

pip install pylotus

Usage

All platforms are supported for use with the API wrapper; a list containing the platform shorthand notations accepted by the API are accessible through the static wf_api.get_platforms().

from pylotus import *

print(wf_api.get_platforms()) # It's always possible to retrieve all supported platforms with which to construct the API, even in a static context.
>>> ['pc', 'ps4', 'xb1', 'swi']

Create a wf_api instance that can access the WarFrame API for a specified platform. Retrieve information from the API with the responses stored in lists of easily accessed JSON-formatted dict objects or individual objects.

xbox_api_wrapper = wf_api('xb1') # Create an instance with your preferred platform.

current_fissures = xbox_api_wrapper.get_current_fissures() # Get back a list of JSON response dicts or a single JSON response dict.

do_something_with_the(current_fissures)

Use built-in classes, like the Fissure class, to easily wrap common API responses. Pass the class constructors the retrieved JSON representations of the API returns.

fissure_objects = [Fissure(fissure) for fissure in current_fissures]

print(len(fissure_objects))
for f in fissure_objects:
	print(type(f), f.enemy, f.missionType)
>>> 4
>>> Fissure, Grineer, Defense
>>> Fissure, Corpus, Defense
>>> Fissure, Grineer, Interception
>>> Fissure, Grineer, Mobile Defense

You can also import only the API interface, skipping the prebuilt classes if you would rather. Do this by importing as follows:

from pylotus import wf_api

Exceptions and Error Handling

There are 3 custom exceptions (termed Errors) in PyLotus: NonPlatformError, raised when the platform passed to the wf_api constructor is invalid; DictTypeError, raised when incorrect objects (not dicts or not correct dicts) are passed to class constructors; and StatusCodeError, raised when the WarFrame API itself returns a non-200 response. These all have error messages associated with them accessible through Error.message.

License

Licensed under the MIT license.

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

pylotus-1.0.0.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

pylotus-1.0.0-py2.py3-none-any.whl (7.5 kB view hashes)

Uploaded Python 2 Python 3

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