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:
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
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.
Update database.yaml file:
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:
Adding a controller for our API. I decided to got with api namespace: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 :).
The last thing with rails is to add routes:
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:
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:
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.