CHAPTER 5

Phase 2 - API Interface

Building on the standardized data formats established in Phase 1, Phase 2 provides computational services and APIs that make biodiversity data actionable. This chapter details the RESTful and GraphQL APIs, diversity calculation engines, integration services, and real-time analytics capabilities that transform raw observations into meaningful conservation insights.

API Architecture

The WIA API follows modern REST principles while offering GraphQL for complex queries. This dual approach balances simplicity for basic operations with power for advanced use cases.

RESTful Endpoints

The REST API organizes resources hierarchically and uses standard HTTP methods:

Base URL: https://api.biodiversity.wia.org/v1/

# Occurrence endpoints
GET    /occurrences                    # List occurrences (paginated)
POST   /occurrences                    # Create new occurrence
GET    /occurrences/{id}              # Get specific occurrence
PUT    /occurrences/{id}              # Update occurrence
DELETE /occurrences/{id}              # Delete occurrence

# Diversity indices
POST   /indices/calculate              # Calculate diversity indices
GET    /indices/{calculation_id}       # Retrieve calculated indices
GET    /indices/trends                 # Temporal trend analysis

# Species endpoints
GET    /species                        # List species
GET    /species/{taxon_id}            # Get species details
GET    /species/{taxon_id}/occurrences # Occurrences for species
GET    /species/search?q={query}      # Search species

# Spatial queries
GET    /spatial/region/{polygon}       # Occurrences in polygon
GET    /spatial/proximity              # Species near coordinates
POST   /spatial/hotspots              # Identify biodiversity hotspots

# Data validation
POST   /validate/occurrence            # Validate occurrence data
POST   /validate/batch                # Batch validation

# Integration
POST   /export/gbif                    # Export to GBIF format
POST   /export/geojson                # Export as GeoJSON
GET    /taxonomy/resolve              # Resolve taxonomic names

Authentication and Authorization

The API uses OAuth 2.0 with JWT tokens for secure, stateless authentication:

# Obtain access token
POST https://auth.biodiversity.wia.org/oauth/token
Content-Type: application/json

{
  "grant_type": "client_credentials",
  "client_id": "your_client_id",
  "client_secret": "your_client_secret",
  "scope": "read:occurrences write:occurrences calculate:indices"
}

# Response
{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "read:occurrences write:occurrences calculate:indices"
}

# Use token in requests
GET https://api.biodiversity.wia.org/v1/occurrences
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

Diversity Index Calculation API

The core analytical capability - calculating biodiversity indices from occurrence data:

Calculate Diversity Indices

POST /v1/indices/calculate
Content-Type: application/json
Authorization: Bearer {token}

{
  "dataset_id": "DS-AMAZON-2025",
  "spatial_filter": {
    "type": "polygon",
    "coordinates": [[[-60.5, -3.5], [-60.0, -3.5], [-60.0, -3.0], [-60.5, -3.0], [-60.5, -3.5]]]
  },
  "temporal_filter": {
    "start_date": "2025-01-01",
    "end_date": "2025-12-31"
  },
  "indices": [
    "species_richness",
    "shannon_diversity",
    "simpson_index",
    "pielou_evenness"
  ],
  "rarefaction": {
    "enabled": true,
    "target_n": 1000
  },
  "bootstrap": {
    "enabled": true,
    "iterations": 1000,
    "confidence_level": 0.95
  }
}

# Response
{
  "calculation_id": "CALC-2025-AZ-1234",
  "status": "completed",
  "execution_time_ms": 2847,
  "results": {
    "species_richness": {
      "observed": 156,
      "rarefied": 142.7,
      "ci_lower": 138.2,
      "ci_upper": 147.3
    },
    "shannon_diversity": {
      "value": 4.127,
      "ci_lower": 3.982,
      "ci_upper": 4.268
    },
    "simpson_index": {
      "value": 0.0234,
      "diversity_1_minus_d": 0.9766,
      "inverse": 42.74
    },
    "pielou_evenness": {
      "value": 0.822,
      "interpretation": "high_evenness"
    }
  },
  "metadata": {
    "input_occurrences": 4523,
    "unique_species": 156,
    "total_individuals": 8947,
    "calculation_date": "2025-12-26T10:30:00Z"
  }
}

