# api-socket-client

> - [What is api-socket-client](#what-is-api-socket-client) - [What is api-socket](#what-is-api-socket) - [Installation](#installation) - [Basic Usage](#basic-usage)

Latest version **0.4.2** (published 2022-04-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install api-socket-client
pnpm add api-socket-client
yarn add api-socket-client
bun add api-socket-client
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.2 |
| Published | 2022-04-21 |
| First published | 2022-04-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | noahgav |

## Links

- npm: https://www.npmjs.com/package/api-socket-client
- npm.io page: https://npm.io/package/api-socket-client

## Dependencies (4)

- [zod](https://npm.io/package/zod.md) ^3.14.4
- [api-socket](https://npm.io/package/api-socket.md) ^0.4.0
- [ts-deferred](https://npm.io/package/ts-deferred.md) ^1.0.4
- [socket.io-client](https://npm.io/package/socket.io-client.md) ^4.4.1

## Recent versions

- 0.4.2 (latest) — 2022-04-21
- 0.4.1 — 2022-04-21
- 0.4.0 — 2022-04-21
- 0.3.2 — 2022-04-20
- 0.3.1 — 2022-04-20
- 0.3.0 — 2022-04-20
- 0.2.0 — 2022-04-18
- 0.1.4 — 2022-04-18
- 0.1.3 — 2022-04-18
- 0.1.2 — 2022-04-18
- 0.1.1 — 2022-04-18
- 0.1.0 — 2022-04-18
- 0.0.7 — 2022-04-16
- 0.0.6 — 2022-04-15
- 0.0.5 — 2022-04-15
- … 4 more at https://npm.io/package/api-socket-client/versions

## README

# ⚠️ IMPORTANT: api-socket-client is still a work in progress. It is subject to constant and unnotified changes. Do not use this library until version 1.0.0.

- [What is api-socket-client](#what-is-api-socket-client)
- [What is api-socket](#what-is-api-socket)
- [Installation](#installation)
- [Basic Usage](#basic-usage)

# What is api-socket-client

api-socket-client is is used to communicate with a server created with api-socket.

# What is api-socket

[api-socket](https://www.npmjs.com/package/api-socket) is the server-side version of this library. It allows you to very easily define the api that this client will use to communicate with the server.

# Installation

To install the latest version of api-socket-client:

```sh
npm install api-socket-client
```

To install the latest version of api-socket for your server side code go to [installation](https://www.npmjs.com/package/api-socket#installation).

# Basic Usage

Creating a simple api client

```typescript
import { ApiClient, createClient } from "api-socket-client";
import { ApiServer } from "./server";

// The client is created with the server's ip and an optional
// callback for when the client connects to the server.
const client = createClient<ApiServer>("http://localhost:3000", async () => {
  // We can post the login message to the server like this. This is
  // completely typesafe since we created the client with the ApiServer type.
  const response = await client.post("user", "login", {
    email: "email",
    password: "password",
  });

  console.log(response);
});
```

⚠️ IMPORTANT: If you are going to be sending secret information like emails and passwords be sure that your server and client are using https and not http.

---
_Source: https://npm.io/package/api-socket-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
