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

Support searching observations by observation fields #381

Closed
6 tasks done
Tracked by #230
JWCook opened this issue May 15, 2022 · 7 comments · Fixed by #473
Closed
6 tasks done
Tracked by #230

Support searching observations by observation fields #381

JWCook opened this issue May 15, 2022 · 7 comments · Fixed by #473
Labels
enhancement New feature or request
Milestone

Comments

@JWCook
Copy link
Member

JWCook commented May 15, 2022

There's an undocumented field:{field_name} param for observations searches, for example: https://www.inaturalist.org/observations?field:Species%20count=2

This can be applied to the following endpoints:

  • /observations
  • /observations/histogram
  • /observations/identifiers
  • /observations/observers
  • /observations/popular_field_values
  • /observations/species_counts
@JWCook JWCook added the enhancement New feature or request label May 15, 2022
@JWCook JWCook added this to the v0.18 milestone May 20, 2022
@JWCook JWCook modified the milestones: v0.18, v1.0 Feb 5, 2023
@willkuhn
Copy link
Contributor

willkuhn commented Mar 2, 2023

I'd love to be able to search on that undocumented field param, both on the observations and observations/species_counts endpoints. Though undocumented, this appears to work correctly through an API query:

It seems like an easy way to allows for querying this param (and potentially other undocumented params) would be to add a "dummy" param for get_observations(), get_observation_species_counts(), and the like that would pass a pre-formatted string like "field:Species%20count=2" directly to the request URL.

@JWCook
Copy link
Member Author

JWCook commented Mar 2, 2023

Sure, I'd be happy to add that. It looks like you can search for both a specific value, or just any observations containing a given field.

Usage could look something like this:

# Find observations that contain these fields
get_observations(observation_fields=['Species count', 'Elevation (m)'])

# Find observations that have these specific field values
get_observations(observation_fields={'Species count': 2})

@JWCook
Copy link
Member Author

JWCook commented Mar 2, 2023

If you have time, something that would be helpful is to test the other observation endpoints to see if any others allow searching by observation fields.

@willkuhn
Copy link
Contributor

willkuhn commented Mar 2, 2023

That's a much more elegant solution that the quick-and-dirty work around I envisioned. Wonderful!

Here's a check of other observation endpoints:

@JWCook
Copy link
Member Author

JWCook commented Mar 8, 2023

I have some changes for this tentatively working, but they still need docs and tests. I'll get that finished up within the next week or so.

@JWCook
Copy link
Member Author

JWCook commented Mar 19, 2023

@willkuhn Changes for this are in the latest pre-release build, if you'd like to give it a try.

@JWCook
Copy link
Member Author

JWCook commented May 29, 2023

@willkuhn FYI, I just realized this conflicts with the fields parameter in the v2 API (#155), so I renamed this parameter to observation_fields. I updated the examples above.

@JWCook JWCook closed this as completed May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants