Hosted tables

Highlight demographic data in a hosted table joined to a feature layer.

What is a hosted table?

A hosted table is a reference to a table in a feature service used to store your data. The table contains features (rows) with attributes but no geometry. Applications can use hosted tables to securely access, query, and edit data as stand-alone tables or as related tables.

You use a hosted table when you want to:

  • Import files such as CSV, XLS, or Google Sheets without geographic coordinate information.
  • Securely store collections of tabular data.
  • Optimize accessing a large amount of data.
  • Create related tables for other hosted layers.
  • Edit features and track edits.
  • Perform SQL queries.
  • Update or export data.
  • Use non-spatial data in offline applications.

How a hosted table works

The most common way to create a hosted table is to use data management tools to upload files such as CSV, XLS, GeoJSON, Shapefile, and File Geodatabase files. When a hosted table is created, an item and a feature service are also created. The item ID is a unique identifier for the table. You use an item page to manage a table and a feature service to access the data. Once the table is published, you can add and edit the table's data, fields, and columns.

Manage a hosted table

An item page allows you to manage the properties and capabilities for a hosted table. You can access an item page by signing in to your developer dashboard or ArcGIS Online. You can set properties such as the name, description, and tags, as well as sharing, editing, and index settings.

View a hosted table item page

To access an item page directly, use a portal search URL with the ID for the item. The portal URL for data hosted in ArcGIS is https://www.arcgis.com. To use this URL, the item must be shared publicly.

Use dark colors for code blocksCopy
 
1
https://www.arcgis.com/home/item.html?id=<ID>

Example: https://www.arcgis.com/home/item.html?id=b79e015459314212a56590ea97faaaad

Access a hosted table

You can view information about a hosted table by accessing the feature service endpoint with the layer ID. The ID is typically an integer such as "0" if there is only one layer in the feature service. Accessing the endpoint in a web browser allows you to view properties such as the name and fields. Most APIs will use the endpoint to perform other operations such as querying data.

Get hosted table properties

To access a hosted table, or to get its properties, use the host, unique service ID, service name, and the layer ID.

Use dark colors for code blocksCopy
 
1
https://<HOST>/<UNIQUE_ID>/ArcGIS/rest/services/<SERVICE_NAME>/FeatureServer/<LAYER_ID>

Example: https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/nc_resource_table/FeatureServer/0

Get hosted table data

To get hosted table data, use the host, unique service ID, service name, layer ID, and a query operation with parameters. You can provide a SQL query and return the data as HTML, JSON, or GeoJSON.

Use dark colors for code blocksCopy
 
1
https://<HOST>/<UNIQUE_ID>/ArcGIS/rest/services/<SERVICE_NAME>/FeatureServer/0/query?<PARAMS>

Examples:

HTML: https://services3.arcgis.com/GVgbJbqm8hXASVYi/ArcGIS/rest/services/nc_resource_table/FeatureServer/0/query?where=1=1&outFields=*&f=html

JSON: https://services3.arcgis.com/GVgbJbqm8hXASVYi/ArcGIS/rest/services/nc_resource_table/FeatureServer/0/query?where=1=1&outFields=*&f=pjson

GeoJSON: https://services3.arcgis.com/GVgbJbqm8hXASVYi/ArcGIS/rest/services/nc_resource_table/FeatureServer/0/query?where=1=1&outFields=*&f=geojson

Code examples

Display a hosted table

To display a hosted table, you reference the layer by its URL or ID and specify which data attributes to return. In this example, a hosted Trailheads hosted table is accessed and all of the records are displayed.

Steps

  1. Get the hosted table URL and layer ID.
  2. Add the hosted table and define the fields.
  3. Display the fields and records.
ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for KotlinArcGIS Maps SDK for SwiftArcGIS Maps SDK for .NETArcGIS Maps SDK for JavaArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
                                                                                                 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
        // Create the FeatureTable from the provided FeatureLayer
        const featureTable = new FeatureTable({
          layer: trailsLayer,
          multiSortEnabled: true,
          visibleElements: { selectionColumn: false },
          tableTemplate: {
            // Autocast to TableTemplate
            columnTemplates: [
              // Takes an array of FieldColumnTemplate and GroupColumnTemplate
              {
                // Autocast to FieldColumnTemplate.
                type: "field",
                fieldName: "TRL_NAME",
                label: "Trail Name",
                direction: "asc"
              },
              {
                type: "field",
                fieldName: "PARK_NAME",
                label: "Park Name"
              },
              {
                type: "field",
                fieldName: "CITY_JUR",
                label: "City Jurisdiction"
              },
              {
                type: "field",
                fieldName: "OPENSTATUS",
                label: "Open status"
              },
              {
                type: "field",
                fieldName: "X_STREET",
                label: "Street Name"
              },
              {
                type: "field",
                fieldName: "ZIP_CODE",
                label: "Zip Code"
              }
            ]
          },
          container: document.getElementById("tableDiv")
        });

Filter a hosted table

To display a subset of data from a hosted table, you can apply a definition expression using a SQL where clause. This example uses a definition expression to filter records by trail name for the Trailheads hosted table.

