REST API

Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

A REST API allows software programs to expose functionality and data to other programs over the Internet in a consistent format. APIs are considered RESTful if the means of accessing the API provider's functionality adhere to the architectural style of REST.

More on REST APIs

A REST API is a popular way for systems to expose useful functions and data to consumers over the Internet. REST stands for Representational State Transfer, which can be described as an architectural pattern describing how distributed systems can expose a consistent interface. API stands for application programming interface, which is essentially a set of software functionality that can be consumed by other software programs (see full definition). Twilio, for example, provides a REST APIs for sending messages, making phone calls, looking up phone numbers, and a lot more.

Generally speaking, when people use the term REST API, they are referring to an API that is accessed via the HTTP protocol at a predefined set of URLs (uniform resource locators) representing the various resources with which interactions can occur.

Resources

A REST API will be made up of one or more resources. A resource is any information or content accessed at a given URL - resources could be JSON, images, HTML, or audio files. Resources can usually have one or more methods that can be performed on them over HTTP. Some of the most common are in the table below.

Method Common Use
GET Most often used to retrieve a resource at a given URL. Can be requested over and over without side effects. When your browser retrieves a web page, it is performing an HTTP GET request to retrieve that page and the assets on it.
POST Most often used to create new data on a server. POST requests usually have side effects, like creating new comments or bank charges every time they are submitted.
PUT Often used for updating data. You can submit a PUT request over and over and it should not have side effects (it should do the same thing every time).
DELETE Used to delete resources from the server.

These HTTP verbs sometimes DO NOT map 1:1 to these tasks, but commonly REST APIs provide a "CRUD" interface to remote resources. "CRUD" stands for these four operations.

  • Create
  • Read (one or multiple)
  • Update
  • Delete

To send a text message with Twilio, for example, you Create a new Message resource. This creates an instance of the resource. You can then Read this instance later to review the message, Update the message body to redact the message, and even Delete the message.

Code Examples

Loading Code Sample...
      
      
          
          
          
          
        
      Loading Code Sample...
          
          
              
              
              
              
            
          Loading Code Sample...
              
              
                  
                  
                  
                  
                

              Learn More

              The REST architectural style goes much deeper. If you'd like to learn more about the REST architectural pattern and REST API's, please check out these resources: