Import Torn API Data to Google Sheets

Torn is a popular and intriguing text-based online RPG. In this guide, we’ll walk through how to pull player and market data from the Torn API directly into Google Sheets, using the API Connector add-on. We’ll first get an API key from Torn, and then set up a request to pull in information from Torn to your spreadsheet.

CONTENTS

STEP 1: GET YOUR TORN API KEY

  1. While logged into Torn, click the Preferences icon in the top right corner.
    torn-img1
  2. Click on API Key. That’s it! You’ll see your API key displayed. Copy this and keep it safe; we’ll need it shortly.
    torn-img2

STEP 2: CREATE YOUR API REQUEST URL

We’ll first follow the Torn API documentation to access item data.

  • API root: https://api.torn.com
  • Query Strings: ?selections=items&key=YOUR_API_KEY

Putting it all together, we get the full API Request URL:

https://api.torn.com/user/?selections=items&key=YOUR_API_KEY

STEP 3: PULL TORN API DATA INTO SHEETS

We can now enter all our values into API Connector and import Torn data into Google Sheets.

  1. Open up Google Sheets and click Add-ons > API Connector > Create New API Request.
  2. In the Create Request interface, enter the Request URL we just created
    torn-img3

     

  3. We don’t need any headers, so just leave that section blank.
  4. Create a new tab. You can call it whatever you like, but here we’ll call it ‘items’. While still in that tab, click ‘Set’ to use that tab as your data destination.
  5. Name your request. Again we’ll call it ‘items’
  6. Click Run and a moment later you’ll see item stats printed into your sheet.
    torn-img4

 

STEP 4: GET MORE DATA

 

  1. You can check the documentation for the full list of available API requests,  but if you just want to jump in, you can play around with the URLs you enter in the API URL path field. Try the following (one at a time):
    https://api.torn.com/user/1?key=YOUR_API_KEY
    https://api.torn.com/property?key=YOUR_API_KEY
    https://api.torn.com/market?key=YOUR_API_KEY
    https://api.torn.com/torn/?selections=items&key=YOUR_API_KEY
    https://api.torn.com/torn/?selections=medals&key=YOUR_API_KEY
    https://api.torn.com/torn/?selections=honors&key=YOUR_API_KEY
  2. By default, some of the Torn API’s endpoints will return data that gets parsed into separate columns. You can select API Connector’s compact report style for a more compact output with fewer columns.
  3. Click the Try It! button for a convenient way to construct and try out requests in the browser before copying them into API Connector. From there, you can simply copy and paste their auto-created URL into the API Connector request URL field.
    torn-img5

8 thoughts on “Import Torn API Data to Google Sheets”

  1. When I try to do it, it says either:
    error » code error » error
    4 Wrong fields

    or
    Status
    Request failed: Server responded with an error (503) show response

    Reply
    • I just tested and the examples in the post still work for me. A 503 error means that a server is temporarily unable to handle the request, so Torn’s server may have been down for maintenance or something. Can you try again?

      Reply
      • I tried to do one for honors and it fully worked. But whenever I try to do one for items it keeps on popping the Error 503. I also restarted my API key just in case and results are the same.

      • No it leaves me with error » code error » error
        4 Wrong fields. I checked everything is correct. It never does this when I try for honors.

    • good question, but the API documentation only shows some timestamp and field filters, there’s nothing about filtering by gender. You should be able to count results using native Sheets formulas like COUNT().

      Reply

Leave a Reply to Anonymous Cancel reply