REST Client

GitHub Overview

Huachao/vscode-restclient

REST Client Extension for Visual Studio Code

Stars5,657
Watchers63
Forks479
Created:March 30, 2016
Language:TypeScript
License:MIT License

Topics

graphqlhttphttp-clientrestrest-apirest-clienttypescriptvisual-studio-codevscodevscode-extension

Star History

Huachao/vscode-restclient Star History
Data as of: 7/17/2025, 02:30 AM

Development Tool

REST Client

Overview

REST Client is a lightweight HTTP client extension for VS Code. It allows you to define API requests in simple text files (.http/.rest) and execute them directly within the editor. With easy Git management and minimalist design without UI, it has persistent popularity among development teams emphasizing developer privacy and efficiency.

Details

REST Client is an extension for sending HTTP requests and viewing responses within Visual Studio Code. It's a highly popular extension with over 2.6 million downloads, characterized by its thoroughly simple design. Request configurations are written in plain text files with .http or .rest extensions, without any complex GUI. This design makes it easy to share request configurations and version control, which is difficult with Postman or Fiddler. It covers essential features for basic API development including syntax highlighting, GraphQL support, multipart/form-data handling, file uploads, proxy support, and SOAP request transmission. Multiple requests can be written in a single file with request history management capabilities. The text-based configuration enables natural API specification sharing among team members, documentation, and CI/CD pipeline integration. Complete integration with the VS Code ecosystem allows API development to proceed without interrupting the development workflow.

Advantages & Disadvantages

Advantages

  • Text-based Design: Define requests in plain text with high readability
  • Complete Git Integration: Natural version control and diff viewing
  • Lightweight Minimal: No UI, design completed within VS Code
  • Sharability: File-based approach makes team sharing and documentation easy
  • Low Learning Curve: Intuitive understanding with simple HTTP syntax
  • Extensibility: Equipped with practical features like environment variables, authentication, proxy
  • Free: Completely free and open source
  • GraphQL Support: Also supports GraphQL queries

Disadvantages

  • VS Code Dependency: VS Code exclusive, cannot be used with other editors
  • Lack of UI: GUI-based convenience features are limited
  • Complex Operations: Advanced testing and scripting features are limited
  • Visual Limitations: Response display is text-based only
  • Learning Required: Understanding of HTTP syntax necessary

Reference Links

Usage Examples

Basic HTTP Requests (.http file)

# User Retrieval API
GET https://api.example.com/users/{{userId}} HTTP/1.1
Authorization: Bearer {{accessToken}}
Content-Type: application/json
Accept: application/json

###

# User Creation API
POST https://api.example.com/users HTTP/1.1
Authorization: Bearer {{accessToken}}
Content-Type: application/json

{
  "name": "John Doe",
  "email": "[email protected]",
  "age": 30,
  "department": "engineering"
}

###

# User Update API
PUT https://api.example.com/users/{{userId}} HTTP/1.1
Authorization: Bearer {{accessToken}}
Content-Type: application/json

{
  "name": "Jane Doe",
  "email": "[email protected]",
  "active": true
}

Environment Variables and File Separation

# Environment variables file (rest-client.env.json)
{
  "development": {
    "baseUrl": "https://api-dev.example.com",
    "accessToken": "dev-jwt-token",
    "userId": "12345"
  },
  "production": {
    "baseUrl": "https://api.example.com",
    "accessToken": "prod-jwt-token",
    "userId": "67890"
  },
  "local": {
    "baseUrl": "http://localhost:3000",
    "accessToken": "local-token",
    "userId": "test-user"
  }
}

# API requests file (api-requests.http)
# @name login
POST {{baseUrl}}/auth/login HTTP/1.1
Content-Type: application/json

{
  "username": "{{username}}",
  "password": "{{password}}"
}

###

# @name getUsers  
GET {{baseUrl}}/users?page=1&limit=10 HTTP/1.1
Authorization: Bearer {{accessToken}}

###

# @name createUser
POST {{baseUrl}}/users HTTP/1.1
Authorization: Bearer {{accessToken}}
Content-Type: application/json

{
  "name": "New User",
  "email": "[email protected]"
}