GraphQL Interface

For complex queries requiring multiple related resources, GraphQL provides efficient single-request access:

POST https://api.biodiversity.wia.org/graphql
Content-Type: application/json

{
  "query": "{
    species(scientificName: \"Panthera tigris\") {
      taxonId
      commonNames
      conservationStatus {
        category
        populationTrend
      }
      occurrences(limit: 10, year: 2025) {
        occurrenceId
        location {
          latitude
          longitude
          protectedArea
        }
        observationDate
        individualCount
      }
      diversityIndices(region: \"India\") {
        shannonIndex
        simpsonIndex
      }
    }
  }"
}

# Response provides exactly requested data structure
{
  "data": {
    "species": {
      "taxonId": "WIA-TAX-001234",
      "commonNames": ["Bengal Tiger", "बंगाल टाइगर"],
      "conservationStatus": {
        "category": "EN",
        "populationTrend": "Increasing"
      },
      "occurrences": [
        {
          "occurrenceId": "OCC-2025-IN-78945",
          "location": {
            "latitude": 27.5142,
            "longitude": 88.7597,
            "protectedArea": true
          },
          "observationDate": "2025-11-15",
          "individualCount": 1
        }
        // ... more occurrences
      ],
      "diversityIndices": {
        "shannonIndex": 3.45,
        "simpsonIndex": 0.0412
      }
    }
  }
}

Real-Time Analytics

WebSocket connections enable real-time biodiversity monitoring and alerts:

// Connect to WebSocket
const ws = new WebSocket('wss://stream.biodiversity.wia.org/v1/live');

// Subscribe to endangered species detections
ws.send(JSON.stringify({
  "action": "subscribe",
  "channels": ["endangered_detections"],
  "filters": {
    "region": "Southeast_Asia",
    "iucn_categories": ["CR", "EN"]
  }
}));

// Receive real-time alerts
ws.onmessage = (event) => {
  const alert = JSON.parse(event.data);
  console.log('Endangered species detected:', alert);
  /*
  {
    "event_type": "endangered_detection",
    "timestamp": "2025-12-26T14:23:15Z",
    "species": {
      "scientific_name": "Dicerorhinus sumatrensis",
      "common_name": "Sumatran Rhino",
      "iucn_status": "CR"
    },
    "location": {
      "latitude": 3.5952,
      "longitude": 98.6722,
      "protected_area": "Way Kambas National Park"
    },
    "detection_method": "camera_trap",
    "confidence": 0.96
  }
  */
};

Data Validation Services

Automated validation ensures data quality before submission:

POST /v1/validate/occurrence

{
  "occurrence_id": "OCC-2025-TEST-001",
  "species": {
    "scientific_name": "Panthera tigris",
    "taxon_id": "GBIF:5219404"
  },
  "location": {
    "latitude": 27.5142,
    "longitude": 88.7597,
    "country": "India"
  },
  "temporal": {
    "observation_date": "2025-11-15T09:30:00Z"
  }
}

# Response
{
  "valid": true,
  "quality_score": 0.94,
  "checks": [
    {
      "check": "coordinate_validity",
      "status": "passed",
      "message": "Coordinates within valid range"
    },
    {
      "check": "country_match",
      "status": "passed",
      "message": "Coordinates match stated country (India)"
    },
    {
      "check": "species_range",
      "status": "passed",
      "message": "Location within known species range"
    },
    {
      "check": "taxonomy_valid",
      "status": "passed",
      "message": "Taxon ID resolves to valid GBIF entry"
    },
    {
      "check": "date_reasonable",
      "status": "passed",
      "message": "Date not in future, within reasonable historical range"
    }
  ],
  "warnings": [],
  "errors": []
}

Integration Services

GBIF Upload Service

