Skip to content
TheChatArchiveThe Chat Archive
Geminigemini-2.0-flash-001· GoogleHugging Face LMArena Human Preference 140K

What currently maintained Emacs packages are available for making HTTP/rest style calls?

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with o3-2025-04-16’s answer.
  1. User

    What currently maintained Emacs packages are available for making HTTP/rest style calls?

  2. Gemini Assistant

    There are several actively maintained Emacs packages for making HTTP/REST-style calls. Here's a breakdown of the most popular and capable options, along with their strengths and weaknesses:

    1. request (Most Common and Recommended)

    • Description: A general-purpose HTTP client for Emacs, providing a flexible and feature-rich API. It's widely used and considered the standard for many Emacs packages that need to make HTTP requests.

    • Features:

      • Simple API: Relatively easy to use, with functions like request and request-async.
      • Asynchronous: Supports asynchronous requests, crucial for maintaining a responsive Emacs.
      • Request Methods: Supports all common HTTP methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS).
      • Headers: Full control over HTTP headers.
      • Data Encoding: Handles different data encodings (JSON, form data, etc.).
      • SSL/TLS: Supports secure HTTPS connections.
      • Proxy Support: Works with HTTP proxies.
      • Streaming: Can handle large responses by streaming data.
      • Comprehensive Documentation: Well-documented.
    • Installation: M-x package-install request

    • Example:

      (request "https://api.example.com/data"
               :success (lambda (data &rest _)
                          (message "Response: %s" (request-response-data data :format 'json)))
               :error (lambda (data &rest _)
                        (message "Error: %s" (request-response-data data))))
      
    • Why it's good: request is a reliable, mature, and well-maintained package. Its asynchronous nature is essential for a smooth Emacs experience. It's the go-to choice for most HTTP tasks.

    2. url (Built-in, Basic but Limited)

    • Description: A built-in Emacs library for handling URLs and making HTTP requests. It's available without needing to install a package.

    • Features:

      • Built-in: No installation required.
      • Basic HTTP: Supports simple GET and POST requests.
      • Limited Functionality: Lacks many features found in request, such as asynchronous requests, advanced data encoding, and streaming.
    • Installation: None required, it's part of Emacs.

    • Example:

      (url-retrieve "https://api.example.com/data"
                   (lambda (status)
                     (let ((data (url-retrieve-synchronously "https://api.example.com/data")))
                       (message "Response: %s" data)))
                   t) ; t for asynchronous
      
    • Why it's generally not recommended: While url is convenient because it's built-in, it's usually insufficient for modern REST APIs. Its synchronous nature can block Emacs. Use request unless you have a very specific reason to avoid it.

    3. restclient (For Interactive REST Client)

    • Description: An Emacs minor mode for making and documenting REST requests within Emacs, inspired by tools like Paw or Insomnia. Excellent for exploratory testing and debugging APIs. It's not primarily for programmatic use (though it can be used that way).

    • Features:

      • Interactive: Write REST requests in a special buffer and execute them.
      • Syntax Highlighting: Highlights the HTTP request syntax.
      • Autocompletion: Helps with headers and common values.
      • Response Display: Displays the response in a nicely formatted buffer.
      • History: Keeps a history of your requests.
      • Variables: Supports variables for dynamic requests.
    • Installation: M-x package-install restclient

    • How to use:

      1. Create a file (e.g., api.rest) and start writing your REST requests.
      2. Enter restclient-mode.
      3. Use commands like restclient-http-send-current to execute the request at point.
    • Why it's good: restclient is fantastic for exploring and testing APIs interactively. It's a great tool to have in your toolbox if you work with REST APIs regularly. It complements packages like request – you use restclient to figure out the correct requests, then use request in your code to automate them.

    4. dash-http (Convenience Wrapper around request)

    • Description: A thin wrapper around request to simplify common HTTP operations. It aims to provide a more concise and functional API.
    • Features:
      • Simplified API: Offers functions like http-get, http-post, etc., that wrap request calls with default settings.
      • JSON Handling: Often includes helpers for working with JSON data.
      • Convenience: Reduces boilerplate code.
    • Installation: M-x package-install dash-http
    • Example:
      (dash-http/get "https://api.example.com/data"
                        :success (lambda (data)
                                   (message "Data: %s" (json-read-from-string data))))
      
    • Why it's good: If you find yourself repeatedly writing similar request calls, dash-http can help make your code cleaner and more readable. It's a good choice if you prefer a more functional style.

    5. org-mode (Indirectly via org-babel)

    • Description: While not strictly an HTTP client package, Org Mode can be used to make HTTP requests using org-babel (code execution).

    • Features:

      • Literate Programming: Embed HTTP requests within your Org Mode documents.
      • Reproducible Results: Capture the results of HTTP requests alongside your documentation.
      • Requires a Language: You'll need to use a language like Python or shell scripting to make the actual HTTP request within your Org Babel block.
    • Installation: org-mode is included with Emacs; org-babel is enabled by default. You'll need the necessary language (e.g., Python) installed.

    • Example:

      #+BEGIN_SRC python :results value
      import requests
      response = requests.get("https://api.example.com/data")
      response.json()
      #+END_SRC
      
      #+RESULTS:
      : (("key" . "value"))
      
    • Why it's good: Excellent for literate programming and documentation that involves making HTTP requests and showing the results. It's not ideal for general-purpose HTTP client usage in your Emacs code.

    Choosing the Right Package

    • For most general-purpose HTTP requests in your Emacs Lisp code: request is the best choice.
    • For simplified HTTP calls, consider dash-http on top of request.
    • For interactive REST API exploration and testing: restclient is invaluable.
    • For documenting HTTP requests and their results within Org Mode: Use org-babel.
    • Avoid url unless you have very specific constraints; it's usually too limited.

    Key Considerations:

    • Asynchronous vs. Synchronous: Favor asynchronous requests (supported by request, dash-http, and url in asynchronous mode) to avoid blocking Emacs.
    • Dependencies: Most of these packages are easy to install using package-install.
    • Maintenance: Choose packages that are actively maintained. Look at the project's GitHub repository to see recent activity.

    In summary, request is the workhorse for most HTTP needs in Emacs. restclient is perfect for interactive testing. And dash-http is a nice convenience wrapper. Choose the package that best fits the specific task you're trying to accomplish.

  3. User

    Focus on interactive use.

  4. Gemini Assistant

    Okay, focusing on interactive use for making HTTP/REST calls in Emacs, the standout option is definitely restclient.

    Here's why restclient excels for interactive use and how to get the most out of it:

    restclient - The Interactive Champion

    • Purpose-built for exploration: restclient is designed from the ground up to be used interactively for testing and experimenting with APIs. It's not just a library; it's a full-fledged mode that turns your Emacs buffer into a powerful REST client.

    • Workflow: You write your HTTP requests directly in an Emacs buffer. This buffer becomes your interactive workspace for crafting, executing, and refining your requests. You can then use the results to tweak the request and resend, until you get the result you want.

    • Key Features for Interactive Use:

      • Request Definition in a Buffer: You type out the HTTP request using a simple, intuitive syntax. This makes it easy to see the entire request at a glance. You can define multiple requests in a single buffer, separated by delimiters (e.g., ###).

      • Syntax Highlighting: Makes requests more readable and helps you catch errors.

      • Autocompletion: Autocompletes HTTP methods, headers, and URL components, saving you typing and preventing typos.

      • Variable Support: Define variables that can be used in your requests. This is excellent for dynamic data or values that you want to change easily.

      • Response Display: The response from the server is displayed in a separate, formatted buffer. restclient understands different content types (JSON, XML, HTML, etc.) and presents them in a readable way.

      • Request History: restclient keeps a history of the requests you've made, so you can easily revisit and modify them.

      • Integration with Other Tools: You can easily copy and paste requests from restclient into other tools like curl or your programming language of choice.

    • How to use restclient interactively:

      1. Install: M-x package-install restclient

      2. Create a .rest file (or any file, really): Open a new file (e.g., my-api-requests.rest). The .rest extension is conventional but not required.

      3. Enter restclient-mode: Type M-x restclient-mode in the buffer. This enables all the restclient features.

      4. Write your request: Here's an example:

        ### GET Request
        
        GET https://api.example.com/users
        
        ### POST Request
        
        POST https://api.example.com/users
        Content-Type: application/json
        
        {
          "name": "John Doe",
          "email": "john.doe@example.com"
        }
        
        ### GET Request with header
        
        GET https://api.example.com/users
        Authorization: Bearer YOUR_API_KEY
        
      5. Send the request: Place your cursor inside the request you want to execute (anywhere between the ### lines or at the beginning) and type C-c C-c (or M-x restclient-http-send-current).

      6. View the response: The response will appear in a new buffer. You can then inspect the headers, status code, and body of the response.

      7. Iterate: Modify the request as needed and resend it until you get the desired result.

    • Commands: Here are some useful restclient commands:

      • restclient-http-send-current: Sends the request at point.
      • restclient-http-send-all: Sends all requests in the buffer.
      • restclient-http-send-region: Sends the requests in the selected region.

    Why request and url aren't as good for interactive use (compared to restclient):

    • request is primarily a library for programmatic use. While you could use it interactively in the *scratch* buffer or in a custom function, it's not designed for that purpose. You'd have to write Lisp code to construct and send the requests, which is much more verbose and less intuitive than restclient's approach.

    • url is even more basic and less suitable for interactive use. It lacks the features and ease of use of restclient.

    In summary: For interactive exploration, testing, and debugging of HTTP/REST APIs within Emacs, restclient is the clear winner. It's the right tool for the job. It makes it quick and easy to craft, send, and analyze HTTP requests directly within Emacs.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.