Git Product home page Git Product logo

http-prompt's Introduction

HTTP Prompt

PyPI Travis Appveyor Coverage

HTTP Prompt is an interactive command-line HTTP client featuring autocomplete and syntax highlighting, built on HTTPie and prompt_toolkit.

image

Installation

Just install it like a regular Python package:

$ pip install http-prompt

You'll probably see some permission errors if you're trying to install it on the system-wide Python. It isn't recommended. But if that's what you want to do, you need to sudo:

$ sudo pip install http-prompt

Another alternative is to use --user option to install the package into your user directory:

$ pip install --user http-prompt

To upgrade HTTP Prompt, do:

$ pip install -U http-prompt

Quickstart

To start a session, you use the http-prompt executable:

# Start with the given URL
$ http-prompt http://httpbin.org

# Or start with some initial options
$ http-prompt localhost:8000/api --auth user:pass username=somebody

Once you're in a session, you can use the following commands.

To change URL address, use cd:

# Relative URL path
> cd api/v1

# Absolute URL
> cd http://localhost/api

To add headers, querystring, or body parameters, use the syntax as in HTTPie. The following are all valid:

> Content-Type:application/json username=john
> 'name=John Doe' apikey==abc
> Authorization:"Bearer auth_token"

You can also add HTTPie options like this:

> --form --auth user:pass
> --verify=no username=jane

To preview how HTTP Prompt is going to call HTTPie, do:

> httpie post
http --auth user:pass --form POST http://localhost/api apikey==abc username=john

You can temporarily override the request parameters by supplying options and parameters in httpie command. The overrides won't affect the later requests.

# No parameters initially
> httpie
http http://localhost

# Override parameters temporarily
> httpie /api/something page==2 --json
http --json http://localhost/api/something page==2

# Current state is not affected by the above overrides
> httpie
http http://localhost

To actually send a request, enter one of the HTTP methods:

> get
> post
> put
> patch
> delete
> head

The above HTTP methods also support temporary overriding:

# No parameters initially
> httpie
http http://localhost

# Send a request with some overrided parameters
> post /api/v1 --form name=jane

# Current state remains intact
> httpie
http http://localhost

To remove an existing header, a querystring parameter, a body parameter, or an HTTPie option:

> rm -h Content-Type
> rm -q apikey
> rm -b username
> rm -o --auth

To reset the session, i.e., clear all parameters and options:

> rm *

To exit a session, simply enter:

> exit

Configuration

When launched for the first time, HTTP Prompt creates a user config file. The config file is $XDG_CONFIG_HOME/http-prompt/config.py (or %LOCALAPPDATA%/http-prompt/config.py on Windows), By default, it's ~/.config/http-prompt/config.py (or ~/AppData/Local/http-prompt/config.py).

config.py is a Python module with all the available options you can customize. Don't worry. You don't need to know Python to edit it. Just open it up with a text editor and follow the guidance inside.

Persistent Context

HTTP Prompt keeps a data structure called Context to represent your current session. Every time you enter a command, HTTP Prompt saves the context to your filesystem, enabling you to resume your previous session when you restart http-prompt.

Categorized by hostnames and ports, context data is stored in the user data directory, which is $XDG_DATA_HOME/http-prompt (or %LOCALAPPDATA%/http-prompt on Windows). By default, it's ~/.local/share/http-prompt (or ~/AppData/Local/http-prompt on Windows).

As context data may contain sensitive data like API keys, you should keep the user data directory private. By default, HTTP Prompt sets the modes of $XDG_DATA_HOME/http-prompt to rwx------ (i.e., 700) so that the only person who can read it is the owner (you).

Roadmap

  • More configurable options
  • More HTTP headers for autocomplete
  • Support for advanced HTTPie syntax, e.g, field:=json and [email protected]
  • Support for cURL command preview
  • Shell command evaluation
  • Python syntax evaluation
  • HTTP/2 support

http-prompt's People

Contributors

eliangcs avatar karlcow avatar mikeecb avatar thegrammarnazi avatar rmax avatar yegorov avatar sirbranedamuj avatar

Watchers

Chih-Hsueh "Josh" Huang avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.