Direct submission to Global Biodiversity Information Facility:

POST /v1/export/gbif

{
  "dataset_id": "DS-AMAZON-2025",
  "gbif_dataset_key": "50c9509d-22c7-4a22-a47d-8c48425ef4a7",
  "filters": {
    "date_range": {
      "start": "2025-01-01",
      "end": "2025-12-31"
    }
  },
  "mapping_profile": "darwin_core_v1.0",
  "validate_before_upload": true
}

# Response
{
  "export_id": "EXP-GBIF-2025-1234",
  "status": "processing",
  "records_to_export": 4523,
  "validation_results": {
    "valid": 4498,
    "warnings": 25,
    "errors": 0
  },
  "estimated_completion": "2025-12-26T15:00:00Z"
}

IUCN Red List Integration

Retrieve conservation status and threat information:

GET /v1/integration/iucn/species/Panthera%20tigris

# Response
{
  "scientific_name": "Panthera tigris",
  "category": "EN",
  "criteria": "A2abcd+3cd+4abcd",
  "population_trend": "Increasing",
  "systems": ["Terrestrial"],
  "threats": [
    {
      "code": "5.1.1",
      "title": "Intentional use (species is the target)",
      "timing": "Ongoing",
      "scope": "Minority (<50%)",
      "severity": "Rapid Declines",
      "score": "Medium Impact: 6"
    },
    {
      "code": "2.1.2",
      "title": "Small-holder farming",
      "timing": "Ongoing",
      "scope": "Majority (50-90%)",
      "severity": "Slow, Significant Declines",
      "score": "Medium Impact: 7"
    }
  ],
  "conservation_actions": [
    {
      "code": "2.1",
      "title": "Site/area management"
    },
    {
      "code": "5.4.1",
      "title": "Awareness & communications"
    }
  ],
  "source": "IUCN Red List API v3",
  "assessment_date": "2023-06-15"
}

Rate Limiting and Performance

To ensure fair access and system stability, the API implements rate limiting:

Tier Rate Limit Burst Limit Use Case
Free 1,000 req/hour 50 req/minute Individual researchers, small projects
Research 10,000 req/hour 200 req/minute Academic institutions, NGOs
Enterprise 100,000 req/hour 1,000 req/minute Government agencies, large conservation orgs
Custom Negotiable Negotiable Global initiatives, long-term partnerships

SDK and Client Libraries

Official SDKs simplify API integration across programming languages:

Python SDK Example

from wia_biodiversity import BiodiversityAPI

# Initialize client
client = BiodiversityAPI(api_key='your_api_key')

# Query occurrences
occurrences = client.occurrences.list(
    species='Panthera tigris',
    country='India',
    year=2025,
    limit=100
)

# Calculate diversity indices
results = client.indices.calculate(
    dataset_id='DS-INDIA-2025',
    indices=['shannon', 'simpson', 'richness'],
    spatial_filter=client.geo.polygon([
        [88.0, 27.0], [89.0, 27.0], [89.0, 28.0], [88.0, 28.0]
    ]),
    bootstrap_iterations=1000
)

print(f"Shannon Diversity: {results.shannon.value:.3f}")
print(f"Species Richness: {results.richness.observed}")

TypeScript SDK Example

import { BiodiversityClient } from '@wia/biodiversity-sdk';

const client = new BiodiversityClient({
  apiKey: process.env.WIA_API_KEY
});

// Real-time species detection monitoring
const stream = client.stream.subscribe({
  channels: ['endangered_detections'],
  filters: {
    region: 'Southeast_Asia',
    iucnCategories: ['CR', 'EN']
  }
});

stream.on('detection', (event) => {
  console.log(`${event.species.commonName} detected!`);
  console.log(`Location: ${event.location.protectedArea}`);
  console.log(`Confidence: ${event.confidence}`);
});

Error Handling

The API uses standard HTTP status codes and structured error responses:

