Skip to main content
Bumped by Community user
added 53 characters in body; edited title
Source Link

Need advices on How to pass arguments of a complex search in RESTful API request params

I’m building an app that lets users manage data across multiple tables. I also expose an API so they can fetch their data and process it in external services. I’d like to enhance the API to support filtered queries. Inside the app, I already have a fairly sophisticated system that converts logical conditions objects (a tree with many operators) into SQL queries. I’m now looking for a clean way to:

  • express filters in the API request, and
  • parse those filters into my internal condition object, which I then turn into SQL.

The challenge: complex queries are hard to pass via GET if I want to remain RESTful and I want to use GET in the end to cache my results. I’m considering two approaches:

  1. POST /tables/{table}/records/search with a complex body that defines the filter. This would create a “saved search” in my DB. Clients could then GET /tables/{table}/records/search/{id} to run it, which would first resolve the parameters and then execute the query.

  2. Use RSQL for a readable query syntax in the URL. The drawback is that, as far as I understand, RSQL is usually evaluated directly against the DB. In my case I’d still need to parse it and map fields/operators to my internal model so I am not sure that this is a proper solution to my problem.

I’m undecided between these two and not fully convinced by either. Do you have advice or alternative designs?

Also I then would like to be able to reverse the process (serialize my condition object into query params)

Need advices on complex search in RESTful API

I’m building an app that lets users manage data across multiple tables. I also expose an API so they can fetch their data and process it in external services. I’d like to enhance the API to support filtered queries. Inside the app, I already have a fairly sophisticated system that converts logical conditions objects (a tree with many operators) into SQL queries. I’m now looking for a clean way to:

  • express filters in the API request, and
  • parse those filters into my internal condition object, which I then turn into SQL.

The challenge: complex queries are hard to pass via GET if I want to remain RESTful. I’m considering two approaches:

  1. POST /tables/{table}/records/search with a complex body that defines the filter. This would create a “saved search” in my DB. Clients could then GET /tables/{table}/records/search/{id} to run it, which would first resolve the parameters and then execute the query.

  2. Use RSQL for a readable query syntax in the URL. The drawback is that, as far as I understand, RSQL is usually evaluated directly against the DB. In my case I’d still need to parse it and map fields/operators to my internal model so I am not sure that this is a proper solution to my problem.

I’m undecided between these two and not fully convinced by either. Do you have advice or alternative designs?

Also I then would like to be able to reverse the process (serialize my condition object into query params)

How to pass arguments of a complex search in RESTful API request params

I’m building an app that lets users manage data across multiple tables. I also expose an API so they can fetch their data and process it in external services. I’d like to enhance the API to support filtered queries. Inside the app, I already have a fairly sophisticated system that converts logical conditions objects (a tree with many operators) into SQL queries. I’m now looking for a clean way to:

  • express filters in the API request, and
  • parse those filters into my internal condition object, which I then turn into SQL.

The challenge: complex queries are hard to pass via GET if I want to remain RESTful and I want to use GET in the end to cache my results. I’m considering two approaches:

  1. POST /tables/{table}/records/search with a complex body that defines the filter. This would create a “saved search” in my DB. Clients could then GET /tables/{table}/records/search/{id} to run it, which would first resolve the parameters and then execute the query.

  2. Use RSQL for a readable query syntax in the URL. The drawback is that, as far as I understand, RSQL is usually evaluated directly against the DB. In my case I’d still need to parse it and map fields/operators to my internal model so I am not sure that this is a proper solution to my problem.

I’m undecided between these two and not fully convinced by either. Do you have advice or alternative designs?

Also I then would like to be able to reverse the process (serialize my condition object into query params)

Lists and inline code to highlight REST calls
Source Link
Greg Burghardt
  • 46.6k
  • 8
  • 87
  • 151

I’m building an app that lets users manage data across multiple tables. I also expose an API so they can fetch their data and process it in external services. I’d like to enhance the API to support filtered queries. Inside the app, I already have a fairly sophisticated system that converts logical conditions objects (a tree with many operators) into SQL queries. I’m now looking for a clean way to:

express filters in the API request, and parse those filters into my internal condition object, which I then turn into SQL.

  • express filters in the API request, and
  • parse those filters into my internal condition object, which I then turn into SQL.

The challenge: complex queries are hard to pass via GET if I want to remain RESTful. I’m considering two approaches:

