Sakari
DevelopmentSakari Public API
Sakari is a cloud-based messaging platform that provides businesses with a powerful and easy-to-use tool for sending SMS and MMS messages. The Sakari Public API allows developers to integrate messaging capabilities into their own applications and platforms.
API Documentation
The Sakari Public API documentation can be found at https://developer.sakari.io/docs. The documentation provides detailed information on each of the available endpoints, parameters, and response formats.
Example API Code in JavaScript
Here are some sample API calls using the Sakari Public API in JavaScript.
Authentication
Before making any API requests, you'll need to authenticate your application by passing your API key in the header of your request. Here's an example of how to authenticate your application using the axios
library in JavaScript:
const axios = require('axios');
const apiKey = 'YOUR_API_KEY_HERE';
const headers = {
'Content-Type': 'application/json',
'Authorization': `Bearer ${apiKey}`
};
const baseUrl = 'https://api.sakari.io/v1/';
axios.defaults.baseURL = baseUrl;
axios.defaults.headers.common = headers;
Sending an SMS Message
To send an SMS message, you'll need to make a POST request to the /sms/send
endpoint with the recipient's phone number and the message text. Here's an example of how to send an SMS message using the axios
library in JavaScript:
const data = {
to: '+1234567890',
body: 'Hello, world!'
};
const response = await axios.post('sms/send', data);
console.log(response.data);
Sending an MMS Message
To send an MMS message, you'll need to make a POST request to the /mms/send
endpoint with the recipient's phone number, the message text, and the URL of the media to be included in the message. Here's an example of how to send an MMS message using the axios
library in JavaScript:
const data = {
to: '+1234567890',
body: 'Check out this cool image!',
media_url: 'https://example.com/image.jpg'
};
const response = await axios.post('mms/send', data);
console.log(response.data);
Retrieving Account Information
To retrieve information about your Sakari account, you'll need to make a GET request to the /account
endpoint. Here's an example of how to retrieve account information using the axios
library in JavaScript:
const response = await axios.get('account');
console.log(response.data);
Conclusion
The Sakari Public API provides developers with a powerful tool for integrating messaging capabilities into their own applications and platforms. With the authentication and example code provided in this blog, you'll be well on your way to using the Sakari Public API in your own projects.