Package: cli-requests
Cli-RequestsCli-Requestsis a command-line interface tool for simplifying HTTP requests. It allows you to effortlessly interact with APIs and websites directly from the terminal. This tool is designed to provide a seamless experience, enabling you to focus on making requests without the complexities of traditional tools.InstallationTo get started with Cli-Requests, you can install it using pip. Ensure you have Python 3.8 or higher installed.pip3installcli-requestsUsageCli-Requests makes it easy to send HTTP requests with various options. Here are some examples:Basic Requestcli-requestshttps://example.com/It's a basic GET request that will return nothing on success or an error.Get Specific Response DataYou can use various command-line arguments to get specific information from the response:--status-code: Show the HTTP status code.--headers-content: Show the response headers.--text-content: Show the text content of the response.--binary-content: Show the binary content of the response.--json-content: Show the response content as JSON.--final-url: Show the final URL after following redirects.--elapsed-time: Show the elapsed time for the request.--cookies-content: Show the cookies.For example, to get the status code and headers, use:cli_requestshttps://google.com--status-code--headers-contentThis code will print stauts code and headers in console.Save Response to a FileTo save the response content to a file, you can use IO redirection with --nocolor argument or --output-file parameter. For example, to save the response to a file namedoutput.txt, use:cli_requestshttps://google.com/--headers-content--status-code--elapsed-time--nocolor>output.txtORcli_requestshttps://google.com/--headers-content--status-code--elapsed-time--output-fileoutput.txtoutput.txt exampleStatus Code:
200

Headers:
{'Date': 'Sat, 18 Nov 2023 14:05:29 GMT', 'Expires': '-1', ...}

Elapsed Time:
0:00:00.193750Sending POST Request with JSON Datacli-requests(YOURURL)--methodPOST--data'{"key": "value"}'Issue with Escaping Quotes in Windows Console when Using JSON ObjectsWhen working with JSON objects in the Windows console, there might be issues due to the required escaping of quotes. You must pass JSON objects like this.cli-requests(YOURURL)--methodPOST--data'{\"key\": \"value\"}'Reading Request Configuration from a FileURL is always required, so make sure that you passed it even with configuration file.cli-requests(YOURURL)--load-configpath/to/request_config.jsonColorized OutputThe output from cli-requests is always presented in color for improved readability. However, for those who prefer a monochromatic display or have specific requirements, there is an optional parameter--nocolor. Adding this parameter to the command will disable the colorful output. For example:cli-requestshttps://google.com--status-code--nocolorRequest ConfigurationCreate a JSON file to define your request configuration. Below is an example for a GET request:{"url":"YOUR URL","method":"GET","params":{"key1":"value1","key2":"value2"},"headers":{"Authorization":"Bearer YourAccessToken"},"timeout":5000}List of parametersUse-h|--helpfor helpRequest parameters-m|--method: HTTP method (default: GET)-p|--params: Request parameters (in JSON format)-f|--files: Files to upload with the request (in JSON format)-x|--proxies: Proxies for the request (in JSON format)-d|--data: Data for the request (in JSON format)-s|--headers: Headers for the request (in JSON format)-t|--timeout: Timeout for the request (in seconds)-a|--auth: Authentication credentials (username and password)-c|--cookies: Cookies for the request (in JSON format)-v|--verify: Verify SSL certificate (default: True)-e|--cert: Path to SSL certificate file-r|--allow-redirects: Allow redirects (default: True)Additional parameters for displaying information:-S|--status-code: Show the status code-H|--headers-content: Show the headers-T|--text-content: Show the text content-B|--binary-content: Show the binary content-J|--json-content: Show the JSON content-U|--final-url: Show the final URL-E|--elapsed-time: Show the elapsed time-C|--cookies-content: Show the cookiesAdditional parameters:-L|--load-config: Load configuration from a JSON file-O|--output-file: Save the output to a fileTo disable colored output, use-w|--nocolor.ContributionFeel free to fork the project, make your changes, and submit a pull request.LicenseCli-Requests is licensed under the MIT License. See theLICENSEfile for details.AuthorSabberianSabberian@gmail.comhttps://github.com/Sabberian