Skip to content

Conversation

@thrau
Copy link
Member

@thrau thrau commented Dec 17, 2025

Motivation

I've wanted better API clients for a while, where classes map to the actual APIs and their API concepts. These can then be used to implement higher-level abstractions like the DataSource class.

With #4 , it's now massively easier to develop and test this, so I went on a quest to implement the most important APIs.

The following APIs have been (partially) implemented, and can be accessed through Client.api:

  • /v0/datasources: client.api.datasources
  • /v0/events: client.api.events
  • /v0/pipes: client.api.pipes
  • /v0/tokens: client.api.tokens
  • /v0/variables: client.api.variables

Examples

For example, you can query a pipe using the pipes API:

from verdin import tinybird

client = tinybird.Client(...)

response = client.api.pipes.query(
    "my_pipe",
    parameters={"my_param": "..."},
    query="SELECT * FROM _ LIMIT 10",
)

for record in response.data:
    # each record is a dictionary
    ...

Or use the HFI endpoint to append data:

from verdin import tinybird

client = tinybird.Client(...)

response = client.api.events.send("my_datasource", records=[
    {"id": "...", "value": "..."},
    ...
])
assert response.quarantined_rows == 0

Changes

@thrau thrau marked this pull request as ready for review December 18, 2025 09:15
@thrau thrau merged commit ed4f1c8 into main Dec 18, 2025
5 checks passed
@thrau thrau mentioned this pull request Dec 18, 2025
# this limit is around 8kb, so if it's too large, we use a POST request instead.
qsize = 1 # include the "?" character
for k, v in params.items():
qsize += len(k) + len(v) + 2 # include the ``&`` and ``=`` character
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this seems to be a breaking change as you have changed the interface of the query method forcing parameters to be dict[str, str] while before it was less strict accepting dict[str, str | None] and now if params has a None value doing len(None) causes a runtime error.... Not sure if is more correct now or before 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! fixed in #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants