JSPM

@mobiletextalerts/typescript-sdk

5.121.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q57949F
  • License ISC

TypeScript SDK for Mobile Text Alerts API

Package Exports

  • @mobiletextalerts/typescript-sdk
  • @mobiletextalerts/typescript-sdk/client

Readme

Mobile Text Alerts TypeScript SDK

A TypeScript SDK for interacting with the Mobile Text Alerts API, automatically generated from OpenAPI specifications using @hey-api/openapi-ts.

Installation

npm install @mobiletextalerts/typescript-sdk

Quick Start

import { createClient } from '@mobiletextalerts/typescript-sdk';

// Create a client instance
const client = createClient({
  baseUrl: 'https://api.example.com', // Replace with actual API base URL
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY'
  }
});

// Example: List subscribers
import { subscribersListSubscribers } from '@mobiletextalerts/typescript-sdk';

const subscribers = await subscribersListSubscribers({
  client,
  // Add any required parameters
});

Authentication

The SDK supports API key authentication. Set your API key in the client configuration:

const client = createClient({
  baseUrl: 'https://api.example.com',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY'
  }
});

Available Endpoints

This SDK provides TypeScript functions for all Mobile Text Alerts API endpoints, including:

Core Features

  • Account Variables - Manage account-level variables
  • Authentication - API key verification
  • Subscribers - Manage subscriber lists and data
  • Messages - Send and manage text messages
  • Templates - Create and manage message templates
  • Groups - Organize subscribers into groups
  • Campaigns - Create and manage messaging campaigns

Advanced Features

  • Automated Replies - Set up automated response systems
  • Chatbots - Manage chatbot interactions
  • Workflows - Create automated messaging workflows
  • Smart Replies - Intelligent response suggestions
  • Drip Campaigns - Scheduled message sequences
  • Link Management - Track and manage links in messages
  • Loyalty Programs - Manage customer loyalty rewards
  • Surveys - Create and manage mobile surveys

Analytics & Reporting

  • Deliveries - Track message delivery status
  • Analytics - Campaign and message performance metrics
  • Threads - Conversation thread management
  • Unsubscribes - Handle opt-out requests

Usage Examples

Send a Message

import { sendMessageFromApi } from '@mobiletextalerts/typescript-sdk';

const result = await sendMessageFromApi({
  client,
  body: {
    message: "Hello from your app!",
    recipients: ["1234567890"],
    // Additional message options
  }
});

List Subscribers

import { subscribersListSubscribers } from '@mobiletextalerts/typescript-sdk';

const subscribers = await subscribersListSubscribers({
  client,
  query: {
    limit: 100,
    offset: 0
  }
});

Create a Template

import { templatesCreateTemplate } from '@mobiletextalerts/typescript-sdk';

const template = await templatesCreateTemplate({
  client,
  body: {
    name: "Welcome Message",
    content: "Welcome to our service, {firstName}!"
  }
});

Rate Limiting

Many endpoints have rate limiting restrictions. Check the function documentation for specific limits. For example:

  • Account Variables endpoints: 15 requests per 15 seconds per account
  • Other endpoints may have different limits based on IP address or account

Error Handling

The SDK provides comprehensive error types for each endpoint:

try {
  const result = await subscribersListSubscribers({ client });
  // Handle success
} catch (error) {
  // Error types are automatically inferred based on the endpoint
  console.error('API Error:', error);
}

TypeScript Support

This SDK is fully typed with TypeScript, providing:

  • Request/Response Types - All API data structures are typed
  • Error Types - Specific error types for each endpoint
  • Options Types - Configuration options with proper typing
  • Auto-completion - Full IDE support with intelligent suggestions

Client Configuration

import { createClient, type ClientOptions } from '@mobiletextalerts/typescript-sdk';

const clientOptions: ClientOptions = {
  baseUrl: 'https://api.example.com',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  // Additional client configuration options
};

const client = createClient(clientOptions);

Development

This SDK is auto-generated from OpenAPI specifications. To regenerate:

  1. Update the OpenAPI specification
  2. Run the code generator
  3. The generated files will be updated in the src/ directory

Generated Files Structure

src/
├── index.ts              # Main exports
├── sdk.gen.ts           # SDK functions
├── types.gen.ts         # Type definitions
├── client.gen.ts        # HTTP client
└── client/
    ├── index.ts         # Client exports
    ├── client.gen.ts    # Core client
    ├── types.gen.ts     # Client types
    └── utils.gen.ts     # Utility functions
└── core/
    ├── auth.gen.ts      # Authentication
    ├── bodySerializer.gen.ts # Request serialization
    └── [other core files]   # Additional utilities

License

ISC

Support

For API documentation and support, visit the Mobile Text Alerts documentation or contact their support team.