Steps

  1. Get the hosted table URL and layer ID.
  2. Create and execute a SQL query.
  3. Display the records.
ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for KotlinArcGIS Maps SDK for SwiftArcGIS Maps SDK for .NETArcGIS Maps SDK for JavaArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
                                                                                                                                                                          
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
          // Create the FeatureTable from the provided FeatureLayer
          const featureTable = new FeatureTable({
            layer: trailsLayer,
            multiSortEnabled: true,
            visibleElements: { selectionColumn: false },
            tableTemplate: {
              // Autocast to TableTemplate
              columnTemplates: [
                // Takes an array of FieldColumnTemplate and GroupColumnTemplate
                {
                  // Autocast to FieldColumnTemplate.
                  type: "field",
                  fieldName: "TRL_NAME",
                  label: "Trail Name",
                  direction: "asc"
                },
                {
                  type: "field",
                  fieldName: "PARK_NAME",
                  label: "Park Name"
                },
                {
                  type: "field",
                  fieldName: "CITY_JUR",
                  label: "City Jurisdiction"
                },
                {
                  type: "field",
                  fieldName: "OPENSTATUS",
                  label: "Open status"
                },
                {
                  type: "field",
                  fieldName: "X_STREET",
                  label: "Street Name"
                },
                {
                  type: "field",
                  fieldName: "ZIP_CODE",
                  label: "Zip Code"
                }
              ]
            },
            container: document.getElementById("tableDiv")
          });

REST API

cURLcURLHTTP
Use dark colors for code blocksCopy
    
1
2
3
4
curl https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trailheads_data/FeatureServer/0/query? \
-d "where=TRL_NAME LIKE '%Medea%'" \
-d "outFields=*" \
-d "f=json"

Join a hosted table to a feature layer

You can combine the attributes from one dataset to another based on attribute relationships which creates new feature data. In this example, you use the JoinFeatures operation from the spatial analysis service to join the Trailheads_data hosted table to the Trailheads_locations hosted feature layer. The resulting layer displays the corresponding attribute information for trailheads.

Steps

  1. Get the hosted table URL.
  2. Get the feature layer URL.
  3. Join the feature table to the feature layer.
  4. Display the resulting layer from the join.

APIs

ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS API for PythonArcGIS REST JS
Expand
Use dark colors for code blocksCopy
                                                                                                                                                                           
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
                const trailsResults = await trailsLayer.load().then(() => {
                    return trailsLayer.queryFeatures({
                        where: "1=1",
                        returnGeometry: true,
                        outFields: ["TRL_NAME"]
                    });
                });

                const tableResults = await tableLayer.load().then(() => {
                    return tableLayer.queryFeatures({
                        where: "1=1",
                        outFields: ["*"],
                        returnGeometry: false
                    });
                });

                const joinedAttFeatures = [];
                trailsResults.features.forEach((trailsFeature) => {
                    tableResults.features.forEach((tableFeature) => {
                        if (trailsFeature.attributes["TRL_NAME"] === tableFeature.attributes["TRL_NAME"]) {
                            trailsFeature.attributes = { ...trailsFeature.attributes, ...tableFeature.attributes };
                            joinedAttFeatures.push(trailsFeature.clone());
                        }
                    })
                });

                const joinedLayer = new FeatureLayer({
                    id: "joined-layer",
                    source: joinedAttFeatures,
                    objectIdField: "ObjectId2",
                    fields: tableLayer.fields,
                    title: "Joined Layer",
                    geometryType: "point",
                    outFields: ["*"]
                })
                map.add(joinedLayer);

                // Add layer to the feature table widget
                const featureTable = new FeatureTable({
                    view: view,
                    layer: joinedLayer,
                    container: tableDiv,
                    hiddenFields: ["OBJECTID"]
                });

Service requests

Request
HTTPHTTPcURL
Use dark colors for code blocksCopy
     
1
2
3
4
5
POST arcgis.com/sharing/rest/portals/self HTTP/1.1
Content-Type: application/x-www-form-urlencoded

&f=json
&token=<ACCESS_TOKEN>
Response (JSON)
Use dark colors for code blocksCopy
           
1
2
3
4
5
6
7
8
9
10
11
{
  "helperServices": {
    // Other parameters
    "analysis": {
      "url": "https://<YOUR_ANALYSIS_SERVICE>/arcgis/rest/services/tasks/GPServer"
    },
    "geoenrichment": {
      "url": "https://geoenrich.arcgis.com/arcgis/rest/services/World/GeoenrichmentServer"
    }
  }
}

Tutorials

Services

Feature service

Add, update, delete, and query feature data.


Vector tile service

Store and access vector tile data.


Image tile service

Store and access image tile data.

API support

Import and create dataDisplay dataQuery dataEdit data
ArcGIS Maps SDK for JavaScript
ArcGIS Maps SDK for Kotlin
ArcGIS Maps SDK for Swift
ArcGIS Maps SDK for Java
ArcGIS Maps SDK for .NET
ArcGIS Maps SDK for Qt
ArcGIS API for Python
ArcGIS REST JS1
Esri Leaflet22
MapLibre GL JS322
OpenLayers322
Full supportPartial supportNo support
  • 1. Access portal via HTTP request and authentication.
  • 2. Access via ArcGIS REST JS.
  • 3. Requires manual application of renderers

Tools

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.