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
- Open Terminal > API: Navigate to the API section in Maeris Terminal
- Create a New Collection: Click "New Collection" to create a container for your API requests
Collections help organize related API requests together.
- 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.
- Create a New Request: Click "Add Request" or "New Request" in your collection
- Configure Request Method: Select the HTTP method (GET, POST, PUT, DELETE, PATCH, etc.)
Choose the method that matches your API endpoint's requirements.
- 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".
- Add Headers (if needed): Configure request headers such as Content-Type, Authorization, etc.
Common headers include Content-Type: application/json, Authorization: Bearer token, etc.
- 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.
- Add Query Parameters (if needed): Configure URL query parameters for GET requests or other methods
- 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:
Example: POST Request
Here's an example of creating a POST request to create a new user:
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
- Working with Environments - Learn about managing variables and settings
- API Assertions and Validations - Add validations to your requests
- API Flows – Chaining Multiple APIs - Chain multiple requests together