Back to Smartcitizen.me

API - Search for published devices

I’m trying to get a list of all public devices that are: a) near me and b) have published. Starting with the near query parameter works just fine and I get a list in order of proximity:

curl -k https://api.smartcitizen.me/v0/devices?near=32.7157,-117.1611

Now, I also only want to retrieve devices that have some data that can be retrieved. I’ll try adding a search string:

curl -k -g “https://api.smartcitizen.me/v0/devices?near=32.7157,-117.1611&q[state_eq]=has_published

Ok, that doesn’t work I’m getting devices returned with “never_published” as the state. Perhaps the q and brackets are not supposed to be in there and I should just request the “state_eq” parameter?

curl -k “https://api.smartcitizen.me/v0/devices?near=32.7157,-117.1611&state_eq=has_published

Still seeing “never_published”. Are multiple search parameters allowed in a single call? I’ve tried taking out near and just using the state search:

curl -k -g "https://api.smartcitizen.me/v0/devices?q[state_eq]=has_published"
curl -k “https://api.smartcitizen.me/v0/devices?state_eq=has_published

Neither of these work. Does the search allow searching by any field, or just specific fields? Or, am I doing something wrong with my endpoint/querystring? Or, is there something that needs to be addressed?

Cheers,
Dave

Hi Dave,

state wasn’t available as a filter, sorry we missed to detailed on the documentation.

We just fix it and now all your queries are be working fine!

Ex:

curl -g "https://api.smartcitizen.me/v0/devices?near=32.7157,-117.1611&q[state_eq]=has_published"

We will update the documentation soon but this are the available params for device:

id
owner_id
name
description
mac_address
created_at
updated_at
kit_id
geohash
last_recorded_at
uuid
state

Let me know if you have any other questions!

Thanks

Awesome, thanks! Any chance you may also be able to add tag search as well? So if I wanted to search for all online devices?

We have plans to add it on the future but for now I will suggest you just filter on the client side, we do this on smartcitizen.me for the Filters.

Take care about pagination http://developer.smartcitizen.me/#pagination

And remember all the platform at https://smartcitizen.me/kits/ is built just using the same API, all the methods are public.

Good luck!