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

# List Datasources

> Retrieve a list of all datasources in your organization. Supports optional pagination for large datasets.

Get a list of all datasources configured in your organization. Useful for managing datasources, verifying configurations, and identifying datasource names for use in other APIs.

<Note>
  This endpoint returns all datasources you have access to within your organization. The response includes only the datasource names for security reasons - full credentials are never returned.
</Note>

## Endpoint

```
GET https://api.usedatabrain.com/api/v2/datasource
```

## Self-hosted Databrain Endpoint

```
GET <SELF_HOSTED_URL>/api/v2/datasource
```

## Authentication

This endpoint requires a service token in the Authorization header. Service tokens differ from data app API keys and provide organization-level permissions.

To access your service token:

1. In **Settings** page, navigate to the **Service Tokens** section.
2. Click the **"Generate Token"** button to create a new service token if you don't have one already.

<Panel>
  <RequestExample>
    ```bash Authentication theme={"dark"}
    curl --request GET \
      --url 'https://api.usedatabrain.com/api/v2/datasource?isPagination=true&pageNumber=1' \
      --header 'Authorization: Bearer dbn_live_...'
    ```
  </RequestExample>
</Panel>

## Headers

<ParamField header="Authorization" type="string" required>
  Bearer token for API authentication. Use your service token.

  ```
  Authorization: Bearer dbn_live_abc123...
  ```
</ParamField>

## Query Parameters

<ParamField query="isPagination" type="string" default="false">
  Enable pagination for the results. Pass `"true"` to enable pagination with a limit of 10 datasources per page.

  **Note:** Query parameters are passed as strings. Use `"true"` or `"false"` (not boolean values).
</ParamField>

<ParamField query="pageNumber" type="string" default="1">
  Page number to retrieve (1-based). Only used when `isPagination` is `"true"`. Must be a numeric string (e.g., `"1"`, `"2"`, `"3"`).

  <Expandable title="Pagination details">
    * First page is `"1"` (not `"0"`)
    * Each page returns up to 10 datasources
    * Only effective when `isPagination` is `"true"`
  </Expandable>
</ParamField>

## Response

<ResponseField name="data" type="array">
  Array of datasource objects. Each object contains only the datasource name for security reasons.
</ResponseField>

<ResponseField name="data.name" type="string">
  The name of the datasource. This name can be used in other APIs to reference the datasource.
</ResponseField>

<ResponseField name="error" type="null">
  Error field, null when successful. Not included in successful responses.
</ResponseField>

## Examples

<Panel>
  <RequestExample>
    ```bash cURL - Without Pagination theme={"dark"}
    curl --request GET \
      --url https://api.usedatabrain.com/api/v2/datasource \
      --header 'Authorization: Bearer dbn_live_abc123...'
    ```

    ```bash cURL - With Pagination theme={"dark"}
    curl --request GET \
      --url 'https://api.usedatabrain.com/api/v2/datasource?isPagination=true&pageNumber=1' \
      --header 'Authorization: Bearer dbn_live_abc123...'
    ```

    ```javascript Node.js theme={"dark"}
    // List all datasources
    const response = await fetch('https://api.usedatabrain.com/api/v2/datasource', {
      method: 'GET',
      headers: {
        'Authorization': 'Bearer dbn_live_abc123...'
      }
    });

    const data = await response.json();
    if (data.error) {
      console.error('Error:', data.error);
    } else {
      console.log('Found datasources:', data.data.length);
      data.data.forEach(datasource => {
        console.log('-', datasource.name);
      });
    }
    ```

    ```javascript Node.js - With Pagination theme={"dark"}
    // List datasources with pagination
    const pageNumber = 1;
    const response = await fetch(
      `https://api.usedatabrain.com/api/v2/datasource?isPagination=true&pageNumber=${pageNumber}`,
      {
        method: 'GET',
        headers: {
          'Authorization': 'Bearer dbn_live_abc123...'
        }
      }
    );

    const data = await response.json();
    console.log(`Page ${pageNumber} datasources:`, data.data.length);
    ```

    ```python Python theme={"dark"}
    import requests

    # List all datasources
    response = requests.get(
        'https://api.usedatabrain.com/api/v2/datasource',
        headers={
            'Authorization': 'Bearer dbn_live_abc123...'
        }
    )

    data = response.json()
    if data.get('error'):
        print('Error:', data['error'])
    else:
        print(f'Found {len(data["data"])} datasources:')
        for datasource in data['data']:
            print(f"  - {datasource['name']}")
    ```

    ```python Python - With Pagination theme={"dark"}
    import requests

    # List datasources with pagination
    url = "https://api.usedatabrain.com/api/v2/datasource"
    headers = {
        "Authorization": "Bearer dbn_live_abc123..."
    }
    params = {
        "isPagination": "true",
        "pageNumber": "1"
    }

    response = requests.get(url, headers=headers, params=params)
    data = response.json()
    print(f"Page 1 datasources: {len(data['data'])}")
    ```
  </RequestExample>

  <ResponseExample>
    ```json Success Response theme={"dark"}
    {
      "data": [
        {
          "name": "production-postgres"
        },
        {
          "name": "analytics-snowflake"
        },
        {
          "name": "warehouse-bigquery"
        }
      ]
    }
    ```

    ```json Success Response - Empty List theme={"dark"}
    {
      "data": []
    }
    ```

    ```json Error Response (400) theme={"dark"}
    {
      "error": {
        "code": "INVALID_REQUEST_BODY",
        "message": "Invalid pagination parameters",
        "status": 400
      }
    }
    ```

    ```json Error Response (401) theme={"dark"}
    {
      "error": {
        "code": "AUTHENTICATION_ERROR",
        "message": "AUTHENTICATION_ERROR",
        "status": 401
      }
    }
    ```

    ```json Error Response (500) theme={"dark"}
    {
      "error": {
        "code": "INTERNAL_SERVER_ERROR",
        "message": "Internal server error",
        "status": 500
      }
    }
    ```
  </ResponseExample>
</Panel>

## Error Codes

| Error Code              | HTTP Status | Description                      |
| ----------------------- | ----------- | -------------------------------- |
| `INVALID_REQUEST_BODY`  | 400         | Invalid pagination parameters    |
| `AUTHENTICATION_ERROR`  | 401         | Invalid or missing service token |
| `INTERNAL_SERVER_ERROR` | 500         | Server error occurred            |

## Next Steps

<CardGroup cols={2}>
  <Card title="Create Datasource" icon="plus" href="/developer-docs/helpers/api-reference/create-datasource">
    Create new datasources for your organization
  </Card>

  <Card title="Update Datasource" icon="edit" href="/developer-docs/helpers/api-reference/update-datasource">
    Update existing datasource credentials
  </Card>

  <Card title="Delete Datasource" icon="trash" href="/developer-docs/helpers/api-reference/delete-datasource">
    Remove datasources you no longer need
  </Card>

  <Card title="Sync Datasource" icon="sync" href="/developer-docs/helpers/api-reference/sync-datasource">
    Sync datasource schema after changes
  </Card>
</CardGroup>
