# Client.js

`Client.js` is a JavaScript library implementing the REST API client for [Open Cloud Server](https://cloud.opendesign.com/docs/index.html#/opencloud_server).

Core capabilities:

- Register on the server as a new user.
- Create new and manage existing user accounts.
- Upload and download files from the server.
- Manage existing files, upload new version of files.
- Convert files from one format to another.
- Run validation, clash detection, and custom jobs on the server.
- Create and manage assemblies.
- Create projects, manage project models and members.
- Change server settings.

This library is a part of [CDE SDK](https://www.opendesign.com/products/cde) by [Open Design Alliance](https://opendesign.com).

## Installation

### CDN or static hosting

For CDN, you can use [unpkg](https://unpkg.com/) or [jsDelivr](https://www.jsdelivr.com/) (replace `25.3` with a version you need):

```html
<script src="https://unpkg.com/@inweb/client@25.3/dist/client.js"></script>
```

The global namespace for `Client.js` is `ODA.Api`.

```html
<script>
  const client = new ODA.Api.Client({ serverUrl: "https://cloud.opendesign.com/api" });
</script>
```

### Install via [npm](https://npmjs.org)

Open a terminal in your project folder and run:

```sh
npm install @inweb/client
```

The `Client.js` package will be downloaded and installed. Then you're ready to import it in your code:

```javascript
import { Client } from "@inweb/client";
const client = new Client({ serverUrl: "https://cloud.opendesign.com/api" });
```

## Example

Login to the `Open Cloud Server` and get the file list from the server:

```html
<html>
  <body>
    <script src="https://unpkg.com/@inweb/client@25.3/dist/client.js"></script>
    <script>
      const client = new ODA.Api.Client({ serverUrl: "https://cloud.opendesign.com/api" });
      client
        .signInWithEmail("email", "password")
        .then(() => client.getFiles())
        .then((files) => files.result.map((file) => file.name))
        .then((names) => console.log(names));
    </script>
  </body>
</html>
```

To learn more, see [First application guide](https://cloud.opendesign.com/docs/index.html#/guide).

## Copyright and license

Code and documentation copyright 2002-2025 the [Open Design Alliance](https://opendesign.com). Code is distributed under a proprietary license, see [LICENSE](./LICENSE) for more information.
