Skip to main content

A Python wrapper for accessing the Vadivelu API

Project description

A Python library for accessing the Vadivelu API.

Installation

Must have Python 3.7 or higher

pip install vadivelu

API Reference

vadivelu.get_available_formats(code)

Get the available formats for a HTTP code. The formats can be gif, jpg, or both.

Parameters

code: int

The HTTP code to use

Returns

Tuple[str, str] A tuple containing the avaiable formats

Raises

ValueError if the code provided is not supported by the API

pick_available_format(code, priority)

Pick a format (gif or jpg) that the API supports for a specific HTTP code.

Parameters

code: int

The HTTP code to use

priority: str

The format to pick in the case both gif and jpg are available, defaults to gif

Returns

str The chosen format (gif or jpg)

Raises

ValueError if the code provided is not supported by the API or if priority is not gif or jpg

get_media_url(code, media_format)

Get the media URL for the specified code in the specified format.

Parameters

code: int

The HTTP code to use

media_format: str

The media format to get (gif or jpg)

Returns

str Theurl for the media

Raises

ValueError media_format is not available for the given code, use pick_available_format to avoid this error

Example

import requests
import vadivelu

code = 404
url = vadivelu.get_media_url(code, vadivelu.pick_available_format(code, 'jpg'))

# save jpg to 404.jpg file
with open('404.jpg', 'wb') as f:
    f.write(requests.get(url).content)

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

vadivelu-1.0.0.tar.gz (3.7 kB view hashes)

Uploaded Source

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