How to search via API

Hello :wave:
I am new to baserow, i found that baserow has typically everything I need for a perfect db.
But I am stuck at a issue, maybe you can help.

So I am using API to get records of my db, I am using get all records with ease, Now I want to get only a specific record.

My db has three fields> Name, phone number and address.
I want to get only the specific record whose phone number is 12346789.

But the get a record api docs show that I can only get the specific record by {ROWID} but I want to get it by phone number.

GET https ://api.baserow.io/api/database/rows/table/43297
returns all records

GET https: //api.baserow.io/api/database/rows/table/43297/{row_id}
When I replace ROWID with 2 I get only the record whose default I’d is 2

GET https ://api.baserow.io/api/database/rows/table/43297/{row_id}/?user_field_names=true
How to customise this with the query get the record where phone number is 123456789

So, how to achieve that.
Thanks,

1 Like

Hi @Siddharth, welcome to the Baserow community!

You can use API filters for that. You need to use the listing endpoint and you need to add an additional filter query parameter (filter__{field}__{filter}) to filter the rows based on the phone number.

I’m not sure what you the field id of your phone number field, so I’ll add an example where you need to replace YOUR_FIELD_ID with your the field id of your phone number. It will respond with all the rows where the phone number contains 123456789.

GET https://api.baserow.io/api/database/rows/table/43297/?user_field_names=true&filter__field_YOUR_FIELD_ID__contains=123456789.

You can find your field is in the API docs here REST API documentation // Baserow.

https://api.baserow.io/api/database/rows/table/43297/?user_field_names=true&filter__field_field_236149__contains=9804057935

my passenger phone number field id is field_236149 which i replaced but still getting all 3 records, i shall be getting two.
here is the raw response

{
“count”: 3,
“next”: null,
“previous”: null,
“results”: [
{
“id”: 11,
“order”: “1.00000000000000000000”,
“Ride_id”: “4444”,
“Pickup”: “Somari Villa”,
“Dropoff”: “Kolkata Airport”,
“Passenger_phone_no”: “9804057935”,
“Driver_phone_no”: “9830883805”,
“Date_time”: “2022-01-15T13:35:49.579408Z”,
“amount”: “300”,
“Payment_method”: {
“id”: 31362,
“value”: “Wallet”,
“color”: “dark-blue”
},
“Trip_rating”: 5,
“Status”: “Driver marked complete”,
“Trip_type”: {
“id”: 31365,
“value”: “Fastforward”,
“color”: “green”
}
},
{
“id”: 12,
“order”: “2.00000000000000000000”,
“Ride_id”: “1111”,
“Pickup”: “rishra”,
“Dropoff”: “serampore”,
“Passenger_phone_no”: “9804057935”,
“Driver_phone_no”: “9830883805”,
“Date_time”: “2022-01-15T15:27:55.215760Z”,
“amount”: “100”,
“Payment_method”: {
“id”: 31360,
“value”: “Cash”,
“color”: “orange”
},
“Trip_rating”: 4,
“Status”: “Driver marked complete”,
“Trip_type”: {
“id”: 31369,
“value”: “Bid Ride”,
“color”: “orange”
}
},
{
“id”: 13,
“order”: “3.00000000000000000000”,
“Ride_id”: “2222”,
“Pickup”: “bally”,
“Dropoff”: “howrah”,
“Passenger_phone_no”: “8274999481”,
“Driver_phone_no”: “9830883805”,
“Date_time”: “2022-01-15T15:28:00.049554Z”,
“amount”: “250”,
“Payment_method”: {
“id”: 31361,
“value”: “DirectUPI”,
“color”: “dark-red”
},
“Trip_rating”: 5,
“Status”: “Driver marked complete”,
“Trip_type”: {
“id”: 31365,
“value”: “Fastforward”,
“color”: “green”
}
}
]
}

i have created a API key that can only read

3cudsI8qLJ8zX7qyp5j45TRRDYX51zvB

There is a minor change you need to make to your URL. You need to replace the field_field_236149 with field_236149. So, your URL should look like this: https://api.baserow.io/api/database/rows/table/43297/?user_field_names=true&filter__field_236149__contains=9804057935.

1 Like