An all-in-one OSRS Library with Hiscores and Grand Exchange Market Information
Project description
OSRSBytes (v1.3.0)
Production Branch
[update20220125] Added OSRS Wiki to Items module in v1.2.5:
- Added the OSRS Wiki API to the Items Module.
[update 20210710] Fixes implemented in v1.2.4:
- Escape username to avoid getting errors for usernames that contain spaces.
- Fixed bug in setup.py causing a manual install to fail and matched version numbers to 1.2.4.
[update 20201004] Bug Fix:
- Fixed a bug that caused the API to appear to be down due to a messup in parsing. Update OSRSBytes with
pip install OSRSBytes --upgrade
to fix this bug.
[update 20200925]
Currently implemented in v1.2.2:
- Hiscores Shelve-caching (reduces the number of calls to the api).
Fixes currently implemented in v1.2.2:
- Previously, ItemID and ItemName each had their own dictionary to allow users to search by either ItemID or ItemName. This was dumb of me, so I instead implemented one dictionary that was keyed by ItemName. You can still search by ItemID thanks to the
self.__normalize_input()
method which will ensure that anything you input is converted to item name. If you put inint(1213)
orstr(1213)
the method will, ultimately, return"rune dagger"
Introduction
OSRSBytes is an all-in-one Python library for Old School Runescape (OSRS) that features Item Information Lookup, Hiscores, and Market information from RSBuddy.
Installation:
pip install OSRSBytes
Upgrade
pip install OSRSBytes --upgrade
Example Invocation (Hiscores)
The OSRSBytes library contains caching on Hiscores to improve performance. Caching is disabled by default and must be enabled when initializing the hiscores object. Note that default TTL of cache is
3600
seconds or1
hour. Example without Caching###################### # No Caching Example # ###################### from OSRSBytes import Hiscores user = Hiscores('Zezima') # Lets display some information print("Current level:", user.skill('attack', 'level')) print("Current rank:", user.skill('attack', 'rank')) print("Current exp:", user.skill('attack', 'experience')) print("Exp remaining:", user.skill('attack','exp_to_next_level'))Example utilizing Caching
################### # Caching Example # ################### from OSRSBytes import Hiscores user = Hiscores('zezima', caching=True) # Lets display some information print("Current level:", user.skill('attack', 'level')) print("Current rank:", user.skill('attack', 'rank')) print("Current exp:", user.skill('attack', 'experience')) print("Exp remaining:", user.skill('attack','exp_to_next_level')) # Reinitializing the Hiscores class is quick now, as we already have the information cached user = Hiscores('zezima', caching=True) # user = Hiscores('zezima', caching=True, cacheTTL=7200) # Optional custom cacheTTL print("Current level:", user.skill('attack', 'level')) print("Current rank:", user.skill('attack', 'rank')) print("Current exp:", user.skill('attack', 'experience')) print("Exp remaining:", user.skill('attack','exp_to_next_level')) # Lets get the current time left in the cache (in seconds) for Zezima print("TTL for Cache: ", user.getCacheTTLRemaining()) # rounded up to nearest second
Example Invocation (HiscoresCache)
The OSRSBytes library allows for you to directly manage the HiscoresCache independant of the Hiscores module.
############################## # Working with HiscoresCache # ############################## from OSRSBytes import HiscoresCache # Initialize the cache object cache = HiscoresCache() # Lets clear a large number of expired users from the cache cache.clearExpiredCacheEntries() print(cache.purgeCounter) # Int print(cache.usersDeleted) # List # Lets remove a specific user from the HiscoresCache if cache.removeFromCache("Zezima"): print("User Removed") else: print("User not in cache") # Lets completely destroy the cache. Note that this method completed removes the cache files as well as the # cache folder itself. cache.destroyCache()
Example Invocation (Items)
from OSRSBytes import Items
items = Items()
# Lets get information on this item
print('Is Members:', items.isMembers('rune dagger'))
print("Item ID:", items.getItemID('rune dagger'))
print('Sell Average:', items.getSellAverage('rune dagger'))
print('Sell Quantity:', items.getSellQuantity('rune dagger'))
print('Buy Average:', items.getBuyAverage('rune dagger'))
print('Buy Quantity:', items.getBuyQuantity('rune dagger'))
print('Buy Limit:', items.getBuyLimit('fire rune'))
print('Shop Price:', items.getShopPrice('rune dagger'))
print('High Alch Value:', items.getHighAlchValue('rune dagger'))
print('Low Alch Value:', items.getLowAlchValue('rune dagger'))
# In addition, all items can be called by Item ID as well
print('Item Name:', items.getName('1213'))
print('Sell Average:', items.getSellAverage('1213'))
Contributing
Prior to contributing, please consider the following before committing code:
- Do not leave commented lines in code (i.e.
#print('test')
- Try to write your code as cleanly and readable as possible
- Whenever possible, do not use third party packages, try your hardest to utilize built-in python packages
- No commits should break previous code functionality. This means that method names should remain the same and return the same, expected values in the same format.
Thank you for your considerations
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
Hashes for OSRSBytes-1.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45fc047e8b62c0479deccdb230bdf2be0c049f6b5121060078c97caf8084c4e4 |
|
MD5 | 3a6bb1b5adae48d7e76e233c6fcc4f03 |
|
BLAKE2b-256 | 1234e16171808c0f99af93cee17c70ff40da97bbfba62ccb221b06df270977d5 |