# Marketplace

> The Marketplace routes of the LightHouse API: 9 operations, generated from the OpenAPI document.

Every request goes to your tenant’s own host, `https://<tenant id>.atlanticagenticlabs.com`, and is scoped to that tenant by row-level security. The examples read `AAL_TENANT`, `AAL_KEY` and your Access service token from the environment: see [Authentication](/api/authentication/).

## Library List

`GET /api/v1/library`

**Authentication:** A person’s session, or a machine key with your Access service token, as the route’s role allows. A route that approves, decides, pays or changes a limit refuses a machine key (`person_required`).

| Status | Meaning                                                                                     |
| ------ | ------------------------------------------------------------------------------------------- |
| 200    | OK: the JSON document this route reads.                                                     |
| 4XX    | Refused: `{error, message}` with a fixed `error` code, listed under [Errors](/api/errors/). |

**curl**

```bash
curl "https://$AAL_TENANT.atlanticagenticlabs.com/api/v1/library" \
  -H "Authorization: Bearer $AAL_KEY" \
  -H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
  -H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"
```

**Python**

```python
import os

import httpx

headers = {
    "Authorization": f"Bearer {os.environ['AAL_KEY']}",
    "CF-Access-Client-Id": os.environ["CF_ACCESS_CLIENT_ID"],
    "CF-Access-Client-Secret": os.environ["CF_ACCESS_CLIENT_SECRET"],
}
r = httpx.get(f"https://{os.environ['AAL_TENANT']}.atlanticagenticlabs.com/api/v1/library", headers=headers)
r.raise_for_status()
print(r.json())
```

**TypeScript**

```ts
const res = await fetch(
  `https://${process.env.AAL_TENANT}.atlanticagenticlabs.com/api/v1/library`,
  {
    headers: {
      Authorization: `Bearer ${process.env.AAL_KEY}`,
      "CF-Access-Client-Id": process.env.CF_ACCESS_CLIENT_ID!,
      "CF-Access-Client-Secret": process.env.CF_ACCESS_CLIENT_SECRET!,
    },
  },
);
if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).error}`);
console.log(await res.json());
```

## Library Card

`GET /api/v1/library/{namespace}/{name}`

**Authentication:** A person’s session, or a machine key with your Access service token, as the route’s role allows. A route that approves, decides, pays or changes a limit refuses a machine key (`person_required`).

| Parameter   | In   | Type   | Required |
| ----------- | ---- | ------ | -------- |
| `namespace` | path | string | yes      |
| `name`      | path | string | yes      |

| Status | Meaning                                                                                        |
| ------ | ---------------------------------------------------------------------------------------------- |
| 200    | OK: the JSON document this route reads.                                                        |
| 400    | Bad request, `bad_query`: a path or query parameter, or a body field, is missing or not valid. |
| 4XX    | Refused: `{error, message}` with a fixed `error` code, listed under [Errors](/api/errors/).    |

**curl**

```bash
curl "https://$AAL_TENANT.atlanticagenticlabs.com/api/v1/library/NAMESPACE/NAME" \
  -H "Authorization: Bearer $AAL_KEY" \
  -H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
  -H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"
```

**Python**

```python
import os

import httpx

headers = {
    "Authorization": f"Bearer {os.environ['AAL_KEY']}",
    "CF-Access-Client-Id": os.environ["CF_ACCESS_CLIENT_ID"],
    "CF-Access-Client-Secret": os.environ["CF_ACCESS_CLIENT_SECRET"],
}
r = httpx.get(f"https://{os.environ['AAL_TENANT']}.atlanticagenticlabs.com/api/v1/library/NAMESPACE/NAME", headers=headers)
r.raise_for_status()
print(r.json())
```

**TypeScript**

```ts
const res = await fetch(
  `https://${process.env.AAL_TENANT}.atlanticagenticlabs.com/api/v1/library/NAMESPACE/NAME`,
  {
    headers: {
      Authorization: `Bearer ${process.env.AAL_KEY}`,
      "CF-Access-Client-Id": process.env.CF_ACCESS_CLIENT_ID!,
      "CF-Access-Client-Secret": process.env.CF_ACCESS_CLIENT_SECRET!,
    },
  },
);
if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).error}`);
console.log(await res.json());
```

## Library Add

`POST /api/v1/library/{namespace}/{name}/add`

**Authentication:** A person’s session, or a machine key with your Access service token, as the route’s role allows. A route that approves, decides, pays or changes a limit refuses a machine key (`person_required`).

