Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queries as an API #164

Open
poundifdef opened this issue Apr 17, 2024 · 0 comments · May be fixed by #165
Open

Queries as an API #164

poundifdef opened this issue Apr 17, 2024 · 0 comments · May be fixed by #165

Comments

@poundifdef
Copy link
Contributor

We want to launch a feature where users can create RESTful endpoints based on queries. This is an enhancement of "saved queries".

I have started this work in a branch: https://github.com/scratchdata/scratchdata/pull/163/files

This is roughly how I propose building it:

  • Rename "Shared Query" to "Saved Query"
    • These queries can either be public, meaning they can be used as public share links
    • Or they can be private, meaning they require an API key to query
  • Queries should accept named parameters. For example: SELECT * FROM events WHERE user = @user
    • These will be passed as query parms: GET /user_events?user=alice
  • We should be able to create API keys which only have access to these queries (and not access to any other endpoints)
  • When we create an API key, we should be able to set default parameters that cannot be overridden
    • For example, create an API key api_key_1 with the user parameter set to alice.
    • In this case, the person making the query does not need to specify a ?user=alice. If they do, then the parameter will be overwritten by the default
  • Ideally, an API key could be granted access to multiple endpoints.

Finally, there should be a UI for creating these queries.

If we have time:

  • It would be awesome to be able to create models (protobuf or openapi)
    • We can either use EXPLAIN statements or DESCRIBE (select * from events where user = @user) to get the output type.
  • Auto-generate documentation (just the basics)
@breadchris breadchris linked a pull request Apr 17, 2024 that will close this issue
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 a pull request may close this issue.

1 participant