# Error response format
{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid species name format",
    "details": {
      "field": "species.scientific_name",
      "value": "panthera tigris",  // lowercase - invalid
      "expected": "Capitalized binomial nomenclature"
    },
    "documentation_url": "https://docs.biodiversity.wia.org/errors/VALIDATION_ERROR"
  },
  "request_id": "req_abc123def456"
}
Status Code Error Code Description
400 VALIDATION_ERROR Request data fails validation rules
401 UNAUTHORIZED Missing or invalid authentication
403 FORBIDDEN Valid auth but insufficient permissions
404 NOT_FOUND Requested resource doesn't exist
429 RATE_LIMIT_EXCEEDED Too many requests
500 INTERNAL_ERROR Server-side processing error

Chapter Summary

Key Takeaways

  • Dual API approach - RESTful endpoints for simple operations, GraphQL for complex queries, providing both ease of use and power.
  • Comprehensive analytical services - Automated diversity index calculation with bootstrap confidence intervals and rarefaction support.
  • Real-time capabilities - WebSocket streaming enables live monitoring and instant alerts for conservation priorities.
  • Seamless integration - Built-in connectors for GBIF, IUCN, and other major biodiversity platforms eliminate manual data transfer.
  • Production-ready features - OAuth 2.0 authentication, rate limiting, error handling, and official SDKs ensure enterprise-grade reliability.

Review Questions

  1. Compare REST and GraphQL approaches in the WIA API. When would you choose each for a biodiversity monitoring application?
  2. Explain how the diversity index calculation API handles statistical uncertainty through bootstrap and rarefaction methods.
  3. Describe the authentication flow using OAuth 2.0. Why is this approach more secure than API key-only authentication?
  4. How do WebSocket streams enable real-time conservation responses that traditional polling cannot?
  5. What validation checks are performed before data submission? How does this prevent data quality issues downstream?
  6. Discuss the rate limiting tiers. How do they balance open access principles with system sustainability?

Looking Ahead: Chapter 6 presents Phase 3: Protocol, detailing standardized field survey methodologies, quality assurance procedures, and certification programs that ensure data quality from the point of collection.

Korea Digital Transformation Detailed Mapping

Korea operates digital transformation through a comprehensive governance system. Digital Government: Digital Platform Government Committee (established September 2022, under the President)·Ministry of the Interior and Safety Digital Government Bureau·e-Government Support Center·Gov.kr·National Citizen Service·KDIS (Korea Digital Information Society)·NIA (National Information Society Agency)·MOIS (Ministry of the Interior and Safety). K-DNS Infrastructure: Korea Internet & Security Agency (KISA) Korea Internet Center·KISA DNS Root Server·KRNIC (Korea Network Information Center)·BGP Korea·National Cyber Security Center (NCSC)·KCC (Korea Communications Commission)·MSIT (Ministry of Science and ICT)·NIA·NIPA. Korean Cloud Infrastructure: KT Cloud·NAVER Cloud (NCloud)·Samsung SDS Cloud·LG U+ Cloud·NHN Cloud·Kakao Enterprise Cloud·SK Telecom Cloud·KISA Cloud Security Assurance Program (CSAP)·KCMVP-validated cloud·ISMS-P (Information Security & Personal Information Management System). Korean Security Certifications: KISA ISMS-P certification·KCMVP (Korean Cryptographic Module Validation Program)·NIS (National Intelligence Service) "National Cryptographic Technology Operation Standards"·NCSC "National Cyber Security Strategy 2024-2028"·CC (Common Criteria) Korean evaluation bodies·EAL4·EAL5·KS X ISO/IEC 15408·19790·24759 Korean Profile. Korean Data Standards: NIA AI Hub·National Data Standardization Committee·Statistics Korea (KOSTAT)·MyData 4 Designated Combination Specialists (Samsung SDS, KICI, KOSTAT, KFTC)·National Institute of Korean Language·National Law Information Center·National Spatial Information Platform·National Spatial Data Center·Korean Spatial Information Standards. Finance and Fintech Standards: FSC (Financial Services Commission)·FSS (Financial Supervisory Service)·FIU (Financial Intelligence Unit)·BOK (Bank of Korea)·FSEC (Financial Security Institute)·KFTC (Korea Financial Telecommunications)·KSD (Korea Securities Depository)·KRX (Korea Exchange) 8-agency cooperation. 5G/6G Communications Infrastructure: 5G subscribers 35 million (2024)·5G base stations 350,000·6G commercialization target 2028·5G dedicated networks 16 operators·6G Acceleration Council (MSIT, 2024). K-Content: KOCCA (Korea Creative Content Agency)·MCST (Ministry of Culture, Sports and Tourism)·KCA (Korea Communications Agency)·Korea Culture Information Service Agency·Korean Film Archive·Korea Publishing Industry Promotion Agency. Data 3 Acts (Personal Information Protection Act·Credit Information Act·Telecommunications Network Act, 2020 enforcement)·Data Industry Act (2021)·Public Data Act (2013)·AI Framework Act (2026)·Digital Platform Government Framework Act (2024 proposed) — Korea digital transformation core legislation.

