Update: Twilio’s official APIs are now available on RapidAPI. Be sure to check them out.
TL;DR: Twilio’s API lets you make calls, send texts or send multi-media messages en masse. By connecting to the API, you can add appointment reminders, two-factor verification or ETA alerts to your app.
We recently added the Twilio API package to our website and we’ve got to admit, it’s pretty cool. This is the same API allows Uber to text users an ETA, AirBnb to confirm reservations over text, and Box to secure accounts with two-factor verification.
Today, we’ll walk through how to connect to the Twilio SMS API in order to build these functionalities. Check out the docs directly if you’d like to jump straight to the code.
Connecting to the Twilio API isn’t too painful. Here’s what you have to do.
First things first, you’ll have to get Twilio credentials to access its API.
1a. Create a Twilio Account
Head over to Twilio.com/console to create an account. This step will involve either paying for a Twilio account or signing up for a free trial. We chose to sign up for a free trial. Have your phone handy for the two-step verification process!
1b. Go to “Account Details” to Get API Details
Once you’re logged into the actual Twilio console, go to “Account Details” and retrieve your custom accountSID
and accountToken
.
1c. Get a Twilio Phone Number
Twilio requires you to get a Twilio phone number to make calls or sends messages from. You can get one number for free.
And there you have it! You can use this number to make a call or send an MMS/SMS through the API.
Note: All phone numbers in Twilio’s API require E.164 formatting. All that means is “+” then country code, then number, with no dashes or spacing. For example, +18675309.
1d. Get a Twilio messagingSID
If you want to call the sendSms
or sendMms
endpoints, you’ll need a messagingSID
. Here’s how to get one:
messagingSID
.
Next up, we’ll actually connect to the Twilio API to make calls and start coding.
2a. Find Twilio API at RapidAPI.com
Go to RapidAPI.com and search for “Twilio.” The result should take you to the Twilio Package page. Once you’re on the Package page, click on the “Functions” menu item to see the full list of endpoints or click on the function that you would like your app to perform (ex. sendSms).
2b. Use Your Credentials to Make Connection
Once you’re on the Package page, you can use your Twilio API credentials to connect to the Twilio API. Fill in accountSid
and accountToken
and whatever necessary parameters you need from previous steps (ex. a from phone number) to get started.
2c. Login to RapidAPI to Access Code Snippets
In order to see the code on the right side window, you’ll have to create a RapidAPI account. Login with your GitHub, Facebook or Google accounts to make the process as quick as possible.
2d. Customize Fields and Language
Yay, you’re logged in! Now, just fill in the fields with the information that your app requires and the code will display in real-time on the window to the right. Pick NodeJs, PHP, Python, Java (Android), Objective-C (iOS), or cURL to select the code that best fits your project’s needs.
We’d love to hear what kind of projects that you build with the Twilio API! Leave us a note in the comments about your app. If you have any questions, you can ping us directly on the RapidAPI website chat function.
We're thrilled to announce the latest update to the Rapid Enterprise API Hub (version 2024.3)!…
Are you curious about what your API consumers are searching for? Is your Hub effectively…
The RapidAPI team is excited to announce the February 2024 update (version 2024.2) for the…
This January's release brings exciting features and improvements designed to empower you and your developers.…
Rapid API is committed to providing its users with the best possible experience, and the…
In today's fast-paced digital world, APIs (Application Programming Interfaces) have become the backbone of modern…