> ## Documentation Index
> Fetch the complete documentation index at: https://helix-digitalocean.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Nodes

> Learn how to select nodes in your graph.

## `N`   Nodes

Select nodes from your graph to begin traversal.

```rust theme={null}
N<Type>(node_id)
```

### Example 1: Selecting a user by ID

<CodeGroup>
  ```rust Query focus={1-3} [expandable] theme={null}
  QUERY GetUser (user_id: ID) =>
      user <- N<User>(user_id)
      RETURN user

  QUERY CreateUser (name: String, age: U8, email: String) =>
      user <- AddN<User>({
          name: name,
          age: age,
          email: email
      })
      RETURN user
  ```

  ```rust Schema theme={null}
  N::User {
      name: String,
      age: U8,
      email: String,
  }
  ```
</CodeGroup>

<CodeGroup>
  ```python Python [expandable] theme={null}
  from helix.client import Client

  client = Client(local=True, port=6969)

  user = client.query("CreateUser", {
      "name": "Alice",
      "age": 25,
      "email": "alice@example.com",
  })
  user_id = user[0]["user"]["id"]

  result = client.query("GetUser", {"user_id": user_id})
  print(result)
  ```

  ```rust Rust [expandable] theme={null}
  use helix_rs::{HelixDB, HelixDBClient};
  use serde_json::json;

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = HelixDB::new(Some("http://localhost"), Some(6969), None);

      let alice: serde_json::Value = client.query("CreateUser", &json!({
          "name": "Alice",
          "age": 25,
          "email": "alice@example.com",
      })).await?;
      let user_id = alice["user"]["id"].as_str().unwrap().to_string();

      let result: serde_json::Value = client.query("GetUser", &json!({
          "user_id": user_id,
      })).await?;

      println!("GetUser result: {result:#?}");

      Ok(())
  }
  ```

  ```go Go [expandable] theme={null}
  package main

  import (
      "fmt"
      "log"

      "github.com/HelixDB/helix-go"
  )

  func main() {
      client := helix.NewClient("http://localhost:6969")

      createPayload := map[string]any{
          "name":  "Alice",
          "age":   uint8(25),
          "email": "alice@example.com",
      }

      var created map[string]any
      if err := client.Query("CreateUser", helix.WithData(createPayload)).Scan(&created); err != nil {
          log.Fatalf("CreateUser failed: %s", err)
      }

      userID := created["user"].(map[string]any)["id"].(string)

      var result map[string]any
      if err := client.Query("GetUser", helix.WithData(map[string]any{"user_id": userID})).Scan(&result); err != nil {
          log.Fatalf("GetUser failed: %s", err)
      }

      fmt.Printf("GetUser result: %#v\n", result)
  }
  ```

  ```typescript TypeScript [expandable] theme={null}
  import HelixDB from "helix-ts";

  async function main() {
      const client = new HelixDB("http://localhost:6969");

      const created = await client.query("CreateUser", {
          name: "Alice",
          age: 25,
          email: "alice@example.com",
      });
      const userId: string = created.user.id;

      const result = await client.query("GetUser", {
          user_id: userId,
      });

      console.log("GetUser result:", result);
  }

  main().catch((err) => {
      console.error("GetUser query failed:", err);
  });
  ```

  ```bash Curl [expandable] theme={null}
  curl -X POST \
    http://localhost:6969/CreateUser \
    -H 'Content-Type: application/json' \
    -d '{"name":"Alice","age":25,"email":"alice@example.com"}'

  curl -X POST \
    http://localhost:6969/GetUser \
    -H 'Content-Type: application/json' \
    -d '{"user_id":"<user_id>"}'
  ```
</CodeGroup>

### Example 2: Selecting all users

<CodeGroup>
  ```rust Query theme={null}
  QUERY GetAllUsers () =>
      users <- N<User>
      RETURN users
  ```

  ```rust Schema theme={null}
  N::User {
      name: String,
      age: U8,
      email: String,
  }
  ```
</CodeGroup>

<CodeGroup>
  ```python Python theme={null}
  from helix.client import Client

  client = Client(local=True, port=6969)

  result = client.query("GetAllUsers")
  print(result)
  ```

  ```rust Rust theme={null}
  use helix_rs::{HelixDB, HelixDBClient};

  #[tokio::main]
  async fn main() -> Result<(), Box<dyn std::error::Error>> {
      let client = HelixDB::new(Some("http://localhost"), Some(6969), None);

      let result: serde_json::Value = client.query("GetAllUsers", &()).await?;
      println!("GetAllUsers result: {result:#?}");

      Ok(())
  }
  ```

  ```go Go theme={null}
  package main

  import (
      "fmt"
      "log"

      "github.com/HelixDB/helix-go"
  )

  func main() {
      client := helix.NewClient("http://localhost:6969")

      var result map[string]any
      if err := client.Query("GetAllUsers").Scan(&result); err != nil {
          log.Fatalf("GetAllUsers failed: %s", err)
      }

      fmt.Printf("GetAllUsers result: %#v\n", result)
  }
  ```

  ```typescript TypeScript theme={null}
  import HelixDB from "helix-ts";

  async function main() {
      const client = new HelixDB("http://localhost:6969");

      const result = await client.query("GetAllUsers", {});
      console.log("GetAllUsers result:", result);
  }

  main().catch((err) => {
      console.error("GetAllUsers query failed:", err);
  });
  ```

  ```bash Curl theme={null}
  curl -X POST \
    http://localhost:6969/GetAllUsers \
    -H 'Content-Type: application/json' \
    -d '{}'
  ```
</CodeGroup>

<Note>You can also do specific property-based filtering, e.g., returning only ID, see the [Property Filtering](../properties/property-access). You can also do aggregation steps, e.g., returning the count of nodes, see the [Aggregations](../aggregation).</Note>