| Parameter   | In   | Type   | Required |
| ----------- | ---- | ------ | -------- |
| `namespace` | path | string | yes      |
| `name`      | path | string | yes      |

| Status | Meaning                                                                                        |
| ------ | ---------------------------------------------------------------------------------------------- |
| 201    | Created: the new resource, as JSON.                                                            |
| 400    | Bad request, `bad_query`: a path or query parameter, or a body field, is missing or not valid. |
| 4XX    | Refused: `{error, message}` with a fixed `error` code, listed under [Errors](/api/errors/).    |

**curl**

```bash
curl -X POST "https://$AAL_TENANT.atlanticagenticlabs.com/api/v1/library/NAMESPACE/NAME/add" \
  -H "Authorization: Bearer $AAL_KEY" \
  -H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
  -H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"
```

**Python**

```python
import os

import httpx

headers = {
    "Authorization": f"Bearer {os.environ['AAL_KEY']}",
    "CF-Access-Client-Id": os.environ["CF_ACCESS_CLIENT_ID"],
    "CF-Access-Client-Secret": os.environ["CF_ACCESS_CLIENT_SECRET"],
}
r = httpx.post(f"https://{os.environ['AAL_TENANT']}.atlanticagenticlabs.com/api/v1/library/NAMESPACE/NAME/add", headers=headers)
r.raise_for_status()
print(r.json())
```

**TypeScript**

```ts
const res = await fetch(
  `https://${process.env.AAL_TENANT}.atlanticagenticlabs.com/api/v1/library/NAMESPACE/NAME/add`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.AAL_KEY}`,
      "CF-Access-Client-Id": process.env.CF_ACCESS_CLIENT_ID!,
      "CF-Access-Client-Secret": process.env.CF_ACCESS_CLIENT_SECRET!,
    },
  },
);
if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).error}`);
console.log(await res.json());
```

## Market Ledger

`GET /api/v1/market/ledger`

**Authentication:** A person’s session, or a machine key with your Access service token, as the route’s role allows. A route that approves, decides, pays or changes a limit refuses a machine key (`person_required`).

| Status | Meaning                                                                                     |
| ------ | ------------------------------------------------------------------------------------------- |
| 200    | OK: the JSON document this route reads.                                                     |
| 4XX    | Refused: `{error, message}` with a fixed `error` code, listed under [Errors](/api/errors/). |

**curl**

```bash
curl "https://$AAL_TENANT.atlanticagenticlabs.com/api/v1/market/ledger" \
  -H "Authorization: Bearer $AAL_KEY" \
  -H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
  -H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"
```

**Python**

```python
import os

import httpx

headers = {
    "Authorization": f"Bearer {os.environ['AAL_KEY']}",
    "CF-Access-Client-Id": os.environ["CF_ACCESS_CLIENT_ID"],
    "CF-Access-Client-Secret": os.environ["CF_ACCESS_CLIENT_SECRET"],
}
r = httpx.get(f"https://{os.environ['AAL_TENANT']}.atlanticagenticlabs.com/api/v1/market/ledger", headers=headers)
r.raise_for_status()
print(r.json())
```

**TypeScript**

```ts
const res = await fetch(
  `https://${process.env.AAL_TENANT}.atlanticagenticlabs.com/api/v1/market/ledger`,
  {
    headers: {
      Authorization: `Bearer ${process.env.AAL_KEY}`,
      "CF-Access-Client-Id": process.env.CF_ACCESS_CLIENT_ID!,
      "CF-Access-Client-Secret": process.env.CF_ACCESS_CLIENT_SECRET!,
    },
  },
);
if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).error}`);
console.log(await res.json());
```

## Market Mine

`GET /api/v1/market/listings`

**Authentication:** A person’s session, or a machine key with your Access service token, as the route’s role allows. A route that approves, decides, pays or changes a limit refuses a machine key (`person_required`).

| Status | Meaning                                                                                     |
| ------ | ------------------------------------------------------------------------------------------- |
| 200    | OK: the JSON document this route reads.                                                     |
| 4XX    | Refused: `{error, message}` with a fixed `error` code, listed under [Errors](/api/errors/). |

**curl**

```bash
curl "https://$AAL_TENANT.atlanticagenticlabs.com/api/v1/market/listings" \
  -H "Authorization: Bearer $AAL_KEY" \
  -H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
  -H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"
```

**Python**

```python
import os

import httpx

headers = {
    "Authorization": f"Bearer {os.environ['AAL_KEY']}",
    "CF-Access-Client-Id": os.environ["CF_ACCESS_CLIENT_ID"],
    "CF-Access-Client-Secret": os.environ["CF_ACCESS_CLIENT_SECRET"],
}
r = httpx.get(f"https://{os.environ['AAL_TENANT']}.atlanticagenticlabs.com/api/v1/market/listings", headers=headers)
r.raise_for_status()
print(r.json())
```

