gear-codeSDKs

Mobile Text Alerts provides multiple SDKs to help you integrate with Mobile Text Alert's API across different platforms and languages.

SDK Overview

What is an SDK?

An SDK (Software Development Kit) is a collection of tools, libraries, documentation, and code samples that developers can use to build applications for a specific platform, framework, or service. It provides a pre-packaged toolbox so developers don't need to worry about low-level implementation details and provides a higher-level interface for interacting with a system.

Mobile Text Alerts SDKs

The Mobile Text Alert SDKs are code libraries that wrap the Mobile Text Alert's REST API to simplify operations like authentication, sending messages, listing subscribers and all functionality of the API. Instead of manually constructing HTTP requests with proper headers and authentication, you can instead call predefined methods for all your operations. The SDK makes things easier by automatically handling things such as request formatting, error handling and retry logic.

Using the Mobile Text Alerts SDKs

Here are the general steps for getting started using a Mobile Text Alerts SDK library in any chosen language (with examples in TypeScript) used to call the Mobile Text Alerts API:

1

Generate an API Key

An API Key is used to make authenticated requests to the API, see Get an API Key for steps to generate your unique key.

circle-info

Generating an API Key requires you to have a free account. Don't have an account yet? Click here to create your free account.arrow-up-right

2

Choose your language and install an SDK

See below to learn more and install the currently available official supported SDK libraries:

More language libraries are actively being developed.

3

Initialize the Client

Once you install the necessary modules in your code you will need to configure the SDK with your credentials. This usually involves passing your API key to a client constructor. 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:

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

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

const client = createClient(clientOptions);
4

Call SDK functions

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

TypeScript Code Examples

Some of the most common actions are: Send a Message and Add a Subscriber.

Send a message:

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

const result = await sendMessageFromApi({
  client,
  body: {
    message: "Hello from your app!",
    groups: [1234567890],
    subscribers: ["1112223333","1222333444"],
    subscriberIds: [187572],
    // Additional message options
  }
});

Add a subscriber:

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

const result = await subscribersCreateSubscriber({
  client,
  body: {
     firstName: "FirstName", 
     lastName: "LastName", 
     number: 8002223333, 
     email: "[email protected]", 
     // Additional optional subscriber fields
  }
});
5

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.

Learn More

Visit the API Reference to learn more about specific API endpoints that you can call with the SDK.

Last updated

Was this helpful?