Posting

repository·main·Indexed 11 days ago

https://github.com/darrenburns/posting

A terminal-based (TUI) HTTP client version 2.10.0 that provides a Postman-like experience. It features Vim keys, jump mode navigation, local YAML-based request storage, and support for environments, variables, and Python scripts. Posting allows importing requests from cURL, Postman, or OpenAPI specs and supports external editor and pager integration.

Tokens
16.8K
Snippets
54
Records
87
Agent score
95%

What's inside Posting

  1. Overview of Posting

    main

    Posting is a terminal-based (TUI) HTTP client designed for efficient, keyboard-centric workflows. It functions similarly to Postman or Insomnia but is optimized for the terminal and can be used over SSH.

    Key features include:

    • Request Management: Requests are stored locally in simple YAML files, making them easy to version control.
    • Navigation & UI: Supports 'jump mode' navigation, Vim keys, a command palette, and autocompletion.
    • Advanced Workflows: Supports environments/variables, running Python code before/after requests, and customizable keybindings/themes.
    • Interoperability: Import requests from cURL (by pasting into the URL bar), Postman, or OpenAPI specs; export requests as cURL commands.
    • Editor Integration: Ability to open content in your configured $EDITOR or $PAGER.
  2. What is a collection in Posting?

    main
    In Posting, a collection is simply a directory on your file system. It may contain requests formatted in .posting.yaml. There are no special files or metadata required; a collection is just a directory that you load into the application to organize and navigate your requests.
  3. Understand how requests are stored

    main

    Requests in Posting are stored directly on your file system as simple YAML files with the .posting.yaml suffix. This makes them easy to read, version control, and share.

    To load requests into the application, use the --collection option to specify a directory. Posting will then display all .posting.yaml files found within that directory in the sidebar.

    name: Create user
    description: Adds a new user to the system.
    method: POST
    url: https://jsonplaceholder.typicode.com/users
    body: 
      content: |- 
        {
          "firstName": "John",
          "email": "john.doe@example.com"
        }
    headers:
    - name: Content-Type
      value: application/json
    params:
    - name: sendWelcomeEmail
      value: 'true'
  4. How script types work in Posting

    main

    Posting allows you to attach Python scripts to requests at three distinct stages of the request/response lifecycle. Understanding these stages is key to knowing when you can modify data versus when you can only inspect it:

    1. Setup Scripts: Executed before the request is constructed. Use these to initialize variables (via posting.set_variable) that will be substituted into the request using the $ syntax (e.g., $my_var).
    2. Pre-request Scripts: Executed after the request is constructed and variables are substituted, but before the request is sent. Use these to directly manipulate the RequestModel object (e.g., adding headers or changing authentication).
    3. Post-response Scripts: Executed after the response is received. Use these to inspect the httpx.Response object, extract data (like tokens), or perform cleanup tasks.
  5. Use the collection browser to navigate requests

    main

    The collection browser is the sidebar in the Posting UI that displays the files within your currently open collection.

    • Navigation: Use your mouse or keyboard to navigate the tree. Press Enter on a focused request to load it into the main UI.
    • Selection: An open request is marked with a visual indicator to the left of its title.
    • Saving: Performing a save operation will overwrite the currently open request in the collection.
    • Shortcuts: Use Shift+j and Shift+k to jump through sub-collections. Press F1 while the browser has focus to see the full list of shortcuts.
    • Positioning: You can move the sidebar to the left or right side of the screen by configuring collection_browser.position to either "left" or "right".
  6. Use variables in input fields and text areas

    main

    You can use variables within Posting's input fields and text areas to dynamically substitute values into outgoing requests. Use either the ${VARIABLE_NAME} or $VARIABLE_NAME syntax. These variables must be defined in a loaded .env file or available in the host environment.

    https://${ENV_NAME}.example.com
  7. Use `.env` files for environment-specific settings

    main

    Posting supports dotenv files, which are useful for swapping settings between environments (e.g., dev vs prod).

    To load a specific .env file, use the --env CLI option. You can supply this option multiple times to load multiple files.

    Example .env file:

    POSTING_THEME="cobalt"
    POSTING_LAYOUT="vertical"
    POSTING_HEADING__VISIBLE="false"

    To run Posting with a specific environment file:

    posting --env dev.env
    # Example .env content
    POSTING_THEME="cobalt"
    POSTING_LAYOUT="vertical"
    POSTING_HEADING__VISIBLE="false"
    
    # Command to run
    posting --env dev.env
  8. Create and install custom themes

    main

    Posting supports custom themes defined in .yaml files. To create a theme:

    1. Locate the themes directory: Run posting locate themes in your terminal to find where Posting looks for user-defined themes.
    2. Create the file: Place a new .yaml file in that directory. The filename is arbitrary, but the extension must be .yaml.
    3. Define the name: The theme is identified by the name field inside the YAML file, not by the filename.
    4. Apply the theme: Add theme: <name> to your config.yaml file.
    5. Restart: Restart Posting for the new theme to take effect.

    Live Preview: If you edit a theme file while Posting is running, the UI will automatically refresh to reflect changes. You can disable this by setting watch_themes: false in config.yaml.

    name: example
    primary: '#4e78c4'
    secondary: '#f39c12'
    accent: '#e74c3c'
    background: '#0e1726'
    surface: '#17202a'
    error: '#e74c3c'
    success: '#2ecc71'
    warning: '#f1c40f'
    
    # Optional metadata
    author: Darren Burns
    description: A dark theme with a blue primary color.
    homepage: https://github.com/darrenburns/posting
  9. Export a request to cURL

    main

    You can transform the currently open request into a cURL command and copy it to your clipboard.

    Steps:

    1. Open the command palette.
    2. Select export: copy as curl.

    You can append custom arguments to the generated cURL command by setting curl_export_extra_args in your config.yaml.

    # config.yaml
    # These args are inserted immediately after 'curl '
    curl_export_extra_args: "--verbose -w %{time_total} %{http_code}"

    Resulting command example:

    curl --verbose -w %{time_total} %{http_code} -X POST ...