Skip to main content

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()

Metadata

Release files for lapidary 0.12.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lapidary 0.12.3
File Size Uploaded
lapidary-0.12.3.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lapidary 0.12.3
File Interpreter ABI Platform
lapidary-0.12.3-py3-none-any.whl Python 3 none any Details

Total release size: 37.0 kB

Release files / lapidary-0.12.3.tar.gz

Download URL lapidary-0.12.3.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
70cbb32f2c55adcf7f0d7b6ca3b6b0a9e1414aa18caf887bc6631a11b69bec9f
BLAKE2b-256 checksum
How to use checksums
bf06e795c72392cc09528cd581373fc5a12e259e9efdc81ee2705ac6adcfa5a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via poetry/1.8.5 CPython/3.12.9 Linux/6.8.0-1021-azure

Release files / lapidary-0.12.3-py3-none-any.whl

Download URL lapidary-0.12.3-py3-none-any.whl
Size 21.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a54a2faa64fa4c5afde3de2388d1bee706071764327b33029b6a5804ed414abd
BLAKE2b-256 checksum
How to use checksums
c509d33ee7b388e10d8dc37c49e5f63962256f3eaf06ef1a761ccbde89a29876
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via poetry/1.8.5 CPython/3.12.9 Linux/6.8.0-1021-azure

Release history Release notifications | RSS feed

This release

0.12.3 This release

2 release files

0.12.2

2 release files

0.12.1

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page