ropensci / rredlist

IUCN Red List API Client

Home Page:https://docs.ropensci.org/rredlist

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't generate API token

marcelxelo opened this issue · comments

Hi there,

I'm trying to get the IUCN categories for some species. For that you need a key, which one should be able to generate here:
https://apiv3.iucnredlist.org/api/v3/token

Nonetheless, the link doesn't work, and therefore I cannot retrieve any kind of information form rredlist.

Cheers,
Marcel

It looks like the red list API is currently down, as you've identified. Unfortunately, I'm not affiliated with IUCN, so there's not much I can do on my end. Hopefully the issue will be resolved soon.

I reached out to the Red List team, and unfortunately, I received the following reply:

Thank you for your email and apologies for this issue. The API token request system is currently down. Unfortunately we don't have a timescale on when it might be possible to get it running again, and there is no other way to generate a token.

In case it helps in the meantime, GBIF looks like it has a recent (May 2023) snapshot of the IUCN Red List dataset -- including threat status: https://www.gbif.org/dataset/19491596-35ae-4a91-9a98-85cf505f1bd3

You might be able to sub in something from rgbif for now to cover some rredlist options -- e.g.:

iucn_check <- name_lookup("Echinus esculentus", datasetKey = "19491596-35ae-4a91-9a98-85cf505f1bd3")

iucn_check$data[,c("speciesKey", "scientificName", "threatStatuses")]

# # A tibble: 1 × 3
#    speciesKey   scientificName                      threatStatuses 
#         <int>   <chr>                               <chr>          
#  1  176596789   Echinus esculentus Linnaeus, 1758   NEAR_THREATENED

I also reached out to the Red List team last week, no response. Looks like the API route is dead for now with no outlook on a solution. Anyone have some ideas on other ways to get access to historical IUCN Red List dataset to look at changes over time?

maybe on CD (at least for older versions...)

I found a fairly simple way to access it. On the page they have several examples of the outputs. Just by copying the API of the example (visible in the url) it is possible to access the dataset.

Hi Everyone, I'm Simon and I'm the Conservation Informatics Manager at the IUCN. As you've rightly identified, we're having some issues with the v3 API at the moment - we had to turn off token generation while we work to understand a few technical issues with this aging system. We've ended up getting a little sidetracked with this work as we've been pulled away to work on the 2023-1 Red List update, so fixing the API token system has, unfortunately, fallen by the wayside. I apologise that this hasn't been communicated more clearly.

As @malmagrok points out you could, for now, use the example API token on the understanding that you are allowed to use IUCN Red List data as per the terms and conditions i.e. for non-commercial purposes

Now to the good news. We're actively working on a "next-gen" API (v4) and we hope to have a beta version ready in Q1 2024 (but this might spill over into early Q2 2024) @willgearty Would you be the best person to contact nearer release about updating rredlist with the new endpoints? We will be looking to deprecate the v3 API before the end of 2024.

Cheers!

Thanks for the information @simon-tarr, and it's great news that you're working on a new API. Yes, please reach out to me closer to the release so I can update rredlist!

Great! I'll be in touch soon.

It will be nice to have the iucn api functioning again!

Hello,
It can't generate a token on my side neither. And I don't see the examples mentioned by @malmagrok on the webpages. Is there any other solution?
Best

@mcauchoix the examples are here. For example, to get the count of species in the API, you could go here. That latter link has the example token that you can use, provided you are using it for non-commercial purposes as described above.

@simon-tarr Hi Simon, it appears that the API is still down?

Dear All, this is to let you know that you can now sign up for the new v4 API here: https://api.iucnredlist.org/users/sign_up

Note that the new API is still in beta so things may change from time to time until we're out of the beta phase. Also, to the best of my knowledge, none of the community R packages that query the v3 API have been updated to query the v4 API so, until this work can happen, you will have to develop your own methods for extracting data from the API e.g with httr2.

Good news!

My plan is to update the rredlist package before the end of the summer. Feel free to reply here with anything you see in the new API that you'd like to see included in the new version of the package!

Does the api support python? Error 401 using requests, forbidden. I can access it on the website but not in python.

I'm not sure why you're getting the 401 error @Andresmrv3 - the API is language agnostic as it's just a regular old OpenAPI spec API. Have you signed up to the new v4 API and provided your v4 token (displayed in your user area after signing up)

@simon-tarr Fixed. I was using bearer authorization, that was the problem. I can't wait to explore! Thank you so much!

Dear All, this is to let you know that you can now sign up for the new v4 API here: https://api.iucnredlist.org/users/sign_up./

Note that the new API is still in beta so things may change from time to time until we're out of the beta phase. Also, to the best of my knowledge, none of the community R packages that query the v3 API have been updated to query the v4 API so, until this work can happen, you will have to develop your own methods for extracting data from the API e.g with httr2.

This link does not work, as the package and the rest of all. It's a shame that accessing the information has become so difficult. So much research halted because we cannot access the information properly.

Dear All, this is to let you know that you can now sign up for the new v4 API here: https://api.iucnredlist.org/users/sign_up./
Note that the new API is still in beta so things may change from time to time until we're out of the beta phase. Also, to the best of my knowledge, none of the community R packages that query the v3 API have been updated to query the v4 API so, until this work can happen, you will have to develop your own methods for extracting data from the API e.g with httr2.

This link does not work, as the package and the rest of all. It's a shame that accessing the information has become so difficult. So much research halted because we cannot access the information properly.

