> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runway.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Export API

> Runway offers a limited API to allow you to export model and database views programmatically.

## Supported objects

You are able to export models and databases. **Page exports are currently unavailable.**

* **Main Scenario Model URL example**: `https://app.runway.com/skynet/submodel/afd94c7e-1e7f-4e55-b99a-472aa5a43cd9`
* **Scenario Model URL example**: `https://app.runway.com/skynet/proposal/445f8fea-df2a-49cb-9cce-f805be588137/submodel/afd94c7e-1e7f-4e55-b99a-472aa5a43cd9`
* **Main Scenario Database example**: `https://app.runway.com/skynet/page/5fb5f2a6-7a13-4085-a89c-86e2da66a17c`
* **Scenario Database URL example**: `https://app.runway.com/skynet/proposal/445f8fea-df2a-49cb-9cce-f805be588137/page/5fb5f2a6-7a13-4085-a89c-86e2da66a17c`

## Guide

1. Log into Runway > Settings (top right) > API
2. Obtain your API secret, this will be used as a **Bearer Token** in the header of your request.
   1. `Authorization: Bearer <your bearer token here>`
3. Format your API endpoint:
   1. Grab the URL of the Database or Model you want to pull data from
   2. **Replace "app.runway.com/org-url" with "api.runway.com/api"**
      * `https://app.runway.com/skynet/submodel/afd94c7e-1e7f-4e55-b99a-472aa5a43cd9`
      * becomes
      * `https://api.runway.com/api/submodel/afd94c7e-1e7f-4e55-b99a-472aa5a43cd9`
4. HTTP method set to GET

## Limitations

* If you have a database with multiple drivers, Runway will only show the time series data that is currently expanded on that page.
* If you want multiple drivers from a database, shape a new database off that existing database and pull from separate databases.
* The time period pulled is limited to the filters applied on the database and model.
* Formulas cannot be exported at this time.
* The exported data is in csv format only

## Example Runway > Google Sheet Integration

* [Video Guide](https://www.loom.com/share/57c29a5412c5479da7e34242526cf548)
* Here's a sample app script to export a model
  * Be sure to replace the following:
    * "PUT API ENDPOINT HERE" with your [https://api.runway.com/api](https://api.runway.com/api)...
    * "PUT TOKEN HERE" with your token from the Runway settings menu
    * "PUT SHEET TAB NAME HERE" with the name of the tab you want to put the data in

      ```
      function importRunwayData() {
        var url = "PUT API ENDPOINT HERE";
        var token = "PUT TOKEN HERE";

        // Call the API
        var response = UrlFetchApp.fetch(url, {
          method: "get",
          headers: {
            "Authorization": "Bearer " + token,
            "Accept": "application/json"
          },
          muteHttpExceptions: true
        });

        // Parse JSON
        var data = JSON.parse(response.getContentText());
        var csvString = data.contents;

        // Clean BOM if present
        csvString = csvString.replace(/^\uFEFF/, "");

        // Parse the entire CSV string at once
        var rows = Utilities.parseCsv(csvString);

        // Get the "Runway import" tab (create if missing)
        var ss = SpreadsheetApp.getActiveSpreadsheet();
        var sheet = ss.getSheetByName("PUT SHEET TAB NAME HERE");
        if (!sheet) {
          sheet = ss.insertSheet("PUT SHEET TAB NAME HERE");
        }

        // Clear and write values
        sheet.clearContents();
        sheet.getRange(1, 1, rows.length, rows[0].length).setValues(rows);
      }

      ```
