# Add Remote Table

## Content

A remote table retrieves data from a server and optionally synchronizes changes back to it.
Unlike a memory table, a remote table does not contain data until [`fetch()`](/spreadjs/api/classes/GC.Data.Table#fetch) is executed.
Remote tables support:

* Server-side data loading
* Data synchronization (single or batch mode)
* Schema mapping
* Multiple response protocols

## Basic Remote Table (Read Only)

The minimum requirement for a remote table is a `read` configuration.
Example using the standardized `products` dataset:

```javascript
const dataManager = spread.dataManager();

const products = dataManager.addTable("products", {
    remote: {
        read: {
            url: "https://demodata.mescius.io/northwind/api/v1/products",
            method: "GET"
        }
    }
});
```

At this point, the table structure is defined but contains no records.

## Required Initialization

All tables must call [`fetch()`](/spreadjs/api/classes/GC.Data.Table#fetch) before further operations.

```javascript
orders.fetch();
```

If `fetch()` is not called, the table remains empty.
Example:

```javascript
orders.fetch().then(function () {
    const view = orders.addView("orderView");
});
```

`fetch()` performs:

* Remote data retrieval
* Schema adaptation
* Internal state initialization

All remote operations depend on a completed fetch.

## Using Schema with Remote Data

Remote responses may require field mapping or type conversion.
Example:

```javascript
const products = dataManager.addTable("products", {
    remote: {
        read: {
            url: "https://demodata.mescius.io/northwind/api/v1/products"
        }
    },
    schema: {
        columns: {
            id: { dataName: "ProductId" },
            name: { dataName: "ProductName" },
            price: { dataName: "UnitPrice", dataType: "number" },
            stock: { dataName: "UnitsInStock", dataType: "number" }
        }
    }
});
```

Schema configuration is documented in the **[Schema](/spreadjs/docs/features/data-manager/schema)** section.

## Enabling Synchronization (Preview)

To enable data write-back, additional remote operations must be defined.
Example (single sync mode):

```javascript
const products = dataManager.addTable("products", {
    remote: {
        read:   { url: "https://example.com/api/products", method: "GET" },
        create: { url: "https://example.com/api/product", method: "POST" },
        update: { url: "https://example.com/api/product", method: "PUT" },
        delete: { url: "https://example.com/api/product", method: "DELETE" }
    },
    autoSync: true
});
```

Synchronization modes are explained in:
→ **[Sync Mode](/spreadjs/docs/features/data-manager/creating-tables/add-remote-table/sync-mode--autosync-vs-batch-)**

## Supported Data Protocols

Remote tables support:

* Standard JSON responses
* REST adapter
* OData
* OData v4
* GraphQL

Protocol configuration is documented in:
→ **[Remote Read and Adapter](/spreadjs/docs/features/data-manager/creating-tables/add-remote-table/remote-read-and-adapter)**