# Get started with the Orbit API scripts

This guide takes you from getting the scripts to your first successful call to the Orbit API.

## Before you start

You need:

- PowerShell 4 or later. The scripts were developed on Windows and haven't been tested on macOS or Linux.
- An Orbit installation running Orbit API 2.3.10 or later
- An Orbit username and password for the DataView you want to work with

Some scripts, including all the Connect scripts, also need the OrbitAdmin role.

## Get the scripts

Most scripts are standalone. To use one, download just that file, plus `Login.ps1` to get an access token.

The scripts in `Powershell/Workflows` combine other scripts, so they need the whole `Powershell` folder. To get everything, clone the , or select **Code \> Download ZIP** on GitHub.

If Windows blocks the scripts because they came from the internet, unblock them:

PowerShell

```powershell
Get-ChildItem -Recurse -Filter *.ps1 | Unblock-File
```

## Find your API URLs

Orbit has separate APIs, each with its own base URL. One access token from `Login.ps1` works with all of them.

| API | Typical base URL | What it covers |
| --- | --- | --- |
| Orbit API | `https://<host>/OrbitAPI` | Dashboards, themes, audiences, users, and most other Orbit features. Most scripts use it. |
| Connect API | `https://<host>/OrbitConnectAPI` | Orbit Connect, where you build your system from your own data. The scripts in `Powershell/Connect` use it to manage user-defined table definitions. |
| Chat API | `https://<host>/ChatAPI` | The Orin AI assistant. Only `HealthCheck.ps1` uses it. |

Pass the right base URL to each script, usually with its `-BaseUrl` parameter. The scripts add the DataView name and endpoint path themselves.

## Open the API reference

Add `/swagger/ui` to your Orbit API URL (for example `https://example.com/OrbitAPI/swagger/ui`) to browse every endpoint.

The page links to the API's JSON definition, at `/swagger/v2/swagger.json`. AI tools can use it to help you write new scripts. See [Use AI tools with the Orbit API](<https://help.apteco.com/en/admin/orbit-api/ai-prompt-ideas/index.md>).

## Log in

`Login.ps1` prompts for your password and outputs an access token. Keep it in a variable:

PowerShell session

```text
> cd .\Powershell

> $token = .\Login.ps1 -BaseUrl https://example.com/OrbitAPI -DataViewName holidays -Username myuser
Enter password: *******
```

If your user has multi-factor authentication (MFA) turned on, the script then asks for the 6-digit code from your authenticator app. The code changes every 30 seconds, so scripts can't log in as that user unattended.

## Make your first call

Pass the token to another script with `-AccessToken`. For example, list the dashboards you can see:

PowerShell session

```text
> .\Dashboards\ListDashboards.ps1 -BaseUrl https://example.com/OrbitAPI -DataViewName holidays -AccessToken $token
Getting dashboards for user myuser...
1: Summary Dashboard - Spring Campaign
3: Customer Instant Insights
4: Impact Report Last Month
Got 3 dashboards
```

To check that the APIs are running and can reach their databases and services, run `HealthCheck.ps1`.

## Keep your credentials safe

Anyone with your password or access token has the same access to Orbit as you.

- Let `Login.ps1` ask for your password rather than passing it with `-Password`. PowerShell can save the commands you type to a history file, password included.
- Keep the access token in a variable, as in [Log in](<#log-in>). Without one, `Login.ps1` prints the token on screen. Don't paste it into script files, shared documents, or AI tools.
- Use `https://` base URLs only. Over `http://`, your password and token are sent unencrypted.
- Log in as a user with only the access a script needs. Keep OrbitAdmin users for the scripts that need that role.

## Next steps

- [Orbit API overview](<https://help.apteco.com/en/admin/orbit-api/api-overview/index.md>): how the Orbit API works, with its key endpoints
- [Orbit API cookbook](<https://help.apteco.com/en/admin/orbit-api/index.md>): every script, and walkthroughs that combine them
- [Use AI tools with the Orbit API](<https://help.apteco.com/en/admin/orbit-api/ai-prompt-ideas/index.md>): writing new scripts with an AI tool

> [!WARNING]
>
> These scripts are examples only, and aren't officially supported. Test them on a non-production system before you run them against live data.
