npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cncflora/iucn-redlist-api-wrapper

v0.0.4

Published

The iucn-redlist-api-wrapper is a TypeScript package that provides a convenient interface for interacting with the IUCN Redlist API. This package allows you to fetch data about taxa, including details by SIS ID, scientific name, and more.

Downloads

13

Readme

IUCN Redlist API Wrapper

Overview

The iucn-redlist-api-wrapper is a TypeScript package that provides a convenient interface for interacting with the IUCN Redlist API. This package allows you to fetch data about taxa, including details by SIS ID, scientific name, and more.

Installation

To install the package, use npm:

npm install iucn-redlist-api-wrapper

Usage

Setup

First, import the IUCNredlist class from the package:

import { IUCNredlist } from "iucn-redlist-api-wrapper";

Create an instance of the IUCNredlist class with your API token:

const api = new IUCNredlist({ token: "YOUR_API_TOKEN" });

Making Requests

You can use the taxa method to query various resources from the API. Below are some examples of how to use the package:

1. Query by SIS ID

Fetch data using a SIS ID:

const { taxon } = await api.get({
  resource: "taxa/sis",
  params: { sis_id: 172817975 },
});

2. Query by Scientific Name

Fetch data using scientific names:

const { taxon } = await api.get({
  resource: "taxa/scientific_name",
  params: {
    genus_name: "Aegis",
    species_name: "luteocontexta",
  },
});

3. Fetch Kingdom Names

Retrieve a list of kingdom names:

const { kingdom_names } = await api.get({
  resource: "taxa/kingdom",
});

4. Query Kingdom by Name

Fetch data for a specific kingdom:

const { assessments } = await api.get({
  resource: "taxa/kingdom",
  params: {
    kingdom_name: "ANIMALIA",
    page: 1,
    year_published: 2020,
  },
});

5. Query Family by Name

Fetch data for a specific family:

const { assessments } = await api.get({
  resource: "taxa/family",
  params: {
    family_name: "ACANTHACEAE",
    year_published: 2020,
  },
});

6. Biogeographical Realms

Fetch Biogeographical Realms:

const { biogeographical_realms } = await api.get({
  resource: "biogeographical_realms",
});

7. Assessment by ID

Fetch Assessment by ID:

const assessment = await api.get({
  resource: "assessment",
  params: {
    assessment_id: 172861292,
  },
});

Output Formatting

The IUCN Redlist API allows you to customize the format of the response by using the format parameter. This can be particularly useful when you want to process or save the data in different formats. Below are the supported options:

Format Options

1. CSV

By setting the format parameter to "CSV", the API response will be formatted as comma-separated values (CSV). This is useful when you intend to save the data directly to a CSV file for further processing or use in spreadsheet applications.

const { biogeographical_realms } = await api.get({
  resource: "biogeographical_realms",
  format: "CSV"
});

In this example, the response will be pre-formatted as CSV, making it easy to save the data to a file.

2. FLAT_JSON

he format parameter can also be set to "FLAT_JSON" to return the data in a flattened JSON structure. When using this option, all nested attributes will be concatenated using dots (.). This is helpful for simplifying nested data and using it in contexts where a flat structure is preferred.

const { biogeographical_realms } = await api.get({
  resource: "biogeographical_realms",
  format: "FLAT_JSON"
});

In this case, any nested attributes in the response will be flattened, and their keys will be joined with a dot (.).

3. JSON (Default)

If no format parameter is specified, the API response will default to a standard JSON structure. This is the default behavior and does not require explicit declaration. Nested attributes will be preserved in their original structure.

const { biogeographical_realms } = await api.get({
  resource: "biogeographical_realms"
});
 // or
const { biogeographical_realms } = await api.get({
  resource: "biogeographical_realms",
  format: "JSON"
});

In this case, the response will be returned as a standard JSON object without any additional formatting, exactly as provided by the API.

Resources and Parameters

All available resources and parameters for the IUCN Redlist API can be found in the official API documentation. For detailed information on how to use each endpoint and the parameters required, please refer to the following link:

API Documentation

Important Notice

This package is not an official product of the International Union for Conservation of Nature (IUCN). It is an independent wrapper designed to simplify interactions with the IUCN Red List API.

Even though you are using this package, it is crucial to give proper acknowledgment and citation to the IUCN Red List API. When using the API or any data obtained from it, please ensure to cite it correctly as follows:

Citation: IUCN 2024. IUCN Red List of Threatened Species. Version 2024-1 <www.iucnredlist.org>.