Korea Industrial, Research, Education Infrastructure Mapping

Korea operates its industrial ecosystem and standardization system through the following core infrastructure. Korea Top 5 Groups: Samsung, Hyundai Motor, LG, SK, Lotte. Each group operates standardization committees and ISO/IEC TC Korean secretariats. Samsung Electronics (semiconductors, displays, home appliances, telecom)·Hyundai Motor (automobiles, mobility)·LG Electronics (home appliances, displays, OLED)·SK hynix (memory)·LG Energy Solution·Samsung SDI (batteries)·POSCO Future M (materials)·Hyundai Mobis (parts). Korean IT Big Tech: NAVER (search, cloud, AI HyperCLOVA)·Kakao (messenger, payment, mobility, banking)·Coupang (e-commerce, logistics)·Karrot Market·Toss·Woowa Brothers. Korea Telcos: SK Telecom·KT·LG U+. 5G·5G dedicated networks·B2B cloud·AI businesses operating. Korea Top 7 Research Universities: Seoul National University·KAIST·POSTECH·Yonsei University·Korea University·UNIST·DGIST·GIST. All serve as standardization R&D bases and ISO/IEC/IEEE Korean chairs. Korea Government-affiliated National Research Institutes (26): KIST, KAERI, KIMM, KIER, KFRI, KRICT, KRIBB, KARI, KASI, KIGAM, KICT, KISTI, KETI, ETRI, NIMS, KIMS, KISDI, KOTRA, STEPI, KOEN, KICCE, KIET, KIPF, KIHASA, KICJ, KLRI. Korea Industrial Complexes / Tech Valleys: Pangyo Techno Valley·Dongtan·Gwanggyo·Songdo IBD·Yeouido·Gangnam·Sihwa·Banwol·Gumi·Ulsan·Changwon·Geoje·Yeosu·Onsan·Cheongju·Iksan·Gwangyang·POSCO Gwangyang Steel Mill·Asan Bay·Seosan·Songdo·Incheon Airport·Sejong·Cheongna·Geomdan. Korea Trade and Finance Infrastructure: Korea International Trade Association (KITA)·Korea Trade-Investment Promotion Agency (KOTRA)·Export-Import Bank of Korea (KEXIM)·Bank of Korea·Kookmin Bank·Shinhan·Hana·Woori·NH Nonghyup·IBK Industrial Bank·SC First Bank·Citi Bank Korea·HSBC Korea·DBS Korea — 14 Korean major banks and foreign banks. Korea K-POP / K-Content: HYBE·SM·YG·JYP 4 major entertainment companies·CJ ENM·tvN·MBC·KBS·SBS·EBS·YTN·Yonhap News TV·JTBC Korean broadcasting·NETFLIX Korea·Disney Plus·TVING·Wavve·Watcha·Coupang Play. Korea Gaming Industry: Nexon·NCsoft·Krafton·Netmarble·Kakao Games·Pearl Abyss·Com2uS·Gamevil·NHN·Smilegate·Webzen. Korea Automotive / Battery: Hyundai Motor·Kia·Genesis·LG Energy Solution·Samsung SDI·SK On·POSCO Future M·EcoPro·L&F battery cathode material suppliers. Korea Semiconductor: Samsung Electronics (HBM3E·HBM4)·SK hynix (HBM3E 12-Hi)·DB HiTek·SK siltron·SK Enpulse·Dongjin Semichem·Seoul Semiconductor·Simmtech·Samsung Display·LG Display.

