-
Notifications
You must be signed in to change notification settings - Fork 15
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
Feature request: Possibility to fetch observations with obscured coordinates #403
Comments
This is an interesting one. Most API searches (by user, taxon, etc.) will return observations with obscured or private coordinates, unless you exclude them by passing I think the main issue is that the project is limited by location:
I am only able to see 183 observations on that project (but I am guessing it shows 192 for you, if you're logged in): And observation 112079159 doesn't show any associated projects for me: Same in the API results: from pyinaturalist import get_observations
obs = get_observations(id=112079159)
print(obs['results'][0]['project_ids'])
[] The reason you can see those observations in the CSV from the export tool is because you're logged in on inaturalist.org, so I think you will need to use an access token to see the same results from the API. Also, I found some related forum threads here: |
By the way, you can manually test an authenticated API request by getting a token here: https://www.inaturalist.org/users/api_token And passing it via from pyinaturalist import get_observations
obs = get_observations(project_id=130644, access_token='eyjHA6OjE2...') Or just open an API request URL in your browser: https://api.inaturalist.org/v1/observations?project_id=130644 |
@oolonek Did that answer your question? |
Hi @JWCook ! Thanks for the detailed explanations. This all makes sense. However I just tested now with the authenticated API token and still get 183 entries (instead of the expected 192). |
By the way, the API request url (https://api.inaturalist.org/v1/observations?project_id=130644) also returns 183 entries only.
|
Ohhh ! My bad it is working through the get_observations() with the authenticated API token Thanks @JWCook all set up on my side ! |
@JWCook could you tell me why this is not working as I expected? def pyinat_auth_test():
from importlib.metadata import version
print(version('pyinaturalist'))
# I prefer to get the token inside my own application:
token = get_access_token(
username='usus', password='papa',
app_id='aiai', app_secret='asas'
)
print("you got a {} characters length code".format(len(token)))
# now I pass it and request one of my own obscured observations
obs = get_observations(id=xxxxxx, access_token=token)
print(obs.get("taxon").get("name"),
obs.get("geojson"),
obs.get("geoprivacy"),
obs.get("private_geojson"))
if __name__ == "__main__":
import sys
from pyinaturalist import *
pyinat_auth_test() output:
Thanks a lot in advance EDIT: New output:
|
BTW, I think both |
@abubelinha You're right, thanks for pointing that out. I'll get that updated. |
Thanks @JWCook That might help to explain why I am failing to get a valid token using the python code in this gist. That gist gives me a 43 characters token as well. But when I try to use it in another request, it doesn't return me the obscured coordinates. So I guess it is not a correct token. I know this is not a pyinaturalist issue, but perhaps you could you give me a clue of what is failing? |
It's a different token format. In 0.17 I switched the default format to JWT, which according to iNat is now the preferred method: https://www.inaturalist.org/pages/api+recommended+practices As far as I know, OAuth tokens (the 43-character ones) should still be working with the V1 API, so I'm not sure what's wrong in your example. If you want to try out JWT, just add another request to your example after line 22: response = requests.get(
'https://www.inaturalist.org/users/api_token',
headers={'Authorization': f'Bearer {token}'},
)
token = response.json()['api_token'] That token then goes in your If that doesn't help, go ahead and create another issue and I can help look into it some more. |
Thank you very much for this advice 😃 👍 👍 👍 !! I upgraded my gist and I can confirm it now works in my old Python 3.4 machine. BTW I can also confirm that in Python 3.8, setting pyinaturalist 0.17.4 |
Feature description
In some case observation can have obscured coordinates (for ex. when the species is endangered). It would be nice to still be able to fetch all remaining information except the precise geolocation, without authenticating.
Use case
I need to fetch all observation from a project but I can't because some have their geolocation obscured by iNaturalist. Only "The person who made the observation, Individuals who the observer has trusted with their hidden coordinates and Curators of the projects" can fetch it.
Workarounds
The text was updated successfully, but these errors were encountered: