🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

@logto/api

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@logto/api

Logto API types and clients.

Source
npmnpm
Version
1.37.0
Version published
Weekly downloads
5.1K
34.4%
Maintainers
2
Weekly downloads
 
Created
Source

@logto/api

A TypeScript SDK for interacting with Logto's Management API using client credentials authentication.

Installation

npm install @logto/api

Quick start

Prerequisites

Before using this SDK, you need to:

  • Create a machine-to-machine application in your Logto Console
  • Grant the application access to the Management API
  • Note down the client ID and client secret

For detailed setup instructions, visit: https://a.logto.io/m2m-mapi

Basic usage

Logto Cloud

import { createManagementApi } from '@logto/api/management';

// For Logto Cloud
const { apiClient } = createManagementApi('your-tenant-id', {
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
});

// Make API calls
const response = await apiClient.GET('/api/users');
console.log(response.data);

Self-hosted / OSS

import { createManagementApi } from '@logto/api/management';

const { apiClient } = createManagementApi('default', {
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
  baseUrl: 'https://your-logto-instance.com',
  apiIndicator: 'https://your-logto-instance.com/api',
});

Custom authentication

For advanced use cases where you need full control over the authentication logic, use createApiClient:

import { createApiClient } from '@logto/api/management';

const client = createApiClient({
  baseUrl: 'https://your-logto-instance.com',
  getToken: async () => {
    // Your custom token retrieval logic
    return getYourToken();
  },
});

// Type-safe API calls
const response = await client.GET('/api/applications/{id}', {
  params: { path: { id: 'your-app-id' } },
});

API documentation

For detailed API documentation, refer to the Logto Management API documentation.

Development

To avoid unnecessary build time in CI, full type generation only happens before publishing. The build script will generate mock types if no types are found.

To explicitly generate types, run:

pnpm generate-types

This will start a local Docker Compose environment, generate types by fetching the OpenAPI endpoints, and then shut down the environment.

FAQs

Package last updated on 28 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts