open-index/open-npm huggingface dataset:
npm package: @limitry/cli
Description: Limitry CLI - Command-line interface for Limitry
Author: Limitry Team
Latest version: 0.1.4

# @limitry/cli

Official CLI for [Limitry](https://limitry.com) — manage rate limits, quotas, and usage from the command line.

## Installation

```bash
npm install -g @limitry/cli
```

Or with other package managers:

```bash
pnpm add -g @limitry/cli
yarn global add @limitry/cli
```

## Quick Start

```bash
# Login to your Limitry account
limitry login

# Select your default project interactively
limitry project select

# Or list your projects
limitry project list
```

## Commands

| Command | Description |
|---------|-------------|
| `limitry login` | Authenticate with Limitry |
| `limitry logout` | Clear authentication |
| `limitry whoami` | Show current user |
| `limitry project list` | List all projects |
| `limitry project select` | Interactively select a default project |
| `limitry project current` | Get current project details |
| `limitry project clear` | Clear the default project |
| `limitry config set <key> <value>` | Set configuration value |
| `limitry config get <key>` | Get configuration value |
| `limitry config list` | List all configuration |

## Configuration

### Default Project

Set a default project to avoid passing `-p` on every command:

```bash
limitry config set project acme/my-app
```

### Environment Variables

| Variable | Description |
|----------|-------------|
| `LIMITRY_PROJECT` | Default project (overrides config file) |
| `LIMITRY_API_URL` | API URL (for self-hosted instances) |

Priority: CLI flag (`-p`) → Environment variable → Config file

## Output Formats

Most commands support `-o, --output` for different output formats:

```bash
# Human-readable table (default)
limitry project list

# JSON (for scripting)
limitry project list -o json
```

## Documentation

Full documentation: [limitry.com/docs](https://limitry.com/docs)

## License

Apache-2.0
npm package: @limitry/client
Description: Limitry client-side SDK for browser, React Native, and Expo
Author: Limitry Team
Latest version: 0.0.3

# @limitry/client

Client-side SDK for Limitry - works in browser, React Native, and Expo.

## Installation

```bash
npm install @limitry/client
```

## Usage

```typescript
import { LimitryClient } from '@limitry/client';

// Create a client with a token from your backend
const client = new LimitryClient({
  clientToken: 'your-client-token',
});

// Check limits before an operation
const result = await client.checkLimits();

if (result.allowed) {
  // Proceed with the operation
  await client.recordEvent({
    eventType: 'api.call',
    values: { tokens: 150 }
  });
} else {
  // Handle limit exceeded
  console.log('Limit exceeded');
}

// Get usage summary
const summary = await client.getEventsSummary('day');
console.log(`Total events: ${summary.usage.totalEvents}`);
```

## Getting a Client Token

Client tokens are created by your backend using the server-side SDK:

```typescript
// On your backend
import { Limitry } from '@limitry/sdk';

const limitry = new Limitry({ apiKey: process.env.LIMITRY_API_KEY });

const { token } = await limitry.clientTokens.create({
  context: { customerId: 'cust_123' },
  ttlSeconds: 3600, // 1 hour
});

// Return this token to your frontend
```

## API

### `LimitryClient`

#### Constructor Options

- `clientToken` (required): The client token from your backend
- `baseUrl` (optional): Custom API URL (defaults to `https://api.limitry.com`)

#### Methods

- `checkLimits(options?)`: Check limits. Options can include `dimensions` for filtering.
- `recordEvent(options)`: Record an event with `eventType`, `values`, `dimensions`, `properties`.
- `getEventsSummary(period?)`: Get events summary. Period can be `'hour'`, `'day'`, `'week'`, or `'month'`.
- `getContext()`: Get the context associated with the client token

## License

Apache-2.0
npm package: @limitry/react
Description: Limitry React SDK - hooks and components for React applications
Author: Limitry Team
Latest version: 0.0.3

# @limitry/react

React SDK for Limitry - hooks and components for React applications.

## Installation

```bash
npm install @limitry/react
```

Note: `@limitry/client` is included as a dependency.

## Quick Start

```tsx
import { LimitryProvider, useLimits, useEvents } from '@limitry/react';

function App() {
  return (
    <LimitryProvider clientToken="your-client-token">
      <MyComponent />
    </LimitryProvider>
  );
}

function MyComponent() {
  const { checkLimits, data, isLoading, error } = useLimits();
  const { recordEvent } = useEvents();

  const handleAction = async () => {
    const result = await checkLimits();
    if (result.allowed) {
      // Proceed with the action
      console.log('Action allowed!');
      
      // Record the event
      await recordEvent({
        eventType: 'feature.used',
        values: { count: 1 }
      });
    } else {
      console.log('Limit exceeded');
    }
  };

  return (
    <div>
      {isLoading && <p>Checking...</p>}
      {error && <p>Error: {error.message}</p>}
      {data && <p>Allowed: {data.allowed ? 'Yes' : 'No'}</p>}
      <button onClick={handleAction}>Perform Action</button>
    </div>
  );
}
```

## Events Summary

```tsx
import { useEvents } from '@limitry/react';
import { useEffect } from 'react';

function UsageDashboard() {
  const { getEventsSummary, summaryData, isLoading } = useEvents();

  useEffect(() => {
    getEventsSummary('day');
  }, [getEventsSummary]);

  if (isLoading) return <p>Loading...</p>;
  if (!summaryData) return null;

  return (
    <div>
      <h2>Today's Usage</h2>
      <p>Total Events: {summaryData.usage.totalEvents}</p>
      <p>Values: {JSON.stringify(summaryData.usage.values)}</p>
    </div>
  );
}
```

## API

### Provider

#### `LimitryProvider`

Wrap your app with this provider to use Limitry hooks.

```tsx
<LimitryProvider clientToken="..." baseUrl="...">
  {children}
</LimitryProvider>
```

### Hooks

#### `useLimitryClient()`

Returns the raw `LimitryClient` instance for advanced usage.

#### `useLimits()`

Hook for checking limits.

Returns:
- `checkLimits(options?)` - Check limits
- `data` - Latest check result
- `error` - Error if request failed
- `isLoading` - Loading state
- `reset()` - Reset state

#### `useEvents()`

Hook for event operations.

Returns:
- `recordEvent(options)` - Record an event
- `getEventsSummary(period?)` - Get events summary ('hour', 'day', 'week', 'month')
- `recordData` - Latest record result
- `summaryData` - Latest summary data
- `error` - Error if request failed
- `isLoading` - Loading state
- `reset()` - Reset state

## License

Apache-2.0