npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vue-api-request-builder

v0.2.10

Published

A Vue 3 component for building and testing API requests with a beautiful UI.

Readme

API Request Builder

A Vue 3 component for building and testing API requests with a beautiful UI.

Start of Selection

中文文档

Workflow

graph TD
    A[Start] --> B[Configure Request]
    B --> C[RequestForm Component]
    C --> D[Set Request Parameters]
    D --> E[URL/Path]
    D --> F[Authentication]
    D --> G[Headers]
    D --> H[Request Body]
    E & F & G & H --> I[Execute Request]
    I --> J[ResponseSection Component]
    J --> K[Display Response]
    K --> L[Status Code]
    K --> M[Response Headers]
    K --> N[Response Body]
    L & M & N --> O[Data Transformation]
    O --> P[DataTransform Component]
    P --> Q[Transform Function]
    Q --> R[Transformed Result]
    R --> S[End]

Installation

npm install vue-api-request-builder
# or
yarn add vue-api-request-builder
# or
pnpm add vue-api-request-builder

Usage

Basic Usage

<template>
  <div class="app-container">
    <RequestForm v-model="requestSchema" @update:modelValue="handleSchemaChange" />
    <ResponseSection v-model="requestSchema" />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { RequestForm, ResponseSection, type RequestSchema, defaultRequestSchema } from 'vue-api-request-builder';

const requestSchema = ref<RequestSchema>(defaultRequestSchema);

const handleSchemaChange = (newSchema: RequestSchema) => {
  console.log("Schema changed:", newSchema);
};
</script>

Components

RequestForm

The main component for building API requests. It provides a form interface for configuring:

Props

  • modelValue (RequestSchema): The request schema object (v-model)

Events

  • update:modelValue: Emitted when the schema changes

Features

  • HTTP method selection (GET, POST, PUT, DELETE, OPTIONS)
  • URL configuration with base URL and path
  • URL parameters management
  • Authentication options:
    • None
    • Basic Auth
    • Bearer Token
  • Custom headers
  • Request body support for:
    • JSON
    • Form Data
    • Raw text
  • Live preview of request URL and body

ResponseSection

Displays the response from the API request.

Props

  • modelValue (RequestSchema): The request schema object (v-model)

Features

  • Request method selection (XMLHttpRequest/Fetch)
  • Response display:
    • Status code with color coding
    • Response time
    • Response headers
    • Response body with formatting
  • Error handling and display

DataTransform

Component for configuring and executing data transformation functions.

Props

  • modelValue (string): The transformation function string (v-model)

Features

  • Code editor interface
  • JavaScript function support
  • Real-time syntax checking
  • Function execution preview

KeyValueInput

A reusable component for managing key-value pairs.

Props

  • modelValue (KeyValuePair[]): Array of key-value pairs (v-model)
  • addButtonText (string): Text for the add button
  • showPreview (boolean): Whether to show the preview
  • previewText (string): Text to show in preview

Events

  • update:modelValue: Emitted when the key-value pairs change

Types

RequestSchema

interface RequestSchema {
  method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'OPTIONS';
  url: string;
  path: string;
  auth: AuthConfig;
  params: KeyValuePair[];
  headers: KeyValuePair[];
  body: RequestBody;
}

AuthConfig

interface AuthConfig {
  type: 'none' | 'Basic' | 'Bearer';
  username?: string;
  password?: string;
  token?: string;
}

RequestBody

interface RequestBody {
  type: 'application/json' | 'multipart/form-data' | 'text/plain';
  json?: string;
  formData?: KeyValuePair[];
  raw?: string;
}

ResponseData

interface ResponseData {
  status: string;
  headers: Record<string, string>;
  body: string;
  timing?: number;
}

Utilities

executeRequest

function executeRequest(
  schema: RequestSchema,
  method: 'fetch' | 'xhr' = 'xhr'
): Promise<ResponseData>

Executes the API request using either Fetch API or XMLHttpRequest.

executeTransformFunction

function executeTransformFunction(
  transformFunctionString: string,
  data: any
): any

Executes a data transformation function to convert input data into the desired format.

Dependencies

This package requires:

  • Vue 3.x
  • Ant Design Vue 4.x

License

MIT