Korea Standardization Infrastructure Mapping

Korea operates a comprehensive standards governance system through inter-ministerial cooperation. National Standards Council (under Prime Minister's Office, per Framework Act on National Standards Article 5) coordinates KATS (Korean Agency for Technology and Standards), MFDS (Ministry of Food and Drug Safety), MOTIE (Ministry of Trade, Industry and Energy), MSIT (Ministry of Science and ICT), MOIS (Ministry of the Interior and Safety), MOE (Ministry of Environment), MOHW (Ministry of Health and Welfare), MND (Ministry of National Defense), MCST (Ministry of Culture, Sports and Tourism), MOFA (Ministry of Foreign Affairs), MOJ (Ministry of Justice), and FSC (Financial Services Commission). Accreditation and Testing: KOLAS (Korea Laboratory Accreditation Scheme) accredits 800+ testing laboratories. KAS (Korea Accreditation System) accredits 50+ certification bodies. KTC (Korea Testing Certification), KTR (Korea Testing & Research Institute), KTL (Korea Testing Laboratory), and KCL (Korea Conformity Laboratories) provide conformance testing. Telecom and Cyber: KCC (Korea Communications Commission), KCA (Korea Communications Agency), TTA (Telecommunications Technology Association), IITP (Institute for Information & Communications Technology Planning & Evaluation), NIPA (National IT Industry Promotion Agency), KISA (Korea Internet & Security Agency), KCMVP (Korea Cryptographic Module Validation Program), NIS (National Intelligence Service), NSR (National Security Research Institute), and NCSC (National Cyber Security Center). National R&D Centers: KIST, ETRI, KAIST, Seoul National University, Yonsei University, Korea University, POSTECH, UNIST, GIST, DGIST, KISTI, KIER, KIMM, KRICT, KFRI, KRIBB. International Standards Cooperation: ISO TC/SC Korean secretariats, IEC TC/SC Korean secretariats, ITU-T Study Group Korean chairs, 3GPP RAN/SA Korean chairs, IEEE 802 Korean chairs, W3C Korea office, OASIS Korea office, IETF Korea cooperation, OECD CSTP, UN ESCAP, APEC SCSC Korean cooperation. Korean Industrial Standards (KS) Catalog: KS X (Information) 25,000+, KS A (Basic) 15,000+, KS B (Machinery) 25,000+, KS C (Electrical) 18,000+, KS D (Metallurgy) 12,000+, KS E (Mining) 5,000+, KS F (Construction) 18,000+, KS H (Food) 8,000+, KS I (Environment) 5,000+, KS J (Biology) 3,000+, KS K (Textile) 15,000+, KS L (Ceramics) 7,000+, KS M (Chemistry) 12,000+, KS P (Medical) 5,000+, KS Q (Quality Mgmt) 4,000+, KS R (Transport) 12,000+, KS S (Service) 3,000+, KS T (Packaging) 4,000+, KS V (Shipbuilding) 5,000+, KS W (Aerospace) 3,000+ — totaling 220,000+ Korean Industrial Standards. Key Acts: Personal Information Protection Act (Act 19234, effective Sept 15, 2024), Electronic Government Act, Electronic Signature Act, Act on Promotion of Information and Communications Network Utilization and Information Protection, Information and Communications Infrastructure Protection Act, Data Industry Act, Public Data Act, AI Framework Act (Act 20212, effective July 2026), Industrial Technology Innovation Promotion Act, Framework Act on Science and Technology — 70+ Korean standardization-related laws.