Skip to main content

Human friendly HTTP client for RESTful APIs

Project description

resourceful

Human friendly HTTP client for RESTful APIs

Usage

>>> import resourceful
>>> solaire = resourceful.API(url='https://api.le-systeme-solaire.net/rest')
>>> bodies = solaire.resource('bodies')
>>> bodies.url
'https://api.le-systeme-solaire.net/rest/bodies'
>>> solaire.bodies.url
'https://api.le-systeme-solaire.net/rest/bodies'
>>> # Perform get on https://api.le-systeme-solaire.net/rest/bodies to get all /bodies
>>> rsp = bodies.get()
>>> rsp.status_code
200
>>> rsp.json()
{
  "bodies": [
    {
      "id": "lune",
      "name": "La Lune",
      "englishName": "Moon",
      "isPlanet": false,
      "moons": null,
      "semimajorAxis": 384400,
      "perihelion": 363300,
      "aphelion": 405500,
      "eccentricity": 0.0549,
      "inclination": 5.145,
      "mass": {
        "massValue": 7.346,
        "massExponent": 22
      },
      "vol": {
        "volValue": 2.1968,
        "volExponent": 10
      },
      "density": 3.344,
      "gravity": 1.62,
      "escape": 2380,
...
>>> # Get resource by ID
>>> rsp = bodies.get('lune')
>>> rsp.status_code
200
>>> rsp.json()
{'id': 'lune', 'name': 'La Lune', 'englishName': 'Moon', 'isPlanet': False, 'moons': None, 'semimajorAxis': 384400, 'perihelion': 363300, 'aphelion': 405500, 'eccentricity': 0.0549, 'inclination': 5.145, 'mass': {'massValue': 7.346, 'massExponent': 22}, 'vol': {'volValue': 2.1968, 'volExponent': 10}, 'density': 3.344, 'gravity': 1.62, 'escape': 2380.0, 'meanRadius': 1737.0, 'equaRadius': 1738.1, 'polarRadius': 1736.0, 'flattening': 0.0012, 'dimension': '', 'sideralOrbit': 27.3217, 'sideralRotation': 655.728, 'aroundPlanet': {'planet': 'terre', 'rel': 'https://api.le-systeme-solaire.net/rest/bodies/terre'}, 'discoveredBy': '', 'discoveryDate': '', 'alternativeName': '', 'axialTilt': 6.68, 'avgTemp': 0, 'mainAnomaly': 0, 'argPeriapsis': 0, 'longAscNode': 0, 'bodyType': 'Moon'}
>>> # Perform get on https://api.le-systeme-solaire.net/rest/bodies with query parameters
>>> rsp = bodies.get(params={'data': 'id,name,isPlanet', 'filter[]': 'isPlanet,eq,true'})
>>> rsp.status_code
200
>>> rsp.json()
{'bodies': [{'id': 'uranus', 'name': 'Uranus', 'isPlanet': True}, {'id': 'neptune', 'name': 'Neptune', 'isPlanet': True}, {'id': 'jupiter', 'name': 'Jupiter', 'isPlanet': True}, {'id': 'mars', 'name': 'Mars', 'isPlanet': True}, {'id': 'mercure', 'name': 'Mercure', 'isPlanet': True}, {'id': 'saturne', 'name': 'Saturne', 'isPlanet': True}, {'id': 'terre', 'name': 'La Terre', 'isPlanet': True}, {'id': 'venus', 'name': 'Vénus', 'isPlanet': True}]}

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

resourceful-0.1.4.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

resourceful-0.1.4-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file resourceful-0.1.4.tar.gz.

File metadata

  • Download URL: resourceful-0.1.4.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.8.10 Linux/5.15.0-48-generic

File hashes

Hashes for resourceful-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b4c8ede8e79231d2c9fe5638b59b325c5ac89722e87c024e12fd9b05856d360c
MD5 e22bdf3a7ac10ac61186a125cf48a466
BLAKE2b-256 bfb05f51f3a97d218a8593185a583177935d1b7159acf5f74fc013e8efcf704c

See more details on using hashes here.

File details

Details for the file resourceful-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: resourceful-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.8.10 Linux/5.15.0-48-generic

File hashes

Hashes for resourceful-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e91ca81d09069e40bc5347913bb17695951ffd9580c92e87647a9376a02cb8b8
MD5 01a85e7a5c67df78aaea7602a4f42a56
BLAKE2b-256 ba4ba04c878c7647ec8026ea77c08bf17eedb99f0d5632e939d639f102f5c518

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