ropensci / rfisheries

package for interacting with fisheries databases at openfisheries.org

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Getting 404 error for some species

CottonRockwood opened this issue · comments

It looks like there is still an issue with the Openfisheries database/API. For some species codes, I'm getting a 404 error from of_landings. For example:

sp_to_get$a3_code[c(1,10, 11, 13)]
[1] "GGG" "OPL" "DUF" "LLE"
of_landings("OPL")
Error in of_landings("OPL") : client error: (404) Not Found
of_landings("DUF")
Error in of_landings("DUF") : client error: (404) Not Found
of_landings("LLE")
Error in of_landings("LLE") : client error: (404) Not Found

Perhaps these are the species with no landings data?

I believe that these are species codes with no landings data. I think there are three ways to address this: 1. Remove species codes with zero landings from species.json in the api. 2. Handle 404 better in the api. 3. Handle 404 differently in the rfisheries package.

I'm not a huge fan of option #1 as that data for other species could be useful to some people. I think that the solution would be in a combination of 2&3.

@andrewjdyck Serving empty strings instead of a 404 would be ideal (I believe that's how it worked before).

If indeed these are all species with no landings, then returning an empty string seems like a good solution.

Looks like none of my examples are listed in the FAO Global Catch statistics, so it looks like the conjecture that they are species with no landings is probably correct.

After a bit more research, I'm thinking that the best solution for the time being will be to update the species json file so that only those with landings are included. I'll open a few issues under the openfisheries project to highlight the development plan for adding a separate section of the api for species info, including those without landings.

I'll also highlight that the preferred method for serving null info from the API will be to serve a null string, however, I think this is lower priority at the moment. I'm hosting the API on github right now and it appears non-trivial to implement this way. Other github based apis such as the UNDP serve 404.html for improperly formatted API queries. I'd rather focus my energy on some other enhancements over serving empty strings.

Also, @CottonRockwood, I suspect that you might be interested in checking out the openfisheries project to find the raw CSV data I use for the API. There are some R utilities in there for massaging the data into a more useful format as well if you are looking at getting something out of the API that doesn't currently exist. Of course, I'd love to incorporate any additions/improvements to the openfisheries project if you have them. Please, feel free to e-mail me directly if you are interested.

Thanks, Andrew. I'll check out the openfisheries csv and your R utilities.