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

# SDKs

> Use the Moonbase API with an SDK in your preferred language.

Moonbase provides SDKs for [TypeScript/JavaScript](https://github.com/moonbaseai/moonbase-sdk-typescript), [Python](https://github.com/moonbaseai/moonbase-sdk-python), [Go](https://github.com/moonbaseai/moonbase-sdk-go), and [Ruby](https://github.com/moonbaseai/moonbase-sdk-ruby). SDKs handle authentication, request formatting, and response parsing. Built-in retries handle rate limits and transient errors.

## Prerequisites

* API key from [organization settings](https://app.moonbase.ai/settings/api_keys).
* Review the [authentication guide](./authentication).

<Warning>
  Keep API keys secret. Avoid client-side exposure.
</Warning>

## Installation and usage

<Tabs>
  <Tab title="TypeScript">
    Install the TypeScript SDK using npm:

    <CodeGroup>
      ```sh npm theme={null}
      npm install @moonbaseai/sdk
      ```

      ```sh Yarn theme={null}
      yarn add @moonbaseai/sdk
      ```

      ```sh pnpm theme={null}
      pnpm add @moonbaseai/sdk
      ```

      ```sh Bun theme={null}
      bun add @moonbaseai/sdk
      ```
    </CodeGroup>

    Usage:

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

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

    const collection = await moonbase.collections.retrieve('organizations');

    console.log(collection.id);
    ```

    <Card title="TypeScript SDK on GitHub" icon="square-code" horizontal href="https://github.com/moonbaseai/moonbase-sdk-typescript">
      View documentation, examples, and source code for the TypeScript SDK.
    </Card>
  </Tab>

  <Tab title="Python">
    Install the Python SDK using pip:

    ```sh theme={null}
    pip install --pre moonbase-sdk
    ```

    Usage:

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

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

    collection = moonbase.collections.retrieve(
        id="organizations",
    )
    print(collection.id)
    ```

    <Card title="Python SDK on GitHub" icon="square-code" horizontal href="https://github.com/moonbaseai/moonbase-sdk-python">
      View documentation, examples, and source code for the Python SDK.
    </Card>
  </Tab>

  <Tab title="Go">
    Install the Go SDK:

    ```sh theme={null}
    go get github.com/moonbaseai/moonbase-sdk-go@v0.1.0-alpha.2
    ```

    Usage:

    ```go theme={null}
    package main

    import (
    	"context"
    	"fmt"

    	"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")), // This is the default and can be omitted
    	)
    	collection, err := client.Collections.Get(
    		context.TODO(),
    		"organizations",
    		moonbase.CollectionGetParams{},
    	)
    	if err != nil {
    		panic(err.Error())
    	}
    	fmt.Printf("%+v\n", collection.ID)
    }
    ```

    <Card title="Go SDK on GitHub" icon="square-code" horizontal href="https://github.com/moonbaseai/moonbase-sdk-go">
      View documentation, examples, and source code for the Go SDK.
    </Card>
  </Tab>

  <Tab title="Ruby">
    Install the Ruby SDK:

    ```ruby theme={null}
    gem "moonbase-sdk", "~> 0.1.0.pre.alpha.2"
    ```

    Then run:

    ```sh theme={null}
    bundle install
    ```

    Usage:

    ```ruby theme={null}
    require "bundler/setup"
    require "moonbase"

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

    collection = moonbase.collections.retrieve("organizations")

    puts(collection.id)
    ```

    <Card title="Ruby SDK on GitHub" icon="square-code" horizontal href="https://github.com/moonbaseai/moonbase-sdk-ruby">
      View documentation, examples, and source code for the Ruby SDK.
    </Card>
  </Tab>
</Tabs>
