Skip to main content

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

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.json_request(method="get", path="items", params={"id": 123})
print(result)

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.4.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

therapi-0.0.4-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file therapi-0.0.4.tar.gz.

File metadata

  • Download URL: therapi-0.0.4.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.1 Linux/6.2.6-76060206-generic

File hashes

Hashes for therapi-0.0.4.tar.gz
Algorithm Hash digest
SHA256 cc8ad0587d47dd1a7fc242b06f18a9dc23abbc375f7a622d9a844539f2999095
MD5 32e585041853bcd5291d4a43131105a8
BLAKE2b-256 09c575b8f118101d64637f03596e6d398c043260ae87365143131e7541286a63

See more details on using hashes here.

File details

Details for the file therapi-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: therapi-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.11.1 Linux/6.2.6-76060206-generic

File hashes

Hashes for therapi-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cfcc20766fd1d8a27d30d0c59651573795793162e852e0fa273bb131e151bbd1
MD5 13829b077df5d18f9de3b7fb47f89d7d
BLAKE2b-256 f5e282115d2ade5d97934ba9430b8176341da2893fc6293c90e4b23c6ebb747d

See more details on using hashes here.

Supported by

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