Isomorphic TypeScript client for the Deps API.
The @depsapi/deps-js package is a lightweight and powerful client for interacting with the Deps API in any JavaScript environment.
- Isomorphic: Works seamlessly in Node.js, Deno, and modern browsers.
- Typed: Fully typed with TypeScript for a better developer experience.
- Lightweight: Built with
ofetchfor a small bundle size. - Promise-based: Modern asynchronous API using Promises.
- Modular: API methods are grouped into logical modules.
| Node.js |
Install with import { DepsClient } from "@depsapi/deps-js"; |
|---|---|
| Browsers |
Load @depsapi/deps-js directly from esm.sh
<script type="module">
import { DepsClient } from "https://esm.sh/@depsapi/deps-js";
</script> |
| Deno |
Load @depsapi/deps-js directly from esm.sh
import { DepsClient } from "https://esm.sh/@depsapi/deps-js?dts"; |
The DepsClient is the main entry point for interacting with the Deps API.
Example: Get the API status.
const client = new DepsClient({ apiKey: 'YOUR_API_KEY' });
const status = await client.status.get();
console.log(status);| name | type | description |
|---|---|---|
apiKey
|
string
|
Your Deps API key. This is a required parameter. |
baseUrl
|
string
|
The base URL of the Deps API. Defaults to https://api.depscian.tech.
|
The client provides access to the API through a set of modules:
client.adminsclient.familiesclient.fractionsclient.ghettoclient.leadershipclient.mapclient.onlineclient.playerclient.sobesclient.status
Example: Get the online players on a server.
const online = await client.online.get({ serverId: '1' });
console.log(online);API errors are thrown as instances of DepsApiError or ValidationError.
import { DepsClient, DepsApiError, ValidationError } from '@depsapi/deps-js';
const client = new DepsClient({ apiKey: 'YOUR_API_KEY' });
try {
const player = await client.player.find({ serverId: '1', nickname: 'NonExistentPlayer' });
} catch (error) {
if (error instanceof ValidationError) {
console.error('Validation Error:', error.data);
} else if (error instanceof DepsApiError) {
console.error('API Error:', error.message);
} else {
console.error('An unknown error occurred:', error);
}
}