> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moonbase.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> A quick tour of the Moonbase API.

Moonbase's REST API enables programmatic access to your core Moonbase data, including people, organizations, deals, tasks, and more.

## Quick Start

Let's make your first API request to list items from your Moonbase collections.

<Tabs>
  <Tab title="TypeScript">
    <Steps>
      <Step title="Prerequisites">
        You'll need an API key from your [organization settings](https://app.moonbase.ai/settings/api_keys) in Moonbase. Once you have it, set it as an environment variable:

        ```bash theme={null}
        export MOONBASE_API_KEY=your_api_key_here
        ```
      </Step>

      <Step title="List Your Data">
        Fetch and display all organizations from your collection. The SDK automatically handles pagination to retrieve all details of the organizations collection.

        ```typescript theme={null}
        import Moonbase from "@moonbaseai/sdk";

        // Initialize the Moonbase client
        const moonbase = new Moonbase({
          apiKey: process.env.MOONBASE_API_KEY, // default, can be omitted
        });

        // This returns an AsyncIterator<Item>
        const organizations = moonbase.collections.items.list("organizations");

        // Loop through the items and print the "name" value
        for await (const org of organizations) {
          console.log(org.values.name.data);
        }
        ```

        Example output:

        ```
        OrbGrid
        TechStart Inc
        Global Systems
        Innovate Labs
        ...
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Python">
    <Steps>
      <Step title="Prerequisites">
        You'll need an API key from your [organization settings](https://app.moonbase.ai/settings/api_keys) in Moonbase. Once you have it, set it as an environment variable:

        ```bash theme={null}
        export MOONBASE_API_KEY=your_api_key_here
        ```
      </Step>

      <Step title="List Your Data">
        Fetch and display all organizations from your collection. The SDK automatically handles pagination to retrieve all details of the organizations collection.

        ```python theme={null}
        import os
        from moonbase import Moonbase

        moonbase = Moonbase(
            api_key=os.environ.get("MOONBASE_API_KEY"),  # default, can be omitted
        )

        # Auto-paginated: fetches all items across multiple pages
        organizations = moonbase.collections.items.list(collection_id="organizations")

        # Loop through items and access fields by their ref
        for org in organizations:
            print(org.values['name'].data)
        ```

        Example output:

        ```
        OrbGrid
        TechStart Inc
        Global Systems
        Innovate Labs
        ...
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Go">
    <Steps>
      <Step title="Prerequisites">
        You'll need an API key from your [organization settings](https://app.moonbase.ai/settings/api_keys) in Moonbase. Once you have it, set it as an environment variable:

        ```bash theme={null}
        export MOONBASE_API_KEY=your_api_key_here
        ```
      </Step>

      <Step title="List Your Data">
        Fetch and display all organizations from your collection. The SDK automatically handles pagination to retrieve all details of the organizations collection.

        ```go theme={null}
        package main

        import (
            "context"
            "fmt"
            "log"
            "os"

            "github.com/moonbaseai/moonbase-sdk-go"
            "github.com/moonbaseai/moonbase-sdk-go/option"
        )

        func main() {
            client := moonbase.NewClient(
                option.WithAPIKey(os.Getenv("MOONBASE_API_KEY")), // default, can be omitted
            )

            // Auto-paginated: fetches all items across multiple pages
            organizations := client.Collections.Items.ListAutoPaging(
                context.TODO(), 
                "organizations",
                moonbase.ItemListParams{},
            )
            
            for organizations.Next() {
                org := organizations.Current()
                if nameField, exists := org.Values["name"]; exists {
                    fmt.Println(nameField.Data.OfString)
                }
            }
            
            if err := organizations.Err(); err != nil {
                log.Fatalf("Error fetching organizations: %v", err)
            }
        }
        ```

        Example output:

        ```
        OrbGrid
        TechStart Inc
        Global Systems
        Innovate Labs
        ...
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Ruby">
    <Steps>
      <Step title="Prerequisites">
        You'll need an API key from your [organization settings](https://app.moonbase.ai/settings/api_keys) in Moonbase. Once you have it, set it as an environment variable:

        ```bash theme={null}
        export MOONBASE_API_KEY=your_api_key_here
        ```
      </Step>

      <Step title="List Your Data">
        Fetch and display all organizations from your collection. The SDK automatically handles pagination to retrieve all details of the organizations collection.

        ```ruby theme={null}
        require "moonbase"

        moonbase = Moonbase::Client.new(
          api_key: ENV["MOONBASE_API_KEY"], # default, can be omitted
        )

        organizations = moonbase.collections.items.list("organizations")

        organizations.auto_paging_each do |org|
          puts org.values[:name].data
        end
        ```

        Example output:

        ```
        OrbGrid
        TechStart Inc
        Global Systems
        Innovate Labs
        ...
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="cURL">
    <Steps>
      <Step title="Prerequisites">
        You'll need an API key from your [organization settings](https://app.moonbase.ai/settings/api_keys) in Moonbase. Once you have it, set it as an environment variable:

        ```bash theme={null}
        export MOONBASE_API_KEY=your_api_key_here
        ```
      </Step>

      <Step title="List Items from a Collection">
        Make a GET request to retrieve items from a collection:

        ```bash theme={null}
        curl https://api.moonbase.ai/v0/collections/organizations/items \
          -H "Authorization: Bearer $MOONBASE_API_KEY"
        ```

        Note: This returns the first page of results. To fetch additional pages, use the cursor from the response.
      </Step>

      <Step title="Understanding the Response">
        A successful response returns a JSON object with your items:

        ```json theme={null}
        {
          "type": "list",
          "data": [
            {
              "id": "1CLJt2ub4MavjpDF6NV14F",
              "type": "item",
              "values": {
                "name": {"type": "value/text/single_line", "data": "OrbGrid"},
                "updated_at": {"type": "value/datetime", "data": "2025-02-17T16:00:00.000Z"}
              }
            },
            {
              "id": "1CLJt2ub4MavjpDF6NV14G",
              "type": "item",
              "values": {
                "name": {"type": "value/text/single_line", "data": "TechStart Inc"},
                "updated_at": {"type": "value/datetime", "data": "2025-02-17T16:00:00.000Z"}
              }
            },
            {
              "id": "1CLJt2ub4MavjpDF6NV14H",
              "type": "item",
              "values": {
                "name": {"type": "value/text/single_line", "data": "Global Systems"},
                "updated_at": {"type": "value/datetime", "data": "2025-02-17T16:00:00.000Z"}
              }
            }
            ...
          ],
          "meta": {
            "cursors": {
              "next": "eyJwYWdlIjoyfQ"
            }
          }
        }
        ```

        To fetch the next page, include the cursor as a query parameter:

        ```bash theme={null}
        curl "https://api.moonbase.ai/v0/collections/organizations/items?after=eyJwYWdlIjoyfQ" \
          -H "Authorization: Bearer $MOONBASE_API_KEY"
        ```
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Core Concepts

Continue exploring the Moonbase API with these resources:

* [**SDKs**](/api-reference/libraries): Official Moonbase clients for TypeScript, Python, Go, and Ruby
* [**Pagination**](/api-reference/pagination): Navigate large datasets efficiently with cursor-based pagination
* [**Rate Limiting**](/api-reference/rate-limiting): Understand throughput limits and implement proper backoff strategies
* [**Error Handling**](/api-reference/error-handling): Learn about error shapes and build resilient retry logic
* [**Webhooks**](/webhook-reference/overview): Subscribe to real-time events for changes in your Moonbase data
