Skip to main content

Papir is an acronym for “Python API Requests”.

The main purpose is to make custom http requests to json APIs, prettify and colorize the full response (headers + json content).

Json files are used to post, put, patch or delete and to customize the http headers.

Basic http authentication is supported.

Simple example:

$ papir httpbin.org/get
https://raw.githubusercontent.com/pdrb/papir/master/papir.png

Notes

  • Works on Python3.3+

  • Uses only Python standard library for maximum compatibility

  • Small and simple source code that can be read in a few minutes

Install

Install using pip:

pip install papir

or

Download and set executable permission on the script file:

chmod +x papir.py

or

Download and run using the python interpreter:

python3 papir.py

Usage

Usage: papir url [options] [method]

make http requests to json apis

Options:
--version        show program's version number and exit
-d DATA_FILE     json file to post, put, patch or delete
-h HEADERS_FILE  json file containing additional headers
-t TIMEOUT       timeout in seconds to wait for response (default: 10)
-a AUTH          basic http authentication in the format username:password
-f, --follow     follow redirects (default: disabled)
-v, --verbose    show request headers (default: disabled)

Examples

Assuming the file “data.json” exists containing:

{
    "name": "Bob",
    "age": 30
}

Make a post request using that data:

$ papir example.org -d data.json

To use a different http method just inform it:

$ papir example.org -d data.json put

To customize the request headers, create a json file like:

{
    "Auth-User": "user",
    "Auth-Token": "1234",
    "User-Agent": "myagent"
}

And add it to the request:

$ papir example.org -h headers.json

Obviously, you can mix it with all kinds of http methods:

$ papir example.org -h headers.json -d data.json patch

Simple basic auth:

$ papir example.org -a user:pass

Release files for papir 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for papir 0.1.0
File Size Uploaded
papir-0.1.0.tar.gz 4.9 kB Details

Release files / papir-0.1.0.tar.gz

Download URL papir-0.1.0.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0bcfbe88949d9810c0a599d5e1f58c1c80cc4921ab476130fa01a51805d6d996
BLAKE2b-256 checksum
How to use checksums
be3dc05c08640f2e1788a9d7c90b1cd9fbc46c09f8e0bd94de923ab8646dbe97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.9.1 pkginfo/1.4.1 requests/2.18.4 setuptools/33.1.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/2.7.14

Release history Release notifications | RSS feed

0.3.0

1 release file

0.2.0

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page