# IPFS RPC API

Filebase now supports a limited set of IPFS RPC-compatible API endpoints. These endpoints allow developers and tools that integrate with [Kubo](https://github.com/ipfs/kubo) to communicate directly with Filebase using familiar IPFS HTTP API routes.

This API is **complementary to our S3-compatible API** and simplifies integration with the IPFS CLI, IPFS-compatible libraries, and other standard HTTP clients.

## Base URL

```
https://rpc.filebase.io
```

All API requests require a **Bearer API key** via the `Authorization` header.

***

## 🔐 Authentication

API keys can be found at the bottom of the [Access Keys](https://console.filebase.com/keys) page. Keys are bucket-specific. All requests must include an API key in the `Authorization` header:

```http
Authorization: Bearer <api-key>
```

***

## 🧪 IPFS CLI Integration

You can use the IPFS CLI directly with Filebase by passing the `--api` flag:

```bash
ipfs --api="/dns4/rpc.filebase.io/tcp/443/https" \
  --api-auth="<api-key>" add file1
```

***

## 📌 `/api/v0/pin/ls`

List all pinned objects.

**Method**: `POST`

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/pin/ls"
```

***

## 🔢 `/api/v0/version`

Get the version of the IPFS daemon.

**Method**: `POST`

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/version"
```

***

## 📂 `/api/v0/cat`

Fetch and return the contents of a file by CID.

**Method**: `POST`

**Query Parameter**:

* `arg` (string) – CID of the file.

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/cat?arg=Qm..."
```

***

## 📦 `/api/v0/block/get`

Retrieve a raw block by CID.

**Method**: `POST`

**Query Parameter**:

* `arg` (string) – CID of the block.

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/block/get?arg=Qm..."
```

***

## ➕ `/api/v0/add`

Add a file to IPFS.

**Method**: `POST`**Form Field**:

* `file` (multipart/form-data) – The file to upload.

**Supported Query Parameters**:

| Parameter             | Type    | Description                                              |
| --------------------- | ------- | -------------------------------------------------------- |
| `wrap-with-directory` | Boolean | Wrap the uploaded file in a directory. Default: `false`. |
| `cid-version`         | Integer | CID version to use (0 or 1). Default: `0`.               |

**Basic Example**:

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/add" \
  -F "file=@file1"
```

**Example with `wrap-with-directory` and `cid-version`**:

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/add?wrap-with-directory=true&cid-version=1" \
  -F "file=@file1" -F "file=@file2"
```

> 💡 When using `wrap-with-directory=true`, the returned CID will represent a directory containing the file rather than the file directly.

***

## 📌 `/api/v0/pin/add`

Pin a CID to ensure it remains stored.

**Method**: `POST`

**Query Parameter**:

* `arg` (string) – CID to pin.

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/pin/add?arg=Qm..."
```

***

## 🧹 `/api/v0/pin/rm`

Unpin a CID to remove it from persistent storage.

**Method**: `POST`

**Query Parameter**:

* `arg` (string) – CID to unpin.

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/pin/rm?arg=Qm..."
```

***

## 🔑 `/api/v0/key/gen`

Create a new keypair.

**Method**: `POST`

**Query Parameter**:

* `arg` (string) – Name of the key to create.

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/key/gen?arg=my-key"
```

***

## 🗝️ `/api/v0/key/import`

Import a private key into the keychain.

**Method**: `POST`

**Query Parameter**:

* `arg` (string) – Name to associate with the key.

**Form Field**:

* `file` (multipart/form-data) – Private key file to import.

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/key/import?arg=my-key" \
  -F "file=@my-key.pem"
```

***

## 🗂️ `/api/v0/key/list`

List all keys in the keychain.

**Method**: `POST`

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/key/list"
```

***

## ✏️ `/api/v0/key/rename`

Rename an existing key.

**Method**: `POST`

**Query Parameters**:

* `arg` (string) – Current key name.
* `arg` (string) – New key name.

**Optional Query Parameters**:

* `force` (boolean) – Overwrite an existing key name.

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/key/rename?arg=old-key&arg=new-key"
```

***

## 🗑️ `/api/v0/key/rm`

Remove a key from the keychain.

**Method**: `POST`

**Query Parameter**:

* `arg` (string) – Name of the key to remove.

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/key/rm?arg=my-key"
```

***

## 📣 `/api/v0/name/publish`

Publish a CID to IPNS.

**Method**: `POST`

**Query Parameter**:

* `arg` (string) – IPFS path or CID to publish.

**Optional Query Parameters**:

* `key` (string) – Key name to publish with.
* `validity` (string) – Record validity duration (e.g. `24h`).
* `ttl` (string) – Cache TTL for resolvers (e.g. `5m`).

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/name/publish?arg=/ipfs/Qm...&key=my-key"
```

***

## 🔍 `/api/v0/name/resolve`

Resolve an IPNS name to an IPFS path.

**Method**: `POST`

**Query Parameter**:

* `arg` (string) – IPNS name or `/ipns/` path.

**Optional Query Parameters**:

* `recursive` (boolean) – Resolve until the result is not an IPNS name.
* `nocache` (boolean) - Do not use cached entries.

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/name/resolve?arg=/ipns/k51qzi5uqu5d..."
```

***

## 📥 `/api/v0/dag/import`

Import a CAR file containing DAG data.

**Method**: `POST`

**Form Field**:

* `file` (multipart/form-data) – The CAR file to import.

**Supported Query Parameters**:

| Parameter   | Type    | Description                                         |
| ----------- | ------- | --------------------------------------------------- |
| `pin-roots` | Boolean | Pin the roots of the imported DAG. Default: `true`. |

**Example**:

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/dag/import" \
  -F "file=@archive.car"
```

**Example with `pin-roots=false`**:

```bash
curl -X POST -H "Authorization: Bearer <api-key>" \
  "https://rpc.filebase.io/api/v0/dag/import?pin-roots=false" \
  -F "file=@archive.car"
```

> 💡 CAR (Content Addressable aRchive) files are a serialization format for IPFS DAGs. Use this endpoint to import pre-built CAR files directly into Filebase.
