# Make an API Request

## Getting Setup

In order to make your first API request, you will first need to:

1. [Create your BlueNexus account](https://docs.bluenexus.ai/introduction/bluenexus-portal/create-account)
2. [Obtain a Personal Access Token](https://docs.bluenexus.ai/introduction/bluenexus-portal/personal-access-tokens) (so you can make authenticated API requests)

## Make your first API Request

We will make the simplest request possible, fetch your account details using the `/accounts/me` endpoint.

{% hint style="success" %}
API reference: [Broken link](https://docs.bluenexus.ai/getting-started/broken-reference "mention")
{% endhint %}

### Authentication

All API requests must specify an authorization header in the format:

```
Authorization: Bearer <access token>
```

Where `<access token>` is your personal access token (obtained above).

When you build your first application, you will obtain an access token that allows you to act on behalf of your connected users.

### Make an API Request

There are several ways you can make your first API request.

#### Example 1: Swagger

The quickest and easiest is to use our [Swagger documentation](https://docs.bluenexus.ai/platform/swagger) to make an API request within your browser.

#### Example 2: Command line (curl)

You can make an API request using curl on your command line:

```bash
curl -X 'GET' \
  '{{space.vars.API_ENDPOINT}}/api/v1/accounts/me' \
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <access token>'
```

#### Example 3: Typescript code

```typescript
const API_URL = "{{space.vars.API_ENDPOINT}}/api/v1/accounts/me";
const ACCESS_TOKEN = "<access token>"; // Replace with your actual token

async function getAccountInfo() {
  try {
    const response = await fetch(API_URL, {
      method: "GET",
      headers: {
        "Accept": "application/json",
        "Authorization": `Bearer ${ACCESS_TOKEN}`,
      },
    });

    if (!response.ok) {
      throw new Error(`Request failed with status ${response.status}`);
    }

    const data = await response.json();
    console.log("Account Info:", data);
  } catch (error) {
    console.error("Error fetching account info:", error);
  }
}

getAccountInfo();
```

## Learn More

* [Learn how to connect user data to your large language model](https://docs.bluenexus.ai/user-data/ai-connectivity-via-mcp/connect-user-data-example)
* [Learn how to access third party APIs connected by your users](https://docs.bluenexus.ai/user-data/third-party-services/api-request-example)
* [Learn how to read / write encrypted user data](https://docs.bluenexus.ai/user-data/database-storage/database-example)
* [api](https://docs.bluenexus.ai/platform/api "mention")
