@lovice/api
v0.3.4
Published
Lovice API definitions
Readme
@lovice/api
TypeScript/JavaScript client library for the Device Locator API. This package provides type-safe access to the Device Locator service APIs.
Installation
npm install @lovice/api
# or
yarn add @lovice/api
# or
pnpm add @lovice/api
# or
bun install @lovice/apiUsage
Basic Setup Example
import { createClient } from "@connectrpc/connect";
import { createGrpcWebTransport } from "@connectrpc/connect-web";
import { PositionsService } from '@lovice/api';
// Create a transport
const transport = createGrpcWebTransport({
baseUrl: 'https://api.device-locator.com',
useBinaryFormat: true,
});
// Create the client
const client = createClient(PositionsService, transport);
// Example: Using the positions service
const position = await client.getPosition({ deviceId: "device-123" });API Documentation
Types
The package includes the following type definitions:
Position- Represents a device's location with latitude, longitude, altitude, speed, and headingDevicePosition- Combines a device ID with its positionDevice- Device information including ID and nameUser- User information including ID, name, and associated devicesGroup- Group information including ID, name, description, and associated users
Services
This is not a full list of services. These are just some examples.
PositionsService- Service for managing device positionssendPositions(positions: DevicePosition[]): Promise<SendPositionsResponse>- Send multiple device position updatesgetGroup(groupId: string): Promise<GetGroupResponse>- Get a group by ID, including user data and their devicesgetGroupPositions(groupId: string): Promise<GetGroupPositionsResponse>- Get positions for all devices in a group
Development
This package is automatically generated from Protocol Buffer definitions. Do not modify the generated code directly. Instead, make changes to the proto files in the parent repository.
Building
The package is built using the following tools:
buf- Protocol Buffer compilerprotoc-gen-es- TypeScript code generatorprotoc-gen-connect-es- Connect-ES code generator
To rebuild the package:
make generateLicense
This package is part of the Device Locator project and is subject to the same license terms as the main project.
