Skip to content

REST Requests

What is a REST Request?

A REST request is a way to request and exchange data with a server.

For instance, you can get the latest weather updates or post a tweet via REST API.

A REST (Representational State Transfer) request is a standardized method used for interacting with resources (like data entities) on a server. It's a part of the RESTful architectural style, which structures a web application as a set of resources with consistent, predefined methods to create, read, update, and delete them.

REST requests are made via HTTP (Hypertext Transfer Protocol), the same protocol that's used to load web pages in your browser. There are four primary types of REST requests, each corresponding to a specific HTTP method.

How to Create REST Requests in Wized

To create a REST request in Wized:

Adding REST to my apps

1. Go to My Apps

Begin by going to the 'My Apps' panel in Wized.

  1. Click the + button at the top of the panel.

  2. Add a name for your app for later reference, i.e. Xano.

  3. Pick the REST option.

  4. Optionally, you can add a Base URL for your requests. This is useful if you're making requests to the same server, and you don't want to repeat the URL in every request. It is also required if you plan to use Secrets. The base URL is defined via a function like this:

js
return 'https://example.com/api';

2. Configure your request

Go to the Requests panel and start configuring your request.

Adding basic info to our request

Create a new request, and add basic info

  • Name your request i.e. get_products
  • Add your request to a folder (optional)
  • Select your REST App from the dropdown

Add your endpoint, and pick an HTTP method

Choosing endpoint and HTTP method for a request

Input the endpoint path, such as /products, which is the specific location in the API you’re interacting with and the HTTP method you want to use:

  • GET: Retrieves data from a specific resource.
  • POST: Sends data to a server to create a new resource.
  • PUT: Updates a specific resource with new data.
  • PATCH: Partially updates data at the specified resource.
  • DELETE: Removes a specific resource.

URL Parameters

Depending on your backend, you might have to send data in URL parameters (query parameters).

Here's an example endpoint from the OpenWeatherAPI, which expects values to be passed within parameters:

https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API key}

So in this case, this would be our base URL: https://api.openweathermap.org/data/2.5, /weather would be our endpoint, and we would have 3 parameters:

  • lat: for latitude
  • lon: for longitude
  • appid: for our API key

Here is how this request could look in Wized with hardcoded values:

Sending data with wized in URL parameters

WARNING

You should never expose your API keys like we did in the screenshot above. In a real application, you would want to store your API key as a Secret.

Headers

Sending an auth token to our backend via REST API

The header section usually contains metadata and authentication information.

Often, we use headers when sending the logged-in user's auth token. Either as shown in the example above, or by adding the string Bearer in front:

js
return 'Bearer ' + c.token;

Another common example is sending the Content-type header. By default, Wized will send the content type that fits the data you're sending. But if you want to be explicit, you can add it like this:

Adding the content-type header to a Wized request

Body

For methods like POST and PUT, provide the body of the request.

The data that you provide here should match with the inputs that your backend is expecting. For instance, the server that you're sending data to in a POST request might expect something like this:

json
{
  "name": "string", //string
  "course_id": 0, // number
  "lessons": [
    // array of objects
    {
      "lesson_id": 0,
      "sort": 0
    }
  ]
}

Which in Xano, would look like this:

Xano inputs

Setting up the Body in Wized would look like this:

Sending a wized request to Xano

Using Secrets in REST Requests

If you need to use private API keys or other sensitive information in your REST requests, you can use Secrets to avoid publicly exposing them.

With a REST app you can connect to any service that provides a REST API. This includes, omong countless others, services like:

  • Webflow: Create, Update, Edit, or Delete your CMS items.
  • OpenAI: Add smart AI capabilities to your app.
  • Shopify: Use Shopify's powerful e-commerce backend in your application.
  • Xano & Fastgen: Build robust, no-code backends.
  • Make (formerly Integromat): Automate tasks smoothly.
  • OpenWeatherMap: Add weather data, and forecasts to your app.
  • PokeAPI: Find information about the Pokémon game and series.