Development
-
May 19, 2020

Access the world's most powerful retail APIs with Best Buy Ruby

What's Best Buy Ruby?

Best Buy Ruby is a new gem developed entirely here, at Rootstrap. It's basically a wrapper for the different Best Buy APIs. It offers a simple and intuitive interface that allows users to access the required API with as much customizations as they like.

Why use it?

Best Buy offers a really powerful API. The different options provided range from pagination and sorting methods to incredibly flexible item queries and response formats.

But with great power comes great responsibility.

While all these options are great, they can make requests quite messy to build. When you find yourself having to add the API key, the response format, page and page size, all this with a couple of conditions in the search query, building the URL can become quite troublesome.

Most healthy projects working with this API must build some kind of module to manage these options, even when the amount of interactions made with the API are low.

And that's where [.c-inline-code]best_buy_ruby[.c-inline-code] comes to save the day.

It's built entirely around the goal of making the API both easily accessible and fully customizable at the same time.

Let's see a quick example. With the gem, this request:


https://api.bestbuy.com/v1/products(categoryPath.id=some_id&(condition=new|new=true))?format=json&page=5&pageSize=100&apiKey=SOME_API_KEY

Can be written like this:


BestBuy::Products.new.get_by(
  category_id: some_id,
  item_contidion: 'new',
  pagination: { page: 5, page_size: 100 }
)

Great, I want it. Where can I find it?

The gem is available in RubyGems, but be sure to check our own Github repo, where you'll find the docs to learn how to use it. You are welcomed to submit any issues or contribute!