Learn how to design, execute, and debug REST API requests in Yasumu
Yasumu provides a powerful REST API testing module that allows you to create, organize, and execute HTTP requests. All REST entities are stored as .ysl files in your workspace, making them easy to version control and share with your team.
REST requests in Yasumu are called “entities” and are stored in the yasumu/rest/ directory. Each entity is a separate .ysl file containing the request configuration, scripts, and tests.
The script block contains pre-request and post-response scripts:
script { export function onRequest(req, res) { // Executed before sending the request req.headers.set('X-Timestamp', Date.now().toString()); } export function onResponse(req, res) { // Executed after receiving the response console.log('Status:', res.status); }}
// List request historyconst history = await workspace.rest.listHistory();history.forEach(item => { console.log(`${item.entityId} - Last executed: ${item.lastExecutedAt}`);});// Add to historyawait workspace.rest.upsertHistory(entity.id);// Clear history for a requestawait workspace.rest.deleteHistory(entity.id);
Use environment variables: Never hardcode API URLs, tokens, or sensitive data. Use environment variables and secrets instead.
Organize with groups: Create logical groups for different API domains, versions, or features.
Descriptive names: Use clear, descriptive names that explain what each request does.
Enable/disable parameters: Use the enabled flag to temporarily disable headers or parameters without deleting them.
Be careful when executing scripts that modify global state or make side effects. Scripts run in an isolated environment but can still affect your request context.