Skip to content
Branch: master
Find file History
Latest commit b054b7c Aug 22, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
items-icons Updated all item icon image files. Jul 25, 2019
items-json-slot Fixed some duplicate items, and fixed crystal items after SOTE change… Aug 19, 2019
items-json Weekly cache and wiki update. Weekly item database regeneration. Push… Aug 22, 2019
monsters-json
prayer-icons Prayer fix web resources (#35) Feb 3, 2019
prayer-json convert line endings to LF Feb 24, 2019
README.md Cleaned up documentation. Pushed PyPi version 1.0.7. Mar 22, 2019
items-complete.json Fixed some duplicate items, and fixed crystal items after SOTE change… Aug 19, 2019
items-summary.json Weekly cache and wiki update. Weekly item database regeneration. Push… Aug 15, 2019
models-summary.json Weekly cache and wiki update. Weekly item database regeneration. Push… Aug 22, 2019
monsters-complete.json Adding the monsters database (finally!) (#141) Aug 22, 2019
npcs-summary.json Weekly cache and wiki update. Weekly item database regeneration. Push… Aug 22, 2019
objects-summary.json Weekly cache and wiki update. Weekly item database regeneration. Push… Aug 15, 2019

README.md

osrsbox-db: Public JSON API

This folder contains the publicly available database/dataset and somewhat-RESTful API of osrsbox-db. Basically, every file inside this specific folder can be fetched using HTTP GET requests. The base URL for this folder is https://www.osrsbox.com/osrsbox-db/. Simply append any file name (from this folder) to the base URL, and you can fetch this data. You can also clone this entire repository and access the files provided in this folder, or download a single file for offline processing.

A summary of the files provided in the JSON API are listed below with descriptions:

  • items-icons: Collection of PNG files (20K+) for every item inventory icon in OSRS.
  • items-json: Collection of JSON files (20K+) of extensive item metadata for every item in OSRS.
  • items-json-slot: Collection of JSON files extracted from the database that are specific for each equipment slot (e.g., head, legs).
  • prayer-icon: Collection of PNG files for each prayer in OSRS.
  • prayer-json: Collection of individual JSON files with properties and metadata about OSRS prayers.
  • items-complete.json: A single JSON file that contains all single JSON files from items-json
  • items-summary.json: A single JSON file that contains only the item name and item ID number.
  • models-summary.json: A single JSON file that contains model ID numbers for items, objects, and NPCs.

Accessing the JSON API

The JSON file for each OSRS item can be directly accessed using unique URLs provide through the osrsbox.com website. Technically, this provides some of the functionality of a RESTful API, but only supports GET requests. That is, you can fetch JSON files using a unique URL but cannot modify any JSON content. Below is a list of URL examples for items in the osrsbox-db:

As displayed by the links above, each item ID is stored in the osrsbox-db repository, under the items-json folder.

In addition to the single JSON files for each item, there is also a collection of JSON files that contain combined items. The following list documents the additional JSON files that are available:

So how can you get and use these JSON files about OSRS items? It is pretty easy but really depends on what you are trying to accomplish and what programming language you are using.

Accessing the JSON API using wget

Take a simple example of downloading a single JSON file. In a Linux system, we could use the wget command to download a single JSON file, as illustrated in the example code below:

wget https://www.osrsbox.com/osrsbox-db/items-json/12453.json

Accessing the JSON API using Python

Maybe you are interested in downloading a single (or potentially multiple) JSON files about OSRS items and processing the information in a Python program. The short script below downloads the 12453.json file using Python's urllib library, loads the data as a JSON object and prints the contents to the console. The code is a little messy, primarily due to supporting both Python 2 and 3 (as you can see from the "try" and "except" importing method implemented).

import json

try:
    from urllib.request import urlopen
except ImportError:
    from urllib2 import urlopen

url = ("https://www.osrsbox.com/osrsbox-db/items-json/12453.json")
response = urlopen(url)
data = response.read().decode("utf-8")
json_obj = json.loads(data)
print(data)

Accessing the JSON API using JavaScript

Finally, let's have a look at JavaScript (specifically jQuery) example to fetch a JSON file from the osrsbox-db and build an HTML element to display in a web page. The example below is a very simple method to download the JSON file using the jQuery getJSON function. Once we get the JSON file, we loop through the JSON entries and print each key and value (e.g., name and Black wizard hat (g)) on its own line in a div element. If you want to experiment with the code, the code is available in a W3Schools TryIt Editor at this link.

<!DOCTYPE html>
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
    <script>
      $(document).ready(function(){
          $("button").click(function(){
              $.getJSON("https://www.osrsbox.com/osrsbox-db/items-json/12453.json", function(result){
                  $.each(result, function(i, field){
                      $("div").append(i + " " + field + "<br>");
                  });
              });
          });
      });
    </script>
  </head>
  <body>
    <button>Get JSON data</button>
    <div></div>
  </body>
</html>
You can’t perform that action at this time.