Bungie Manifest API. SQLite

to Ruby on Rail API.

Hash tags: Bungie API Ruby on Rails SQLite API

How to build your own Bungie Manifest API from a single sqlite file.

I just recently found out that Bungie(the company which developed Destiny Online) happened to have a free API built absolutely free for their fans/gamers. I was pleasantly surprised because of 2 reasons - first I was open and looking for a new project to work on and the second I love the game. So I decided to start learning the API they have, after a couple of hours reading through their documentation I realized that it's not an ideal at all but!! BUT! more challenges more fun isn't it? Well, I guess it's just me or maybe all software engineer? I will leave this on you to decide. My main problem was their manifest file which is actually a part of the DB they didn't include/built into API endpoint. What does it mean? Well you can query API and get all items you have on your character but you can't actually see the name of it or an icon of it well you can't actually see anything really exciting there except IDs :D -not really cool??!! Not really!

Here is what I came up with - SQLite sounds like Ruby on Rails to me why would I just develop an API RoR app which would access all goodies I need from the manifest and render JSON back to me?? And I will have to only provide the id of the item I need... or whenever else I need to query. One thing to note here! This is not the ideal solution for sure or super-puper advance approach to develop it's just something I thought would make my life a bit easier and I could have fun with.

Ok here is what we need if we are lazy jk :D. If you know how it works:
  1. Click Here
  2. git clone
  3. bundle install
  4. gcloud app deploy
  5. Enjoy

Full tutorial:
  1. We need to have Ruby on Rails app lock and loaded. We won't need any heavy front part so use rails new my_api --api. More information here
  2. When 1 step is done let's change default SQLite file in db folder on our manifest.sqlite. BTW to open their manifest you have to use a special call here more info. And then change world_sql_conten_somedigits.content -> world_sql_conten_somedigits.zip, unzip it, you will get the same .content but not the same :D so change the last one to .sqlite3 and use it for your app.
    Screen Shot 2019-07-14 at 9.10.41 PM.png 34.8 KB
  3. Update database.yaml file:
    Screen Shot 2019-07-14 at 9.16.26 PM.png 324 KB
  4. Creating the first Active Record model class for our new DB. Please note that by default rails will associate database table names as destiny_inventory_item_definitions - snake case + pluralization which we definitely don't need. To fix this we need to explicitly set a name of the table. Here is an example:
    Screen Shot 2019-07-14 at 9.22.03 PM.png 49.5 KB
  5. Adding a controller for our API. I decided to got with api namespace:
    Screen Shot 2019-07-14 at 9.22.57 PM.png 159 KB
    I have 2 examples here. One is to get all items(not really a good idea to render so log string) and a second one is to get just one item by id. Which I think is very useful :).
  6. The last thing with rails is to add routes:
    Screen Shot 2019-07-14 at 9.26.13 PM.png 78.9 KB
  7. Now one more thing. I tried to go with Heroku to deploy the app but they are not allowing sqlite on their servers. So it's up to you what service to use, but i would recommend google app engine. I was able to set it up within 1 hour. So just follow google instruction and everything will work just fine. Here is something you will need to put in your root rails directory app.yaml:
runtime: ruby
env: flex
entrypoint: bundle exec rackup --port $PORT

# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/ruby/configuring-your-app-with-app-yaml
manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10
This is pretty much it. Just add ActiveRecord models for all tables you need, and don't forget to keep sql file up to date.

PROJECTS


MORE BLOGS