![]() There’s lots of cool stuff sent in the JSON objects, including hyperlinks to the item images and details on the price of each item. (Also, if you haven’t got The Ram – get it) Yes! Our Python app can now send requests to Bungie and print the contents of Xurs inventory. Xurs inventory, taken from the vendors page. Here is what the output of our code looks like: Print "Item type is: " item_tier " " item_type "\n" Res = requests.get(hashReqString, headers=HEADERS) HashReqString = base_url "Manifest/" hashType "/" hashID We can add on another request to our nested loops above: This request takes the form of: will be “6”, as we are searching for an “InventoryItem”. Now that we have a list of our itemHash’s – we need to make send a request to the Bungie Destiny Manifest page for each of the hashes. So in order to make a list of each of the “itemHash” values, we need a for loop to iterate through each of the “saleItemCategories” and another for loop to iterate through each of the “saleItems”.įor saleItem in res.json(): Print "Error status: " error_stat "\n"ĭecoding the JSON response for Xurs inventory. The JSON object contains a key called “ErrorStatus”, this key is used to store status of the request, so lets print the value of this key: The JSON response received from the request is pretty big, in my case it contained 1018 lines of text! So what do we do with this data? First things first, we need to know if our request was received and processed correctly. Now the object “res” contains the JSON response received from the Bungie servers. ![]() Makes a HTTP request to the URL stored in the “xur_url” string, the X-API-Key is also added to the request in the “headers” dictionary object. Res = requests.get(xur_url, headers=HEADERS) Print "Fetching data for: Xur's Inventory!" ![]() Print "\n\n\nConnecting to Bungie: " xur_url "\n" The X-API-Key is passed as a parameter with every HTTP request made to the Bungie servers: Our first HTTP request will be to Xurs Advisors page, here is the link Sending our request to Xurs advisors page: You may need to install it on your computer, If you have PIP installed on your computer requests can be installed by typing: pip install requests Requests is a Python HTTP library, if you’re not familiar with it, start here. So even 2 of the same guns can be completely different.īecause of this, we’ll need to send multiple requests to the Bungie servers and read multiple replies. For example, each gun can have a different scope type, different perks, and different barrel modifications. The reason behind this is, even items of the same type can have different perks. Bungie have implemented a method for reading Xurs inventory – but it returns the data in an encrypted format, as an item hash. For every request we make to the Bungie servers, we need to send this API key in the HTTP header of the request.įinding Xurs inventory isn’t as straight-forward as expected. This will give you your unique X-API-Key. This only takes a few minutes, to register as a developer, follow this link: In order to build an app using the Bungie API, you need to create a account, and register as a developer. This just wasn’t good enough, I couldn’t risk missing out on the next Gjallarhorn! So let’s built an app to find Xurs inventory each week. As with most people – I’m at work every Friday and usually busy with family time over the weekend, so I’m often left in a situation where I miss Xur or don’t have the time to log in and see what he’s selling. Xur is only available from Friday to Sunday mornings, and appears in a different location each week – because of this he can be quite hard to track down. I’m a huge fan of Bungie’s Destiny game, and have been playing it since launch. In Destiny there is a vendor, called Xur, who visits the game each week and sells exotic weapons and armour.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |