Skip to main content

Make http requests based on a CSV input file

Project description

csv2http

ci pypi version Code style: black

CLI tool and library for making a series of HTTP requests based on a CSV file input.

Quick start

Install

pip install csv2http

Check CLI usage

❯ csv2http --help
usage: csv2http [-h] [-c CONCURRENCY] [--method {POST,PATCH,PUT}] file url

HTTP request for every row of a CSV file

positional arguments:
  file                  payload csv file
  url                   URL destination - called with `http` if scheme is absent

options:
  -h, --help            show this help message and exit
  -c CONCURRENCY, --concurrency CONCURRENCY
                        Maximum number of concurrent requests (default: 25)
  --method {POST,PATCH,PUT}
                        HTTP method/verb (default: POST)

Mockbin Example

Make POST calls to http://mockbin.org from a local csv file.

First setup a new bin, using httpie, curl or the web ui and get a bin id.

❯ http POST mockbin.com/bin/create status:=201 statusText=Created httpVersion=HTTP/1.1 headers:='[]' cookies:='[]' 'content[mimeType]'=application/json --body
"9e95289e-d048-4515-9a61-07f2c74810f5"

Create your my_file.csv and pass it to csv2http. Use the returned bin id from before.

❯ csv2http my_file.csv mockbin.org/bin/9e95289e-d048-4515-9a61-07f2c74810f5 --concurrency 3
 POST http://mockbin.org/bin/mockbin.org/bin/9e95289e-d048-4515-9a61-07f2c74810f5
  status codes - {200: 3}
  status codes - {200: 3}
  status codes - {200: 3}
  status codes - {200: 1}

Check the bin log from. https://mockbin.org/bin/9e95289e-d048-4515-9a61-07f2c74810f5/log

Roadmap

  • As Library - Alpha
    • parse csv as dictionary/json - Alpha
    • accept mutator function - Alpha
    • HTTP POST request with json from csv - Alpha
    • limit concurrency - Alpha
    • non-blocking file IO - ???
    • hooks for response results - Beta
    • mkdoc docs - Beta
  • As CLI - Beta
    • argparse - Alpha
    • progress bar - ???
    • use dedicated CLI library (typer, rich etc.) - Beta
    • Nested fields - V1
  • Complete Docs - V1
    • create_mockbin.csv and example.csv to use in quickstart - Beta
    • examples for using as library
  • GH Actions CI (lint, test, etc.)
  • GH Actions CD (publish to pypi)

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

csv2http-0.0.0a0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

csv2http-0.0.0a0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file csv2http-0.0.0a0.tar.gz.

File metadata

  • Download URL: csv2http-0.0.0a0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.4 Darwin/21.5.0

File hashes

Hashes for csv2http-0.0.0a0.tar.gz
Algorithm Hash digest
SHA256 2fd7672b0d257b17e85885a115b4ac54e6d862359322782402121eb9874acc2c
MD5 4be27b7bc009509dfe877ea9388eeef9
BLAKE2b-256 cd646f36333cae83606cb6d347ba4400e99ec39402be7b1d1c6bd82ac18a1618

See more details on using hashes here.

File details

Details for the file csv2http-0.0.0a0-py3-none-any.whl.

File metadata

  • Download URL: csv2http-0.0.0a0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.4 Darwin/21.5.0

File hashes

Hashes for csv2http-0.0.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 872e69d3ad9a289fbd4a3f356df4d0ee32eeda65b3580433f6d6bb24af83def3
MD5 cc055ddfd2234fce2e890877c1653a40
BLAKE2b-256 244fafa8baeef3dc011b9cb9eb2a6a0458ab4252d7e26d82df0c379b978e6a87

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