Skip to main content

Python async OpenAPI client library

Project description

Lapidary

test

Python DSL for Web API clients.

http://lapidary.dev/

Why

DRY. Web API clients follow a relatively small set of patterns and writing them is rather repetitive task. Encoding these patterns in form of a DSL library frees its users from implementing the same patterns over and over again.

How

Lapidary is an internal DSL made of decorators and annotations, that can be used to describe Web APIs similarly to OpenAPI (lapidary-render can convert a large subset of OpenAPI 3.0 to Lapidary).

At runtime, the library interprets user-provided function declarations (without bodies), and makes them behave as declared. If a function accepts parameter of type X and returns Y, Lapidary will try to convert X to HTTP request and the response to Y.

Example:

class CatClient(ClientBase):
    """This class is a working API client"""

    def __init__(self):
        super().__init__(
            base_url='https://example.com/api',
        )

    @get('/cat')
    async def list_cats(self: Self) -> Annotated[
        tuple[list[Cat], CatListMeta],
        Responses({
            '2XX': Response(
                Body({
                    'application/json': list[Cat],
                }),
                CatListMeta
            ),
        })
    ]:
       pass

client = CatClient()
cats_body, cats_meta = await client.list_cats()

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

lapidary-0.12.3.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

lapidary-0.12.3-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file lapidary-0.12.3.tar.gz.

File metadata

  • Download URL: lapidary-0.12.3.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: poetry/1.8.5 CPython/3.12.9 Linux/6.8.0-1021-azure

File hashes

Hashes for lapidary-0.12.3.tar.gz
Algorithm Hash digest
SHA256 70cbb32f2c55adcf7f0d7b6ca3b6b0a9e1414aa18caf887bc6631a11b69bec9f
MD5 0ec970929d1d012ad228b4302c756b9d
BLAKE2b-256 bf06e795c72392cc09528cd581373fc5a12e259e9efdc81ee2705ac6adcfa5a3

See more details on using hashes here.

File details

Details for the file lapidary-0.12.3-py3-none-any.whl.

File metadata

  • Download URL: lapidary-0.12.3-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: poetry/1.8.5 CPython/3.12.9 Linux/6.8.0-1021-azure

File hashes

Hashes for lapidary-0.12.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a54a2faa64fa4c5afde3de2388d1bee706071764327b33029b6a5804ed414abd
MD5 bc54a814151ca38345eda23fd91964a5
BLAKE2b-256 c509d33ee7b388e10d8dc37c49e5f63962256f3eaf06ef1a761ccbde89a29876

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