# Getting Started

{% hint style="success" %}
This is the official documentation of the `forestadmin-agent-django` and `forestadmin-agent-flask` Python agents.
{% endhint %}

After doing the quick start, you should have a development project which is up and running and connected to your main data storage system.

However, you can plug as many data sources as you want into the same agent.

### What can I connect to?

Forest Admin collections map to any of those concepts:

* ORM models
* Endpoints on SaaS providers (by writing a custom data source)
* Endpoints on your own API (by writing a custom data source)

### Example

#### Flask / SQLAlchemy

In this example, we import collections from SQLAlchemy ORM.

{% tabs %}
{% tab title="Alone SQLAlchmy" %}

```python
from flask import Flask
from sqlalchemy.orm import declarative_base
from forestadmin.flask_agent.agent import create_agent
from forestadmin.datasource_sqlalchemy.datasource import SqlAlchemyDatasource

app = Flask(__name__)
Base = declarative_base(engine)

# ...

agent = create_agent(app)
# db_uri parameter is optional, but if the agent can't find
# an engine in your Base class you have to set it
agent.add_datasource(SqlAlchemyDatasource(Base, db_uri='sqlite:///path/to/db.sql'))

```

{% endtab %}

{% tab title="With Flask-SQLAlchemy package" %}

```python
from flask_sqlalchemy import SQLAlchemy
from flask import Flask
from forestadmin.flask_agent.agent import create_agent
from forestadmin.datasource_sqlalchemy.datasource import SqlAlchemyDatasource

app = Flask(__name__)
db = SQLAlchemy()

# ...

agent = create_agent(app)
# with app_context you don't have to specify the db_uri parameter
with app.app_context():
    # db.init_app(app)
    agent.add_datasource(SqlAlchemyDatasource(db))
```

{% endtab %}
{% endtabs %}

#### Django

With the Django agent, the Django datasource is automatically added. If you prefer to add the datasource manually you have to:

* In project/settings.py set `FOREST_AUTO_ADD_DJANGO_DATASOURCE = False` to not auto add it
* Add a customization function
* Reference the customization function in project/settings.py
* Add the datasource in the customization function `FOREST_CUSTOMIZE_FUNCTION="path.to.custom.function"`

{% tabs %}
{% tab title="project/settings.py" %}

```python
FOREST_AUTO_ADD_DJANGO_DATASOURCE = False
FOREST_CUSTOMIZE_FUNCTION = "my_app.forest_admin.customize_forest"
# you can also directly pass a function
from my_app.forest_admin import customize_forest
FOREST_CUSTOMIZE_FUNCTION = customize_forest
```

{% endtab %}

{% tab title="my\_app/forest\_admin.py" %}

```python
from forestadmin.django_agent.agent import DjangoAgent
from forestadmin.datasource_django.datasource import DjangoDatasource

def customize_forest(agent: DjangoAgent):
    agent.add_datasource(DjangoDatasource())
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.forestadmin.com/developer-guide-agents-python/data-sources/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