POST /tables/{table}/records/search with a complex body that defines the filter. This would create a “saved search” in my DB. Clients could then GET /tables/{table}/records/search/{id} to run it, which would first resolve the parameters and then execute the query. Use RSQL for a readable query syntax in the URL. The drawback is that, as far as I understand, RSQL is usually evaluated directly against the DB. In my case I’d still need to parse it and map fields/operators to my internal model so I am not sure that this is a proper solution to my problem.

  1. POST /tables/{table}/records/search with a complex body that defines the filter. This would create a “saved search” in my DB. Clients could then GET /tables/{table}/records/search/{id} to run it, which would first resolve the parameters and then execute the query.

  2. Use RSQL for a readable query syntax in the URL. The drawback is that, as far as I understand, RSQL is usually evaluated directly against the DB. In my case I’d still need to parse it and map fields/operators to my internal model so I am not sure that this is a proper solution to my problem.

I’m undecided between these two and not fully convinced by either. Do you have advice or alternative designs?

Also I then would like to be able to reverse the process (serialize my condition object into query params)

I’m building an app that lets users manage data across multiple tables. I also expose an API so they can fetch their data and process it in external services. I’d like to enhance the API to support filtered queries. Inside the app, I already have a fairly sophisticated system that converts logical conditions objects (a tree with many operators) into SQL queries. I’m now looking for a clean way to:

express filters in the API request, and parse those filters into my internal condition object, which I then turn into SQL.

The challenge: complex queries are hard to pass via GET if I want to remain RESTful. I’m considering two approaches:

POST /tables/{table}/records/search with a complex body that defines the filter. This would create a “saved search” in my DB. Clients could then GET /tables/{table}/records/search/{id} to run it, which would first resolve the parameters and then execute the query. Use RSQL for a readable query syntax in the URL. The drawback is that, as far as I understand, RSQL is usually evaluated directly against the DB. In my case I’d still need to parse it and map fields/operators to my internal model so I am not sure that this is a proper solution to my problem.

I’m undecided between these two and not fully convinced by either. Do you have advice or alternative designs?

Also I then would like to be able to reverse the process (serialize my condition object into query params)

I’m building an app that lets users manage data across multiple tables. I also expose an API so they can fetch their data and process it in external services. I’d like to enhance the API to support filtered queries. Inside the app, I already have a fairly sophisticated system that converts logical conditions objects (a tree with many operators) into SQL queries. I’m now looking for a clean way to:

  • express filters in the API request, and
  • parse those filters into my internal condition object, which I then turn into SQL.

The challenge: complex queries are hard to pass via GET if I want to remain RESTful. I’m considering two approaches:

  1. POST /tables/{table}/records/search with a complex body that defines the filter. This would create a “saved search” in my DB. Clients could then GET /tables/{table}/records/search/{id} to run it, which would first resolve the parameters and then execute the query.

  2. Use RSQL for a readable query syntax in the URL. The drawback is that, as far as I understand, RSQL is usually evaluated directly against the DB. In my case I’d still need to parse it and map fields/operators to my internal model so I am not sure that this is a proper solution to my problem.

I’m undecided between these two and not fully convinced by either. Do you have advice or alternative designs?

Also I then would like to be able to reverse the process (serialize my condition object into query params)

Source Link

Need advices on complex search in RESTful API

I’m building an app that lets users manage data across multiple tables. I also expose an API so they can fetch their data and process it in external services. I’d like to enhance the API to support filtered queries. Inside the app, I already have a fairly sophisticated system that converts logical conditions objects (a tree with many operators) into SQL queries. I’m now looking for a clean way to:

express filters in the API request, and parse those filters into my internal condition object, which I then turn into SQL.

The challenge: complex queries are hard to pass via GET if I want to remain RESTful. I’m considering two approaches:

POST /tables/{table}/records/search with a complex body that defines the filter. This would create a “saved search” in my DB. Clients could then GET /tables/{table}/records/search/{id} to run it, which would first resolve the parameters and then execute the query. Use RSQL for a readable query syntax in the URL. The drawback is that, as far as I understand, RSQL is usually evaluated directly against the DB. In my case I’d still need to parse it and map fields/operators to my internal model so I am not sure that this is a proper solution to my problem.

I’m undecided between these two and not fully convinced by either. Do you have advice or alternative designs?

Also I then would like to be able to reverse the process (serialize my condition object into query params)