E
E
E2n2015-06-02 08:19:19
SQL
E2n, 2015-06-02 08:19:19

Are REST and passing multiple ids (WHERE IN queries) compatible?

I will describe a simple situation:
api/users - all users
api/users/5 - the fifth user
api/users/1,2,7,11,99 - select query by type where_in('user_id', $ids)
In the latter case, to to receive several users, it is enough for me to make only one request.
I would like to know if this approach has the right to life. Do I need to make 1 request or 5.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2015-06-02
@E2n

GET /api/users/ - all dudes
GET /api/users/?filter[id]=1,2,7,11,99 - filter for selecting all dudes
GET /api/users/5 - dude with ID 5
jsonapi .org

A
Arthur, 2015-06-02
@ArthurG

In fact, this is just data filtering, which is solved by query parameters:
/api/users?ids=1&ids=2&ids=7&…

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question