**TypeScript**

```ts
const res = await fetch(
  `https://${process.env.AAL_TENANT}.atlanticagenticlabs.com/api/v1/market/listings`,
  {
    headers: {
      Authorization: `Bearer ${process.env.AAL_KEY}`,
      "CF-Access-Client-Id": process.env.CF_ACCESS_CLIENT_ID!,
      "CF-Access-Client-Secret": process.env.CF_ACCESS_CLIENT_SECRET!,
    },
  },
);
if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).error}`);
console.log(await res.json());
```

## Market Submit

`POST /api/v1/market/listings`

**Authentication:** A person’s session, or a machine key with your Access service token, as the route’s role allows. A route that approves, decides, pays or changes a limit refuses a machine key (`person_required`).

| Status | Meaning                                                                                     |
| ------ | ------------------------------------------------------------------------------------------- |
| 201    | Created: the new resource, as JSON.                                                         |
| 4XX    | Refused: `{error, message}` with a fixed `error` code, listed under [Errors](/api/errors/). |

**curl**

```bash
curl -X POST "https://$AAL_TENANT.atlanticagenticlabs.com/api/v1/market/listings" \
  -H "Authorization: Bearer $AAL_KEY" \
  -H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
  -H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"
```

**Python**

```python
import os

import httpx

headers = {
    "Authorization": f"Bearer {os.environ['AAL_KEY']}",
    "CF-Access-Client-Id": os.environ["CF_ACCESS_CLIENT_ID"],
    "CF-Access-Client-Secret": os.environ["CF_ACCESS_CLIENT_SECRET"],
}
r = httpx.post(f"https://{os.environ['AAL_TENANT']}.atlanticagenticlabs.com/api/v1/market/listings", headers=headers)
r.raise_for_status()
print(r.json())
```

**TypeScript**

```ts
const res = await fetch(
  `https://${process.env.AAL_TENANT}.atlanticagenticlabs.com/api/v1/market/listings`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.AAL_KEY}`,
      "CF-Access-Client-Id": process.env.CF_ACCESS_CLIENT_ID!,
      "CF-Access-Client-Secret": process.env.CF_ACCESS_CLIENT_SECRET!,
    },
  },
);
if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).error}`);
console.log(await res.json());
```

## Market Listing

`GET /api/v1/market/listings/{listing_id}`

**Authentication:** A person’s session, or a machine key with your Access service token, as the route’s role allows. A route that approves, decides, pays or changes a limit refuses a machine key (`person_required`).

| Parameter    | In   | Type   | Required |
| ------------ | ---- | ------ | -------- |
| `listing_id` | path | string | yes      |

| Status | Meaning                                                                                        |
| ------ | ---------------------------------------------------------------------------------------------- |
| 200    | OK: the JSON document this route reads.                                                        |
| 400    | Bad request, `bad_query`: a path or query parameter, or a body field, is missing or not valid. |
| 4XX    | Refused: `{error, message}` with a fixed `error` code, listed under [Errors](/api/errors/).    |

**curl**

```bash
curl "https://$AAL_TENANT.atlanticagenticlabs.com/api/v1/market/listings/LISTING_ID" \
  -H "Authorization: Bearer $AAL_KEY" \
  -H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
  -H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"
```

**Python**

```python
import os

import httpx

headers = {
    "Authorization": f"Bearer {os.environ['AAL_KEY']}",
    "CF-Access-Client-Id": os.environ["CF_ACCESS_CLIENT_ID"],
    "CF-Access-Client-Secret": os.environ["CF_ACCESS_CLIENT_SECRET"],
}
r = httpx.get(f"https://{os.environ['AAL_TENANT']}.atlanticagenticlabs.com/api/v1/market/listings/LISTING_ID", headers=headers)
r.raise_for_status()
print(r.json())
```

**TypeScript**

```ts
const res = await fetch(
  `https://${process.env.AAL_TENANT}.atlanticagenticlabs.com/api/v1/market/listings/LISTING_ID`,
  {
    headers: {
      Authorization: `Bearer ${process.env.AAL_KEY}`,
      "CF-Access-Client-Id": process.env.CF_ACCESS_CLIENT_ID!,
      "CF-Access-Client-Secret": process.env.CF_ACCESS_CLIENT_SECRET!,
    },
  },
);
if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).error}`);
console.log(await res.json());
```

