Skip to main content

Therapy to ease the pain of writing boilerplate code to consume JSON APIs.

Project description

python-therapi

Therapy to ease the pain of writing boilerplate JSON API consumers.


Tired of writing the same code to consume JSON APIs, over and over? Let's solve that!

Query a basic, public JSON API

To query any basic, public JSON API, we create our consumer class and inherit from BaseAPIConsumer, as follows:

from therapi import BaseAPIConsumer

class MyAPIConsumer(BaseAPIConsumer):
    base_url = "https://www.an-awesome-service.com/api"

Now we can use this class to make API calls to different endpoints, as follows:

consumer = MyAPIConsumer()
result = consumer.base_request(method="get", path="items")
print(result.json())

We would see, for example, this response:

{
  "data": [
    {"name": "Laptop", "price": 239},
    {"name": "Printer", "price": 99}
  ]
}

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

therapi-0.0.2.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

therapi-0.0.2-py3-none-any.whl (2.6 kB view hashes)

Uploaded Python 3

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