Skip to content

Add search_occurrences() and get_occurrence() to WildbookClient - #18

Merged
CourtneyMarne merged 3 commits into
WildMeOrg:mainfrom
CourtneyMarne:add-occurrence-methods
Sep 29, 2026
Merged

CourtneyMarne merged 3 commits into
WildMeOrg:mainfrom
CourtneyMarne:add-occurrence-methods

Conversation

@CourtneyMarne

Copy link
Copy Markdown
Collaborator

The Wildbook v3 API exposes /api/v3/search/occurrence and /api/v3/occurrences/{id} but WildbookClient has no methods for them. Users who need occurrence data (survey type, group size estimates, transect fields, etc.) are currently forced to bypass the client and call client.session.post() directly.

This PR adds search_occurrences() and get_occurrence() using the same pattern as the existing encounter and individual methods — no new dependencies, minimal change.

Tested against GiraffeSpotter (giraffespotter.org). The occurrence search returns fields including sightingPlatform, fieldSurveyCode, numAdults, numJuveniles, numCalves, groupComposition, groupBehavior, transect fields, and comments — all of which appear in the Wildbook web export CSVs but are not available via the current client.

@vkirkl

vkirkl commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

Since Wildbook has migrated all of the user-facing bits to use "sighting" instead of "occurrence", I'm wondering if we should go with search_sightings() and get_sighting(). (Granted, it would also be good to alias the /api/v3/occurrences endpoint with /api/v3/sightings ...)

Let's also update the README to include the new methods.

@CourtneyMarne

Copy link
Copy Markdown
Collaborator Author

Thanks Kirk, I pushed a commit renaming to search_sightings()/get_sighting() and adding a README section -- ready for another look whenever you get a chance

@vkirkl

vkirkl commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Looking good Courtney!
One last thing: can you add a similar docstring note to get_sighting like you did for search_sighting? I like the heads-up that the underlying API uses occurrence.

The other thing we should do, but can save for another PR is add unit testing for these. I need to do that for encounters so we can do all at once. I'll start a branch for that once we merge this one.

Comment thread src/pywildbook/client.py
@CourtneyMarne

Copy link
Copy Markdown
Collaborator Author

Thanks Kirk - I added the same note to get_sighting (pushed). Sounds good on saving unit tests for a follow-up PR, especially if you're bundling encounters in with it. Let me know if this is good to merge as is.

@vkirkl vkirkl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@CourtneyMarne
CourtneyMarne merged commit 73a0d03 into WildMeOrg:main Sep 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants