Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

API


An Application Programming Interface (API) is provided by a service owner so that others may use the features and functions enabled by the service. APIs describe how a consumer will make requests of the service, and what they will receive in return.

An API defines the means by which the consumer or user of a service invokes service functions and receives data in return from the provider of the API. There are many different kinds of APIs, from the Swift(link takes you to an external page) APIs provided by iOS to provide mobile apps with access to the many facilities provided by the operating system, to REST APIs provided by Twilio that allow developers to send SMS and do tons of other things.

Incoming SMS Diagram.

Twilio, as an API company, provides many different APIs to our customers to help them build applications that communicate. Check out the API reference for a full listing of the APIs Twilio provides for developers to use. Primarily, Twilio provides REST APIs and software APIs for developers to use in order to do fun things like answer phone calls, make video calls, or instantly synchronize data between two clients.


REST APIs

rest-apis page anchor

A REST API allows systems to communicate with one another and invoke functions over the Internet.


In a typical software program, you will use a combination of a programming language's built-in features, its syntax, and APIs provided either by the language's standard library or libraries created and published by third-parties. Twilio provides libraries for many popular programming languages that allow developers on those platforms to more easily consume our services.

Here's an example of using Twilio's helper libraries to send an SMS message using different languages.

Sending an SMS in different languages

sending-an-sms-in-different-languages page anchor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
_14
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_14
const authToken = process.env.TWILIO_AUTH_TOKEN;
_14
const client = require('twilio')(accountSid, authToken);
_14
_14
client.messages
_14
.create({
_14
body: 'This is the ship that made the Kessel Run in fourteen parsecs?',
_14
from: '+15017122661',
_14
to: '+15558675310'
_14
})
_14
.then(message => console.log(message.sid));

Output

_24
{
_24
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24
"api_version": "2010-04-01",
_24
"body": "This is the ship that made the Kessel Run in fourteen parsecs?",
_24
"date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
_24
"date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
_24
"date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
_24
"direction": "outbound-api",
_24
"error_code": null,
_24
"error_message": null,
_24
"from": "+15017122661",
_24
"num_media": "0",
_24
"num_segments": "1",
_24
"price": null,
_24
"price_unit": null,
_24
"messaging_service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24
"sid": "SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24
"status": "queued",
_24
"subresource_uris": {
_24
"media": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Media.json"
_24
},
_24
"to": "+15558675310",
_24
"uri": "/2010-04-01/Accounts/ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Messages/SMXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.json"
_24
}

Don't know an API from an IPA(link takes you to an external page)? Talk to an expert(link takes you to an external page), or get some help from our support team(link takes you to an external page).


Rate this page: