# get()

Canonical URL: https://developers.iagenify.com/sdk/ref/storage/get/
Language: en

`api.storage.get({ id }) → Promise<ConnectedStorage | null>`

One storage, ready to use. With no argument, the account's default.

Status: GET /api/storage/:id · free · null, never a throw

## Parameters {#parameters}

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `id` | string |  | Which storage. Leave it out for the account's default. |

```javascript
const target = await api.storage.get();            // the default
const one = await api.storage.get({ id });         // a particular one
```

## It answers null rather than throwing {#null}

An unknown id, a malformed one, or one belonging to another account all give `null`. So the check is a value test, not a try/catch — and `null` never means « it is someone else's ».

```javascript
const storage = await api.storage.get({ id });

if (!storage) {
  throw new Error("that storage is not on this account");
}
```

## This, or getStorage() {#versus}

|  | api.storage.get() | api.getStorage() |
| --- | --- | --- |
| Gives | A ConnectedStorage, with methods | Four plain fields |
| Use it to | read, write, list files | show which one is the default |
| Takes an id | yes | no — always the default |

## What you can do with what comes back {#doing}

```javascript
const storage = await api.storage.get({ id });

// Any storage: read and write through run()
await storage.run({ action: "collections" });

// A computer only: its own files, on that machine
const pc = await api.storage.get({ id: computerId });
await pc.files.list();
```

> **files and terminals exist only on a computer**
>
> Reaching for them on anything else throws storage_not_local, and on a phone storage_is_phone — its files are in its browser. Test type before you reach.

```javascript
if (storage.type === "filesystem") {
  await storage.files.list();
} else {
  await storage.run({ action: "objects" });
}
```

## What it carries {#fields}

| Field | Is |
| --- | --- |
| id · label | Identity, and the display name. |
| type | filesystem · phone · browser · database · object |
| provider · managedBy | What is behind it, and who operates it. |
| service | nosql · sql · object on an IaGenify Cloud storage; null otherwise. |
| isDefault | Whether a save with no target goes here. |
| machineId · hostname · deviceId | On a device: which one. |

Nothing here carries a credential: what you supplied at connection is used by the server and not handed back.

- [ConnectedStorage](/sdk/ref/connected-storage): Everything on the object this returns.
- [api.getStorage()](/sdk/ref/iagenify/get-storage): The default, as four plain fields.

```python
target = api.storage.get()                # the default
one = api.storage.get(id=storage_id)      # a particular one
```

```python
storage = api.storage.get(id=storage_id)

if storage is None:
    raise LookupError("that storage is not on this account")
```

```python
storage = api.storage.get(id=storage_id)

# Any storage: read and write through run()
storage.run(action="collections")

# A computer only: its own files, on that machine
pc = api.storage.get(id=computer_id)
pc.files.list()
```

```python
if storage.type == "filesystem":
    storage.files.list()
else:
    storage.run(action="objects")
```
