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

# Nodes

> How to select and query nodes in your HelixDB graph by ID or type with code examples

## How do I select nodes in HelixDB?

Use `N` to select nodes from your graph by ID, type, or property values to begin traversals.

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

### Example 1: Selecting a user by ID

<CodeGroup>
  ```helixql 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
  ```

  ```helixql 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>
  ```helixql Query theme={null}
  QUERY GetAllUsers () =>
      users <- N<User>
      RETURN users
  ```

  ```helixql 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>

### Example 3: Selecting nodes by property value

Select nodes by matching INDEX field values instead of ID. This is useful when you need to find nodes with specific property values.

<CodeGroup>
  ```helixql Query focus={1-3} theme={null}
  QUERY GetUserByEmail (email: String) =>
      user <- N<User>({email: email})
      RETURN user
  ```

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

<Note>Property-based selection returns all nodes matching the specified INDEX field values. For more complex filtering conditions, use [WHERE clauses](../conditionals/conditions).</Note>

<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>

## Related operations

* [Create nodes](/documentation/hql/create/addN) - Add new nodes to your graph
* [Traversals](/documentation/hql/traversals/steps_nodes) - Navigate between connected nodes
* [Conditionals](/documentation/hql/conditionals/conditions) - Filter nodes by properties
* [Property access](/documentation/hql/properties/property-access) - Work with node properties
