Get started

GraphQL endpoint

The Urban GraphQL API has a single public endpoint:

https://urban-api.arcgis.com/graphql

The endpoint remains the same for all Urban API GraphQL operations.

Form GraphQL calls

This section explains how to make requests to the GraphQL API. There are a few different ways to do it, namely:

  1. Send raw GraphQL queries with cURL
  2. Send raw GraphQL queries with GraphiQL
  3. Send raw GraphQL queries from JavaScript
  4. Use client libraries

Each subsection explains how to use the urbanModels query to list the id and title attributes of publicly accessible urban models. The server response should look something like this:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
  "data": {
    "urbanModels": [
      {
        "id": "e57f2982d5e74885979c975a904a6148",
        "title": "River Forest Urban Model"
      },
      {
        "id": "9c8bd4c0f6384b1c919c3a65a215713f",
        "title": "Utrecht"
      },
      {
        "id": "0f4c1fc028aa43d5b57d20c5fe5bb9c4",
        "title": "Grand-Lyon"
      }
    ]
  }
}

Note, that up to 10 models are returned by the server due to the default limit. To return more models, change the limit argument.

Send raw GraphQL queries with cURL

Use the following cURL command to retrieve a list of the IDs and names of all publicly visible urban models:

Use dark colors for code blocksCopy
1
2
3
4
5
curl \
  -X POST \
  -H "Content-Type: application/json" \
  --data '{ "query": "{ urbanModels { id title } }" }' \
  https://urban-api.arcgis.com/graphql

Send raw GraphQL queries with GraphiQL

Open GraphiQL by loading the Urban API endpoint in a web browser. You can also explore GraphiQL in the API Reference section, which embeds the same GraphQL endpoint in the ArcGIS for developers webpage.

Use the following query to retrieve a list of the IDs and names of all publicly visible urban models:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
query {
  urbanModels {
    id
    title
    owner
  }
}

Send raw GraphQL queries from JavaScript

Alternatively, embed the following code snippet in a JavaScript code to send the same query to the server as in the examples above:

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
fetch("/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Accept: "application/json"
  },
  body: JSON.stringify({ query: "{ urbanModels { id title } }" })
})
  .then((r) => r.json())
  .then((data) => console.log("data returned:", data));

Use client libraries

Client libraries will provide you with the fastest and most comprehensive way to access the API. They assist in formatting your requests and responses and simplify authentication handling. You can use the Urban API with any programming language and framework. See the official GraphQL list of the libraries in all sorts of languages.

Use the following code snippet to retrieve a list of the IDs and names of all publicly visible urban models using Python and the sqglc client library:

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
from sgqlc.operation import Operation
from sgqlc.endpoint.http import HTTPEndpoint
from urban_api_schema import urban_api_schema as schema

url = 'https://urban-api.arcgis.com/graphql'

op = Operation(schema.Query) # module operation generates Queries and Mutations
urban_models = op.urban_models
urban_models.id()
urban_models.title()

endpoint = HTTPEndpoint(url)
json_data = endpoint(op)

# add the JSON data to the operation to interpret the results and produce convenient objects
obj = op + json_data
urban_models_data = obj.urban_models
for urban_model in urban_models_data:
    print(urban_model)

The above code snipet will print information about the urban models returned from the query, and will look similar to:

Use dark colors for code blocksCopy
1
2
3
UrbanModel(id=fd45a15550cf4ea6b361e3c54c8d3ed1, title=Sample Urban Project)
UrbanModel(id=9dd5bed4a5b847c8a9feddeb410a5193, title=Modelo Curso ArcGIS Urban 2.0)
UrbanModel(id=e57f2982d5e74885979c975a904a6148, title=River Forest Urban Model)

See the Get started with Python sgqlc client library guide for more information.

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