Integrate IUCN Red List API: Add IUCN API endpoints, schema updates, and documentation for fetching species conservation status.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: e931b5ab-041b-42e7-baf1-50017869cef6
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/e19c6a51-7e4c-4bb8-a6a6-46dc00f0ec99/339e2da6-2d1a-4412-8be5-d5f8e250ffde.jpg
This commit is contained in:
Magnus-SmariSma
2025-03-20 22:19:01 +00:00
parent 478c353d03
commit 093e8788da
3 changed files with 180 additions and 0 deletions

View File

@ -0,0 +1,165 @@
To gather detailed information about species by connecting to multiple APIs, follow these steps:
## Step 1: Connect to GBIF API for Taxonomic and Occurrence Data
1. **Install pygbif**: Use Python to install the `pygbif` library, which simplifies interactions with the GBIF API.
```bash
pip install pygbif
```
2. **Fetch Species Data**: Use the `species.name_lookup()` function to retrieve taxonomic information.
```python
from pygbif import species
# Example: Fetch data for 'Helianthus annuus'
data = species.name_lookup(q='Helianthus annuus', rank="species")
print(data)
```
## Step 2: Connect to Wikidata Query Service for Biological Attributes
1. **Access Wikidata Query Service**: Use the SPARQL endpoint at `https://query.wikidata.org/sparql`.
2. **Query for Biological Attributes**: Use SPARQL to fetch attributes like lifespan or population.
```sparql
# Example query to get lifespan of a species
PREFIX wdt:
PREFIX wd:
SELECT ?item ?itemLabel ?lifespan
WHERE {
?item wdt:P31 wd:Q15978631; # Species
wdt:P2114 ?lifespan. # Lifespan
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
```
## Step 3: Connect to IUCN Red List API for Conservation Status
1. **Obtain an API Key**: Register at the IUCN Red List to get an API token.
2. **Fetch Conservation Status**: Use the `iucnredlist` R package or the IUCN API directly.
```r
# R example using iucnredlist package
library(iucnredlist)
api <- init_api("your_api_key")
assessment_raw <- assessment_data(api, 266696959)
assessment <- parse_assessment_data(assessment_raw)
print(assessment)
```
## Step 4: Connect to Swedish Biodiversity Data Infrastructure (SBDI) Bioatlas
1. **Access SBDI Bioatlas**: Use the SBDI guides to access regional biodiversity data.
2. **Fetch Regional Data**: Follow the step-by-step guides for using the Bioatlas APIs.
## Step 5: Combine Data
1. **Integrate Datasets**: Use programming languages like Python or R to merge data from different APIs based on species identifiers.
2. **Analyze and Visualize**: Use libraries like Pandas, NumPy, and Matplotlib (Python) or dplyr and ggplot2 (R) to analyze and visualize the combined data.
### Example Integration in Python
```python
import pandas as pd
from pygbif import species
# Fetch GBIF data
gbif_data = species.name_lookup(q='Helianthus annuus', rank="species")
# Fetch Wikidata data using SPARQL (example query above)
# For simplicity, assume you have a function to execute SPARQL queries
wikidata_data = execute_sparql_query(query)
# Fetch IUCN data (example using a hypothetical IUCN API function)
iucn_data = fetch_iucn_data(species_id)
# Combine data into a single DataFrame
combined_data = pd.DataFrame({
'GBIF': gbif_data,
'Wikidata': wikidata_data,
'IUCN': iucn_data
})
# Print combined data
print(combined_data)
```
This approach allows you to gather comprehensive information about species by leveraging multiple APIs.
Citations:
[1] https://pygbif.readthedocs.io/en/latest/modules/species.html
[2] https://techdocs.gbif.org/en/openapi/v1/species
[3] https://en.wikibooks.org/wiki/SPARQL/Wikidata_Query_Service
[4] https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/A_gentle_introduction_to_the_Wikidata_Query_Service
[5] https://iucn-uk.github.io/iucnredlist/
[6] https://publicapi.dev/iucn-api
[7] https://docs.biodiversitydata.se/tutorials/step-by-step-help-guides/
[8] https://biodiversitydata.se/explore-analyze/use-your-own-tools/our-apis/
[9] https://data-blog.gbif.org/post/gbif-api-beginners-guide/
[10] https://rdrr.io/github/bioatlas/SBDI4R/src/R/search_guids.R
[11] https://github.com/ManonGros/Small-scripts-using-GBIF-API
[12] https://www.youtube.com/watch?v=2h9LNS8C764
[13] https://www.nies.go.jp/biowm/en/GBIFSpecies/
[14] https://gbif.github.io/dwc-api/apidocs/org/gbif/dwc/terms/GbifTerm.html
[15] https://phylonext.github.io/inputdata/
[16] https://github.com/gbif/gbif-api/issues/82
[17] https://peerj.com/preprints/3304v1.pdf
[18] https://www.youtube.com/watch?v=netnQb-6F0M
[19] https://github.com/NaturalHistoryMuseum/gbif-name-resolution
[20] https://fairsharing.org/FAIRsharing.zv11j3
[21] https://www.youtube.com/watch?v=TXdjxnjCvng
[22] https://stackoverflow.com/questions/39773812/how-to-query-for-people-using-wikidata-and-sparql
[23] https://query.wikidata.org
[24] https://www.youtube.com/watch?v=B59vEET-nEk
[25] https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/Wikidata_Query_Help
[26] https://librarycarpentry.github.io/lc-wikidata/05-intro_to_querying.html
[27] https://stackoverflow.com/questions/45316749/how-to-create-a-local-wikidata-query-service
[28] https://wikidataworkshop.github.io/2022/papers/Wikidata_Workshop_2022_paper_2349.pdf
[29] https://addshore.com/2019/10/your-own-wikidata-query-service-with-no-limits/
[30] https://apiv3.iucnredlist.org
[31] https://api.iucnredlist.org/api-docs/index.html
[32] https://github.com/ropensci/rredlist
[33] https://cran.r-project.org/web/packages/rredlist/vignettes/rredlist.html
[34] https://pypi.org/project/IUCN-API/
[35] https://apiv3.iucnredlist.org/api/v3/docs
[36] https://api.iucnredlist.org
[37] https://github.com/ropensci/rredlist/issues/52
[38] https://github.com/biodiversitydata-se/repo-overview
[39] https://www.biodiversa.eu/wp-content/uploads/2024/01/Biodiversa-Governance-Sub-pilot-Sweden.pdf
[40] https://community.atlassian.com/t5/Atlassian-Home-questions/Can-we-interact-with-Atlas-API/qaq-p/2427472
[41] https://biodiversitydata-se.github.io/r-tools-tutorial/
[42] https://github.com/biodiversitydata-se/documentation-overview
[43] https://docs.beyondtrust.com/entitle/docs/configuring-mongodb-atlas-api-key
[44] https://docs.biodiversitydata.se/analyse-data/
[45] https://www.frontiersin.org/journals/molecular-biosciences/articles/10.3389/fmolb.2022.926623/full
[46] https://github.com/bioatlas/r-functionality/
[47] https://chemrxiv.org/engage/api-gateway/chemrxiv/assets/orp/resource/item/6540eb2548dad23120c52242/original/the-hitchhiker-s-guide-to-statistical-analysis-of-feature-based-molecular-networks-from-non-targeted-metabolomics-data.pdf
[48] https://rdrr.io/github/bioatlas/SBDI4R/man/sbdi_lists.html
[49] https://royalsocietypublishing.org/doi/10.1098/rspb.2002.2218
[50] https://docs.ropensci.org/rgbif/articles/gbif_sql_downloads.html
[51] https://github.com/ManonGros/Small-scripts-using-GBIF-API/blob/master/query_species_list/functions_query_from_species_list.py
[52] https://techdocs.gbif.org/en/openapi/
[53] https://aubreymoore.github.io/blog/posts/using-the-species-api-to-mine-the-gbif-backbone-taxonomy/
[54] https://tutorials.inbo.be/tutorials/r_gbif_checklist/
[55] https://metacpan.org/dist/App-wdq/view/script/wdq
[56] https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual/ru
[57] https://www.mediawiki.org/wiki/Wikidata_Query_Service/User_Manual
[58] https://wikitech.wikimedia.org/wiki/Wikidata_Query_Service
[59] https://flograttarola.com/post/rbiodiversidata/
[60] https://publicapis.io/iucn-species-database-api
[61] https://cran.r-project.org/web/packages/rredlist/rredlist.pdf
[62] https://github.com/CerrenRichards/IUCN-Threats
[63] https://git-og.github.io/EasyOpenRedList/
[64] https://www.youtube.com/watch?v=4T6GXtptmj4
[65] https://academic.oup.com/nargab/article/5/1/lqad003/6997971
[66] https://docs.biodiversitydata.se/tutorials/step-by-step-help-guides/setting-up-and-using-your-sbdi-bioatlas-account/
[67] https://apidocs.tbauctions.com/getting-started
[68] https://biodiversitydata-se.github.io/mol-data/
[69] https://www.biorxiv.org/content/10.1101/2022.08.29.505468.full
---
Answer from Perplexity: pplx.ai/share

View File

@ -8,6 +8,15 @@ export const CITES_API_ENDPOINTS = {
REFERENCES: "references"
};
export const IUCN_API_ENDPOINTS = {
BASE_URL: "https://apiv3.iucnredlist.org/api/v3",
SPECIES: "species",
SPECIES_BY_NAME: "species/name",
THREATS: "threats/species/name",
CONSERVATION_MEASURES: "measures/species/name",
HABITATS: "habitats/species/name"
};
// API types
export interface ApiResponse<T> {
success: boolean;

View File

@ -15,6 +15,9 @@ export const species = pgTable("species", {
genus: text("genus"),
citesListings: jsonb("cites_listings"),
citesId: integer("cites_id"),
iucnStatus: text("iucn_status"),
iucnId: text("iucn_id"),
iucnData: jsonb("iucn_data"),
apiData: jsonb("api_data"),
searchedAt: timestamp("searched_at").defaultNow(),
});
@ -31,6 +34,9 @@ export const insertSpeciesSchema = createInsertSchema(species).pick({
genus: true,
citesListings: true,
citesId: true,
iucnStatus: true,
iucnId: true,
iucnData: true,
apiData: true,
});