Skip Navigation
Github - QuickApiClient: Create fully typed and declarative API clients easily
github.com GitHub - martinn/quickapiclient: Create fully typed declarative API clients quickly and easily.

Create fully typed declarative API clients quickly and easily. - martinn/quickapiclient

GitHub - martinn/quickapiclient: Create fully typed declarative API clients quickly and easily.

A library for creating fully typed and declarative API clients, quickly and easily.

What would an API client with this library look like?

For a single API endpoint over HTTP GET, it could look something like this:

``` from dataclasses import dataclass import quickapi

An example type that will be part of the API response

@dataclass class Fact: fact: str length: int

What the API response should look like

@dataclass class ResponseBody: current_page: int data: list[Fact]

Now we can define our API

class MyApi(quickapi.BaseApi[ResponseBody]): url = "https://catfact.ninja/facts" response_body = ResponseBody ```

And you would use it like this:

``` response = MyApi().execute()

That's it! Now response is fully typed (including IDE support) and conforms to our ResponseBody definition

assert isinstance(response.body, ResponseBody) assert isinstance(response.body.data[0], Fact) ```

It also supports attrs or pydantic (or dataclasses as above) for your model/type definitions, including validation and types/data conversion.

I have a lot more examples (e.g. POST requests, query string params, authentication, error handling, model validation and conversion, multiple API endpoints) on the repo's README.

I've shared this one here before but it's been a while and I've added a lot of features since.

Github repo: https://github.com/martinn/quickapiclient

0
I made a tool to aggregate git blame stats across any repo
github.com GitHub - martinn/repoblame: Aggregate git blame stats across any git repository. Find out top contributors by Lines of Code.

Aggregate git blame stats across any git repository. Find out top contributors by Lines of Code. - martinn/repoblame

GitHub - martinn/repoblame: Aggregate git blame stats across any git repository. Find out top contributors by Lines of Code.

I've always been curious about this. If I were to take a snapshot of a git repo at a particular point in time, who would be the top contributors by active lines of code? And then, what type of files have they contributed the most? So I built this little tool.

I've been wanting to learn rust for quite some time now and this was one of my first projects in it. It was a lot of fun!

It uses git under the hood to obtain the information and it's nothing fancy, but keen to hear what you think.

1
A library for creating fully typed declarative API clients quickly and easily
github.com GitHub - martinn/quickapiclient: Create fully typed declarative API clients quickly and easily.

Create fully typed declarative API clients quickly and easily. - martinn/quickapiclient

GitHub - martinn/quickapiclient: Create fully typed declarative API clients quickly and easily.

cross-posted from: https://programming.dev/post/13395352

> Would love to hear any suggestions, feedback or comments.

0
Python @lemmy.ml martinn @programming.dev
A library for creating fully typed declarative API clients quickly and easily
github.com GitHub - martinn/quickapiclient: A library for creating fully typed declarative API clients quickly and easily.

A library for creating fully typed declarative API clients quickly and easily. - martinn/quickapiclient

GitHub - martinn/quickapiclient: A library for creating fully typed declarative API clients quickly and easily.

cross-posted from: https://programming.dev/post/13395352

> Would love to hear any suggestions, feedback or comments.

0
A library for creating fully typed declarative API clients quickly and easily
github.com GitHub - martinn/quickapiclient: A library for creating fully typed declarative API clients quickly and easily.

A library for creating fully typed declarative API clients quickly and easily. - martinn/quickapiclient

GitHub - martinn/quickapiclient: A library for creating fully typed declarative API clients quickly and easily.

Would love to hear any suggestions, feedback or comments.

6
InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)MA
martinn @programming.dev
Posts 5
Comments 4