## Market Logo

`GET /api/v1/market/listings/{listing_id}/logo`

**Authentication:** A person’s session, or a machine key with your Access service token, as the route’s role allows. A route that approves, decides, pays or changes a limit refuses a machine key (`person_required`).

| Parameter    | In   | Type   | Required |
| ------------ | ---- | ------ | -------- |
| `listing_id` | path | string | yes      |

| Status | Meaning                                                                                        |
| ------ | ---------------------------------------------------------------------------------------------- |
| 200    | OK: the JSON document this route reads.                                                        |
| 400    | Bad request, `bad_query`: a path or query parameter, or a body field, is missing or not valid. |
| 4XX    | Refused: `{error, message}` with a fixed `error` code, listed under [Errors](/api/errors/).    |

**curl**

```bash
curl "https://$AAL_TENANT.atlanticagenticlabs.com/api/v1/market/listings/LISTING_ID/logo" \
  -H "Authorization: Bearer $AAL_KEY" \
  -H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
  -H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"
```

**Python**

```python
import os

import httpx

headers = {
    "Authorization": f"Bearer {os.environ['AAL_KEY']}",
    "CF-Access-Client-Id": os.environ["CF_ACCESS_CLIENT_ID"],
    "CF-Access-Client-Secret": os.environ["CF_ACCESS_CLIENT_SECRET"],
}
r = httpx.get(f"https://{os.environ['AAL_TENANT']}.atlanticagenticlabs.com/api/v1/market/listings/LISTING_ID/logo", headers=headers)
r.raise_for_status()
print(r.json())
```

**TypeScript**

```ts
const res = await fetch(
  `https://${process.env.AAL_TENANT}.atlanticagenticlabs.com/api/v1/market/listings/LISTING_ID/logo`,
  {
    headers: {
      Authorization: `Bearer ${process.env.AAL_KEY}`,
      "CF-Access-Client-Id": process.env.CF_ACCESS_CLIENT_ID!,
      "CF-Access-Client-Secret": process.env.CF_ACCESS_CLIENT_SECRET!,
    },
  },
);
if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).error}`);
console.log(await res.json());
```

## Market Withdraw

`POST /api/v1/market/listings/{listing_id}/withdraw`

**Authentication:** A person’s session, or a machine key with your Access service token, as the route’s role allows. A route that approves, decides, pays or changes a limit refuses a machine key (`person_required`).

| Parameter    | In   | Type   | Required |
| ------------ | ---- | ------ | -------- |
| `listing_id` | path | string | yes      |

| Status | Meaning                                                                                        |
| ------ | ---------------------------------------------------------------------------------------------- |
| 200    | OK: the request was carried out. The answer is JSON.                                           |
| 400    | Bad request, `bad_query`: a path or query parameter, or a body field, is missing or not valid. |
| 4XX    | Refused: `{error, message}` with a fixed `error` code, listed under [Errors](/api/errors/).    |

**curl**

```bash
curl -X POST "https://$AAL_TENANT.atlanticagenticlabs.com/api/v1/market/listings/LISTING_ID/withdraw" \
  -H "Authorization: Bearer $AAL_KEY" \
  -H "CF-Access-Client-Id: $CF_ACCESS_CLIENT_ID" \
  -H "CF-Access-Client-Secret: $CF_ACCESS_CLIENT_SECRET"
```

**Python**

```python
import os

import httpx

headers = {
    "Authorization": f"Bearer {os.environ['AAL_KEY']}",
    "CF-Access-Client-Id": os.environ["CF_ACCESS_CLIENT_ID"],
    "CF-Access-Client-Secret": os.environ["CF_ACCESS_CLIENT_SECRET"],
}
r = httpx.post(f"https://{os.environ['AAL_TENANT']}.atlanticagenticlabs.com/api/v1/market/listings/LISTING_ID/withdraw", headers=headers)
r.raise_for_status()
print(r.json())
```

**TypeScript**

```ts
const res = await fetch(
  `https://${process.env.AAL_TENANT}.atlanticagenticlabs.com/api/v1/market/listings/LISTING_ID/withdraw`,
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.AAL_KEY}`,
      "CF-Access-Client-Id": process.env.CF_ACCESS_CLIENT_ID!,
      "CF-Access-Client-Secret": process.env.CF_ACCESS_CLIENT_SECRET!,
    },
  },
);
if (!res.ok) throw new Error(`${res.status}: ${(await res.json()).error}`);
console.log(await res.json());
```

Source: https://docs.atlanticagenticlabs.com/api/reference/marketplace/
