Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

Sell OSRS Gold
Sign in to follow this  
wastedbro

Item Price API [Uses RSBuddy + Official GE] [Caching]

Recommended Posts

This library provides a fully-featured API for obtaining data from the Official GE API, as well as the RSBuddy Exchange API. You can use either service separately, or together to provide redundancy in case one goes down. You can also add your own service for other price APIs!

 

Gitlab: https://gitlab.com/WBScripting/rs-item-services

Requirements:

How to add to your project:

  1. Download the repository,
  2. Extract the "scripts" folder into your script's source directory.

 

Example Usages:

1. Getting ground items over a certain price (using the Grand Exchange Wrapper)

/**
* Make sure to have this import
* import scripts.wastedbro.api.rsitem_services.GrandExchange;
*/
public static ArrayList<RSGroundItem> getGroundItemsOverPrice(int minPrice)
{
	return Arrays.stream(GroundItems.getAll())
		.filter(item -> GrandExchange.getPrice(item.getID()) >= minPrice)
		.collect(Collectors.toCollection(ArrayList::new));
}

 

2. Getting ground items over a certain price (using dependency injection)

public static ArrayList<RSGroundItem> getGroundItemsOverPrice(int minPrice, IRsItemPriceService priceService)
{
	return Arrays.stream(GroundItems.getAll())
		.filter(item -> priceService.getPrice(item.getID()) >= minPrice)
		.collect(Collectors.toCollection(ArrayList::new));
}

To call it:

RsItemPriceService priceService = new RsItemPriceService.Builder()
		.addPriceService(new RsBuddyPriceService())
		.addPriceService(new GrandExchangePriceService())
		.build();

// This will try using the RsBuddyPriceService to look up the item
// If that fails, it will try the GrandExchangePriceService
// This will rarely, if ever, fail to get the price
getGroundItemsOverPrice(500, priceService);

Or you can call it like:

GrandExchangePriceService priceService = new GrandExchangePriceService();

getGroundItemsOverPrice(500, priceService);

 

3. Getting an item's icon URL via the official grand exchange

GrandExchangePriceService priceService = new GrandExchangePriceService();

String fireRuneIconUrl = priceService.tryGetItemData(554).orElse(new ExchangeItem()).getIconUrl(); // Will either be the icon URL or null

 

 

Notes:

  • RsBuddyPriceService caches every item in memory and on the file system. It will work even if the RSBuddy API is down, assuming there is still a cache in the filesystem. You can specify how often to update the cache, as well as set a time at which the cache is considered invalid.
  • The RsBuddyPriceService will very rarely make network calls. It mostly uses caching.
  • GrandExchangePriceService caches items in memory as you look them up. You can disable this.
  • All of the methods via services return an Optional. This is useful because it informs you whether or not it successfully looked up the item. 
Edited by wastedbro
  • Like 4

Share this post


Link to post
Share on other sites
On 11/6/2018 at 6:28 PM, wastedbro said:

Update:

  • Fixed an issue where the RSBuddyPriceService would throw an exception if the cache existed but was empty. This can happen if the user doesn't allow the connection to the RSBuddyAPI.
  • Changed the cache filepath to be cross-platform-friendly

Thanks @Worthy :)

@wastedbro, seems like it's unable to parse prices like 12.5k, kmb values from ruenscape's ge prices

Share this post


Link to post
Share on other sites
1 hour ago, erickho123 said:

@wastedbro, seems like it's unable to parse prices like 12.5k, kmb values from ruenscape's ge prices

Worthy mentioned that to me a while ago. I think I ended up disregarding it since no one was using the GE service API.

I will keep a note of it to do, but is there any reason you want to use the GE API over the RSBuddy + caching one?

Share this post


Link to post
Share on other sites
2 hours ago, wastedbro said:

Worthy mentioned that to me a while ago. I think I ended up disregarding it since no one was using the GE service API.

I will keep a note of it to do, but is there any reason you want to use the GE API over the RSBuddy + caching one?

Just to chime in here, before RSBuddy migrated their pricing API to google storage, I used GE as a backup for when their API was down. Now that it's 100% stable I can't find a reason to use the GE one again.

Share this post


Link to post
Share on other sites
5 hours ago, wastedbro said:

Worthy mentioned that to me a while ago. I think I ended up disregarding it since no one was using the GE service API.

I will keep a note of it to do, but is there any reason you want to use the GE API over the RSBuddy + caching one?

RSBuddy is being used less and less. Most people I know use RL so overtime if RL takes over, then RSBuddy becomes more inacurate since it's based off their user's game data

Share this post


Link to post
Share on other sites

 

On 8/18/2019 at 11:03 PM, theholyone said:

Been having some errors getting prices of items, not sure if link needs to be updated

 

  • [21:00:01] Could not load RSItem via Grand Exchange API

 

A fix has been pushed to the Gitlab repo.

 

On 8/19/2019 at 12:49 AM, Netami said:

Just a heads up for @theholyone and anyone else who uses this, RSBuddy migrated their API again, to use this just change the URL String on Line 112 of RsBuddyPriceService class to 

https://rsbuddy.com/exchange/summary.json

 

Don't be afraid to submit a merge request.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Our picks

    • Over the past few months, I’ve been working diligently on a new project - TRiBot X. Everything has been written from the ground up, with all of the best practices of software engineering. Every aspect of TRiBot has been re-imagined to support three main goals: flexibility, useability, and reliability.
        • Like
      • 30 replies
    • Come give us feedback on the next version of TRiBot!
        • Thanks
        • Like
      • 74 replies
    • TRiBot is looking to improve a lot of its customer relationship management, customer on boarding process, customer experience, design elements, community engagement and pretty much everything else you can imagine when it comes to marketing.

      Our goal: To ensure that the marketing done TRULY reflects the experience and does not shine an inaccurate light on what TRiBot is lacking in.

      So I ask, what do you love about TRiBot and what do you hate about TRiBot? What does O S Bot, Rune M8, PowR Bot and Dre amBot do better? (yes I purposely didn't spell it right 😂).

      Love, 

      RileyZ
        • Like
      • 23 replies
    • Over the last three weeks, I've been working on upgrading our server infrastructure. It's finally ready and is now live!

      Why?

      Increased reliability - less server errors


      Increased availability - less downtime


      Increased security - keeping us and you secure


      Increased capacity - ability to serve you better


      Increased speed - less waiting for things to load


      Faster development - server and service updates will come faster


      What are the changes?

      Move from a single AWS EC2 instance to AWS ECS (Elastic Container Service)


      Distributed computing


      Load balancing


      Git management of server files and filesystem


      Redis caching


      How?

      AWS ECS (with 10 EC2 instances)


      AWS ElastiCache (Redis)


      AWS Load Balancing


      AWS EFS (Elastic file system)


      Please bare with us as I continue to tune the server for maximum performance. Slow loading speeds may occur temporarily. I thank everyone for their patience.

      Please post on this thread if you experience any issues other than slow loading times.
        • Like
      • 51 replies
    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Sad
        • Haha
        • Thanks
        • Like
      • 90 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...