HomeGuidesAPI ReferenceChangelog
GuidesAPI ReferenceChangelogLog In

How to Make an API Call

Once you've signed up for a developer account and found your Access Token, it's time to make your first API call. Before we get started, let's understand the components of an API call.

What makes up an API request?

You need X things to make an API call:

  • Endpoint: This is the URL you're requesting data from.

There are two endpoints to consider: the Rest endpoint, which is the main path of the API. For Revel's API, the Rest endpoint looks like https://[yoursubdomain].revelup.com/resources/. The API endpoint specifies the resource you want to request information about. An example Revel API endpoint is OrderItem, which can create an order or modify information about an order.

  • Method: The type of request you send to the server.

You can use one of five HTTP methods in your request: GET, PUT, POST, PATCH, and DELETE. Learn more about HTTP methods in our Rest API article.

  • Headers: HTTP headers are key-value pairs that provide information to the server about the request. These can detail information like the types of information the request is sending, authentication information, and more.

Revel's requests and responses are written in JSON, so you want to tell the server to expect JSON. You can do this by adding the content-type: application/json header to your request header.

You can also send your access information via a HTTP header.

  • Data (or body): The content of the request. This section is only used when you're telling the server to update, create, or delete information--i.e. for requests that are not GET requests. This typically takes the form of key-value pairs that tell the server what to modify.

For example, if you want to create a discount named "10% off coffee", you would use the Discount resource and set the name value equal to "10% off coffee".

  • Parameters (optional): These help you modify the response you get. For instance, you might want to see only the first ten customers or view the results in descending order. Using parameters help you request exactly the information you want. Learn more about the Revel API's supported parameters in our FAQ.

  • ** API key/secret: There are two ways that the key and secret can be passed.

a. In the Request Header: The key and secret should be joined by a colon and passed in each request as a header named API-AUTHENTICATION.

For example:
API-AUTHENTICATION: xxxx:yyyy

b. As a GET or POST variable: The key and secret can be passed as parameters named api_key and api_secret.

For example:
?api_key=xxxx&api_secret=yyyy