Create Your First API Request

Learn how to create and configure your first API request in Maeris. This guide will walk you through the process step by step.

Overview

An API request in Maeris is an HTTP request that you send to test your API endpoints. You can configure the method, URL, headers, body, and other parameters to match your API's requirements.

Step-by-Step Guide

  1. Open Terminal > API: Navigate to the API section in Maeris Terminal
  2. Create a New Collection: Click "New Collection" to create a container for your API requests

    Collections help organize related API requests together.

  3. Set Base URL: Configure the base URL for your API in the collection settings

    This will be used as the base for all requests in the collection.

  4. Create a New Request: Click "Add Request" or "New Request" in your collection
  5. Configure Request Method: Select the HTTP method (GET, POST, PUT, DELETE, PATCH, etc.)

    Choose the method that matches your API endpoint's requirements.

  6. Enter Request URL: Specify the endpoint path (the base URL is automatically prepended)

    For example, if your base URL is "https://api.example.com" and you enter "/users", the full URL will be "https://api.example.com/users".

  7. Add Headers (if needed): Configure request headers such as Content-Type, Authorization, etc.

    Common headers include Content-Type: application/json, Authorization: Bearer token, etc.

  8. Add Request Body (for POST/PUT/PATCH): If your request requires a body, add it in the appropriate format (JSON, form-data, etc.)

    Make sure the Content-Type header matches your body format.

  9. Add Query Parameters (if needed): Configure URL query parameters for GET requests or other methods
  10. Run the Request: Click "Run" to execute the request and view the response

Example: GET Request

Here's an example of creating a simple GET request to fetch user information:

GET /api/users/123
Headers:
Authorization: Bearer your-token-here
Content-Type: application/json

Example: POST Request

Here's an example of creating a POST request to create a new user:

POST /api/users
Headers:
Content-Type: application/json
Authorization: Bearer your-token-here
Body:
{
"name": "John Doe",
"email": "john@example.com"
}

Using Variables

You can use variables in your requests to make them more flexible and reusable. Variables are defined in environments and can be referenced using double curly braces.

Example: Use {{baseUrl}} for the base URL or {{userId}} in the URL path.

Learn more about variables in our Working with Environments guide.

Adding Authentication

Most APIs require authentication. You can configure authentication at the collection level or for individual requests.

Common Authentication Types

  • Bearer Token: Add "Authorization: Bearer {{token}}" header
  • API Key: Add API key as a header or query parameter
  • Basic Auth: Configure username and password
  • OAuth 2.0: Configure OAuth flow for token-based authentication

Next Steps