---
title: "Run Built-in Queries - GSQL 101"
component: "gsql-ref"
version: "4.1"
module: "tutorials"
html_url: "/gsql-ref/4.1/tutorials/gsql-101/built-in-select-queries"
canonical_url: "https://www.tigergraph.com/docs/gsql-ref/4.1/tutorials/gsql-101/built-in-select-queries"
markdown_url: "https://www.tigergraph.com/docs/gsql-ref/4.1/tutorials/gsql-101/built-in-select-queries.md"
---

[View as HTML](https://www.tigergraph.com/docs/gsql-ref/4.1/tutorials/gsql-101/built-in-select-queries)

# Run Built-in Queries - GSQL 101

You now have a graph with data! You can run some queries using the built-in REST endpoint calls.

## Get vertex/edge statistics

Here we call two functions, `stat_vertex_number` and `stat_edge_number` to return the number of vertices and edges of each vertex and edge type.

> [!NOTE]
> REST endpoints return results in JSON format. However, JSON data can't be read easily from JSON files by using bash script like other normal files. The `jq` tool is used to solve this problem.
> 
> We recommend you install jq and redirect the REST call result to jq before it is output.

Linux Shell

```bash
// Get vertex cardinality
curl -X POST 'http://localhost:14240/restpp/builtins/Social' -d  '{"function":"stat_vertex_number","type":"*"}'  | jq .
```

```javascript
// results
{
  "version": {
    "edition": "enterprise",
    "api": "v2",
    "schema": 0
  },
  "error": false,
  "message": "",
  "results": [
    {
      "v_type": "Person",
      "count": 7
    }
  ]
}
```

Linux Shell

```bash
# get edge cardinality
curl -X POST 'http://localhost:14240/restpp/builtins/Social' -d  '{"function":"stat_edge_number","type":"*"}' | jq .
```

```javascript
{
  "version": {
    "edition": "enterprise",
    "api": "v2",
    "schema": 0
  },
  "error": false,
  "message": "",
  "results": [
    {
      "e_type": "Friendship",
      "count": 7
    }
  ]
}
```

## Select vertices

If you want to look up the details about a vertex with its primary ID, you can use the following REST call.

Linux Shell

```bash
curl -X GET "http://localhost:14240/restpp/graph/{graph_name}/vertices/{vertex_type}/{vertex_id}"
```

**Example**. Find a Person vertex whose `primary_id` is "Tom".

Linux Shell

```bash
 curl -X GET "http://localhost:14240/restpp/graph/Social/vertices/Person/Tom" | jq .
```

```javascript
 {
  "version": {
    "edition": "enterprise",
    "api": "v2",
    "schema": 0
  },
  "error": false,
  "message": "",
  "results": [
    {
      "v_id": "Tom",
      "v_type": "Person",
      "attributes": {
        "name": "Tom",
        "age": 40,
        "gender": "male",
        "state": "ca"
      }
    }
  ]
}
```

## Select edges

In similar fashion, we can see details about edges. To describe an edge, you name the types of vertices and edges in the two parts or three parts of a URL.

Linux Shell

```bash
#two parts
curl -X GET "http://localhost:14240/restpp/graph/edges/{source_vertex_type}/{source_vertex_id}/{edge_type}/"

#three parts
curl -X GET "http://localhost:14240/restpp/graph/edges/{source_vertex_type}/{source_vertex_id}/{edge_type}/{target_vertex_type}/{target_vertex_id}"
```

**Example**. Find all friendship edges whose source vertex's `primary_id` is "Tom".

Linux Shell

```bash
curl -X GET "http://localhost:14240/restpp/graph/Social/edges/Person/Tom/Friendship/" | jq .
```

```gsql
// results
{
    "version": {
        "edition": "enterprise",
        "api": "v2",
        "schema": 0
    },
    "error": false,
    "message": "",
    "results": [
    {
        "e_type": "Friendship",
        "directed": false,
        "from_id": "Tom",
        "from_type": "Person",
        "to_id": "Dan",
        "to_type": "Person",
        "attributes": {
        "connect_day": "2017-06-03 00:00:00"
        }
    },
    {
        "e_type": "Friendship",
        "directed": false,
        "from_id": "Tom",
        "from_type": "Person",
        "to_id": "Jenny",
        "to_type": "Person",
        "attributes": {
        "connect_day": "2015-01-01 00:00:00"
        }
    }
    ]
}
```

For more built-in REST endpoints, visit the [Built-in Endpoints page](https://www.tigergraph.com/docs/tigergraph-server/4.1/API/built-in-endpoints.md).