GraphQL Queries and Mutations

# GraphQL Query
POST {{graphqlEndpoint}} HTTP/1.1
Authorization: Bearer {{graphqlToken}}
Content-Type: application/json

{
  "query": "query GetUserProfile($userId: ID!) { user(id: $userId) { id name email posts { id title content createdAt } } }",
  "variables": {
    "userId": "{{currentUserId}}"
  }
}

###

# GraphQL Mutation
POST {{graphqlEndpoint}} HTTP/1.1
Authorization: Bearer {{graphqlToken}}
Content-Type: application/json

{
  "query": "mutation CreatePost($input: CreatePostInput!) { createPost(input: $input) { id title content author { name } } }",
  "variables": {
    "input": {
      "title": "New Post",
      "content": "Post created with GraphQL",
      "authorId": "{{currentUserId}}"
    }
  }
}

File Upload and Multipart

# File Upload (multipart/form-data)
POST {{baseUrl}}/upload HTTP/1.1
Authorization: Bearer {{accessToken}}
Content-Type: multipart/form-data; boundary=----boundary123

------boundary123
Content-Disposition: form-data; name="file"; filename="sample.txt"
Content-Type: text/plain

< ./files/sample.txt

------boundary123
Content-Disposition: form-data; name="description"

Sample file upload
------boundary123--

###

# Binary File Upload
POST {{baseUrl}}/upload/image HTTP/1.1
Authorization: Bearer {{accessToken}}
Content-Type: image/png

< ./images/logo.png

###

# JSON and File Combination
POST {{baseUrl}}/posts HTTP/1.1
Authorization: Bearer {{accessToken}}
Content-Type: multipart/form-data; boundary=----boundary456

------boundary456
Content-Disposition: form-data; name="metadata"
Content-Type: application/json

{
  "title": "Post with Image",
  "tags": ["sample", "upload"]
}

------boundary456
Content-Disposition: form-data; name="image"; filename="post-image.jpg"
Content-Type: image/jpeg

< ./images/post-image.jpg
------boundary456--

Authentication Patterns and Configuration

# Basic Authentication
GET {{baseUrl}}/protected HTTP/1.1
Authorization: Basic {{basicAuthToken}}

###

# Bearer Token Authentication
GET {{baseUrl}}/users HTTP/1.1
Authorization: Bearer {{jwtToken}}

###

# API Key Authentication (Header)
GET {{baseUrl}}/data HTTP/1.1
X-API-Key: {{apiKey}}
Content-Type: application/json

###

# API Key Authentication (Query Parameter)
GET {{baseUrl}}/search?q=example&api_key={{apiKey}} HTTP/1.1

###

# Custom Headers
GET {{baseUrl}}/custom HTTP/1.1
Authorization: Bearer {{accessToken}}
X-Client-Version: 1.2.3
X-Request-ID: {{$guid}}
X-Timestamp: {{$timestamp}}
User-Agent: RestClient/1.0

Preprocessing and Postprocessing

# Variable Setting Before Request
# @note Generate timestamp for testing
POST {{baseUrl}}/events HTTP/1.1
Authorization: Bearer {{accessToken}}
Content-Type: application/json

{
  "eventType": "test",
  "timestamp": "{{$timestamp}}",
  "requestId": "{{$guid}}",
  "data": {
    "message": "Test event"
  }
}

###

# Request with Dynamic Values
# @note Create test data with random values
POST {{baseUrl}}/users HTTP/1.1
Authorization: Bearer {{accessToken}}
Content-Type: application/json

{
  "name": "User-{{$randomInt 1000 9999}}",
  "email": "user{{$randomInt 100 999}}@example.com",
  "timestamp": "{{$datetime iso8601}}"
}

###

# Value Extraction and Reuse from Response
# @name createSession
POST {{baseUrl}}/auth/sessions HTTP/1.1
Content-Type: application/json

{
  "username": "{{username}}",
  "password": "{{password}}"
}

###

# Use Session ID from Previous Response
# @note Get sessionId from createSession response
GET {{baseUrl}}/profile HTTP/1.1
Authorization: Bearer {{createSession.response.body.sessionId}}