TypeScript SDK

Set up your development environment to call the Mobile Text API with the TypeScript SDK.

Overview

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

  • Request/Response Types - All API data structures are typed

  • Error Handling - Specific error types for each endpoint

  • Options Types - Configuration options with proper typing

  • Auto-completion - Full IDE support with intelligent suggestions

Using the TypeScript SDK

Install Node

The Mobile Text Alerts TypeScript SDK requires a working node installation of Node.js and npm. You can check which version of Node you already have installed by running the following command:

node -v

Learn how to install or update Node to a newer version.

Install @mobiletextalerts/typescript-sdk

The Mobile Text Alerts TypeScript SDK is open-source and hosted on GitHub:

The latest version of the TypeScript SDK can be installed with npm:

Client Configuration

The client acts as a single point of configuration for all your API interactions. This is where you set your API key for authentication, the base URL, and other options. This is done during initialization, so it does not need to be passed in every individual API call.

Example client configuration

Usage Examples

After creating a client, you can use TypeScript functions to call any of the Mobile Text Alerts API endpoints.

Send a Message

The following example calls the POST /send endpoint:

List Subscribers

The following example calls the GET /subscribers endpoint:

Create a Template

The following example calls the POST /templates endpoint:

Error Handling

If the API returns an HTTP error code (400, 401, 404, 500, etc.), the SDK intercepts the response and transforms it into a meaningful exception class for each endpoint.

Rate Limits

Most Mobile Text Alerts API endpoints have a general rate limit of 30 requests per minute per IP address. However, some individual endpoints may override the general rate limit, see Rate Limits to learn more.

Last updated

Was this helpful?