Apologies, there was a typo in the URL - somehow a full stop crept into the end of the string. The correct link is https://api.iucnredlist.org/users/sign_up

Unfortunately the open source community hasn't had the time yet to update their packages to account for the new structure of the v4 API - until this happens, you won't be able to use rredlist (or other pkgs) to get data out of the v4 API. If your work is urgent, you may use the public v3 API token, as per my comment last december: #52 (comment). Alternatively, you can write your own methods to query and process the v4 API using, for example, httr2 and dplyr. This would be quite involved and perhaps not an ideal solution if you're on a tight deadline.

Remember, you can always download the data as CSVs from the Red List website. If you specify a query on the Advanced Search page, there's a "Download" button that will let you get the data as .csv files:

image

@simon-tarr Fixed. I was using bearer authorization, that was the problem. I can't wait to explore! Thank you so much!

What authorization method did you use instead of bearer authorization? I thought that was what you were supposed to use. I am using JavaScript/Node.Js for my queries, but when I enter my API key in my headers, I get the error: Unauthorized when I sent a request.

My plan is to update the rredlist package before the end of the summer. Feel free to reply here with anything you see in the new API that you'd like to see included in the new version of the package!

How can we help you!? I would really like to access the API, but maybe even with the API I may not find the data I need.

You can use the current version of rredlist by following the instructions in this comment: #52 (comment). Essentially, you can use the API key from the examples on the old API's website.

That is no longer possible unless I am doing it wrong. If you access the API, the default landing is v4, and the examples from v3 have been removed. Further, if using your KEY here , it is possible to retrieve some data in json, but the Request URL does not have a section on where to write down the KEY so the process can be automated. Right?

I'll take a look this upcoming week. If necessary , I can release a quick patch until the new full version is done.

The examples for v3 of the API are still hosted here: https://apiv3.iucnredlist.org/api/v3/docs.

You can take the API token from any of those examples and use that with rredlist.

I just confirmed that the rredlist package works just fine using v3 of the API and the API token from the examples on this page. Please open a separate issue if the current functionality of the package does not cover what you are looking for (e.g., #48, #55).

In case anyone else has trouble accessing the v3 API documentation at https://apiv3.iucnredlist.org/api/v3/docs, you might find this snapshot on the wayback machine useful: https://web.archive.org/web/20240330190522/https://apiv3.iucnredlist.org/api/v3/docs

I just confirmed that the rredlist package works just fine using v3 of the API and the API token from the examples on this page. Please open a separate issue if the current functionality of the package does not cover what you are looking for (e.g., #48, #55).

WX20240724-094725@2x
Hi @willgearty, I try to get the example API from the link at https://apiv3.iucnredlist.org/api/v3/docs, but when I open it, which is empty, and I also ask two friends to open, who stay at different country and city, it is same as the picture.

In case anyone else has trouble accessing the v3 API documentation at https://apiv3.iucnredlist.org/api/v3/docs, you might find this snapshot on the wayback machine useful: https://web.archive.org/web/20240330190522/https://apiv3.iucnredlist.org/api/v3/docs

It works, thanks for your sharing the good way

Excuse me, it's September 2024 and I'm trying to utilise the v3 version of the api, the rredlist version is 0.7.1, but R carries out the following error: Error in curl::curl_fetch_memory(x$url$url, handle = x$url$handle) :
Could not resolve host: apiv3.iucnredlist.org
Does this mean that the v3 version is completely shut down, even if I use the api from https://apiv3.iucnredlist.org/api/v3/docs.

Just tried testing the V3 API and it still seems to be working for me. Here's what I used:

# load package
library(rredlist)

# try accessing V3 API using example token provided in documentation
rl_habitats(
  "Fratercula arctica", 
  key = "9bb4facb6d23f48efbf424bb05c0c1ef1cf6f468393bc745d42179ac4aca5fee"
)

@nicholasZ16, maybe it was temporarily down when you tried using it?

Thanks @jeffreyhanson for looking into this! I'm guessing the API was indeed temporarily down when @nicholasZ16 tried using the package.

Also, FYI to everyone here, I'm planning to start work on the new version of rredlist this week. I will keep you all updated as that progresses (and I'll certainly be looking for beta testers in the near future).

No worries!

Awesome - thank you very much @willgearty!

Also, I'm happy to help out with beta testing.

I am also interested in beta testing as well.

I've made a new version of rredlist that accesses all of the endpoints of the new IUCN API 🎉. It is available on the api_v4 branch and can be installed using the remotes package:

remotes::install_github("ropensci/rredlist@api_v4")

Note that, while this new version has most of the functionality and documentation of the new API, it has not yet been thoroughly tested. If you find any issues (or have any requests), please report them in this pull request: #57.

I'll also note that, for anyone that hasn't tried out the new API yet, you'll notice that it has changed the focus from species to assessments. If you filter the assessments that are returned by most of the new functions by the "latest" column, I believe that should give you a list of unique species matching your query.

Thanks in advance for anyone that puts in time to test out the new version!

Brilliant - thank you very much @willgearty! I'll make some time to look at this on Friday.

could you please help me to find out what is the code to get the category of a list of species from excel? I have tried out several codes but I still get an error message, I keep gettig a message of "NA" for all the species.

Could you be more specific and provide a reproducible example? If you're looking for an API key, see the discussion above for details on API keys for both versions of the API.

Could you be more specific and provide a reproducible example? If you're looking for an API key, see the discussion above for details on API keys for both versions of the API.

thank you, the token was the problem, I could finally work it out using the example token from the web.