Skip to main content

Hand-curate your artisanal REST requests more easily.

Project description

Hand-craft your artisinal REST requests more easily.

Do you find yourself hand-crafting REST requests by opening up a python, ruby, or javascript repl, or hand-building a curl request? Do you find the process of remembering each service’s required headers, request format and authentication rules terribly tedious? This library is for you.

Benzo makes the process of building and iterating on common request types easy by providing a few features:

  • Templatized requests: Both generic (json, yaml, or form-encoded) and service-specific templatized requests make it really easy for you to define the content you’d like to send.

  • Simple and intuitive creating of requests. Your request’s contents and properties (like URL, request method, and headers) are displayed in your default editor, and you can add, alter, or remove paramters as you wish.

  • Separation of the API payload from the editor format. Although the API you’re interacting with might demand form-encoded, JSON, or yaml values, you can edit your request using a variety of formats, and benzo will convert it to the proper format when dispatching your request.

  • Saveable sessions. Do you ever build a request perfectly the first time? Me neither. Iterate quickly and easily on your request by using benzo’s sessions. If first you do not succeed, just re-run benzo in the same session, and the editor will be opened just as you last left it.

Installation

Install using pip:

pip install benzo

Usage

You can just run benzo, but the real power comes when using either sessions or one of the built-in templates.

Sessions

You can save a session for your request by using the --session=<path to file> command-line argument. When using a session, future requests using the same session file will continue with not only the same actual session (including any cookies the server you connected to previously sent down), but the editor when opened will show you exactly the request you made previously. This makes it very easy to iterate on a particularly tricky request.

Templates

You can use a request template by using the --template=<template name> command-line argument. Available templates include:

  • yaml, json, and form: These are just generic REST request templates that will build an API payload in the Yaml, JSON, or form-encoded formats, respectively.

  • urbanairship.push: This will provide you with a blank template you can use for dispatching a Push using Urban Airship’s API.

    • This template also allows for a few configuration settings in your ~/.benzo file’s [urbanairship] section:

      • app_key: The Urban Airship App Key to use by default for requests.

      • master_secret: The Urban Airship Master Secret to use by default for requests.

  • twilio.sms: This will provide you with a blank template you can use for dispatching an SMS notification via Twilio’s API.

    • This template allows for a few configuration settings in your ~/.benzo file’s [twilio] seciton:

      • account_sid: The Twilio Account SID to use by default for requests.

      • auth_token: The Twilio Auth Token to use by default for requests.

Editing your Request

Parameters

Request templates will generally contain a variety of parameters displayed at the top of your editor as comments. Parameters usually will include things like Method and URL, but individual templates may provide additional parameters. These parameters can be edited to alter your request’s behavior before being dispatched.

Headers

Request templates will usually contain a list of extra headers displayed near the top of your editor as comments starting with the proword [Header]. You can alter or add additional headers at-will; just make sure to keep the proword [Header] at the beginning of the line so benzo knows which lines to interpret as headers.

Cancelling

If you would like to abort making a request once your editor is opened, just delete all content from the file, save, and quit.

Configuration

You do not need to provide any special configuration details, but you can fine-tune the behavior of benzo by adding configuration settings to your ~/.benzo file’s [benzo] section.

  • default_editor_format: Which format would you like to use for building your API requests? I personally recommend setting this to yaml for more humane editing of API requests. Default: json.

  • default_template: If you do not specify a template to use, which template should be used for generating your request? Default: json.

Note that individual templates may define extra configuration settings; see Templates for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

benzo-0.1.0.tar.gz (8.3 kB view details)

Uploaded Source

File details

Details for the file benzo-0.1.0.tar.gz.

File metadata

  • Download URL: benzo-0.1.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for benzo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eee39e03ed04947265c2ee47aa9d737ea04224012adb56585418986afd66d174
MD5 e495924b4deeeba9ef682a51896caa9a
BLAKE2b-256 a2cc0332ce21a0514403fb90cf2021fe4a978ec2718e6cef61066ad32216e6a1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page