From 436b661acdf82cf4e89af8a656486e6e984d594f Mon Sep 17 00:00:00 2001 From: Magnus Smari Smarason Date: Tue, 25 Mar 2025 11:59:55 +0000 Subject: [PATCH] Initial commit: Arctic Species 2025 Frontend --- .env.example | 2 + .gitignore | 36 +- .replit | 42 - README.md | 263 +- ...cites-status-401-in-2ms--1742513423785.txt | 26 - ...eturn-assessment-data-re-1742510048337.txt | 378 - ...ecies-CITES-Checklist-AP-1742506789633.txt | 48 - ...-without-the-code-Here-s-1742511134407.txt | 58 - ...-without-the-code-Here-s-1742512107918.txt | 58 - ...-without-the-code-Here-s-1742512823907.txt | 58 - ...APIs-follow-these-steps--1742508730468.txt | 165 - client/src/App.tsx | 26 - client/src/components/api-status.tsx | 117 - .../src/components/authentication-panel.tsx | 187 - client/src/components/recent-searches.tsx | 63 - client/src/components/results-container.tsx | 275 - client/src/components/saved-species.tsx | 82 - client/src/components/search-form.tsx | 154 - client/src/components/species-tabs.tsx | 458 - client/src/components/ui/accordion.tsx | 56 - client/src/components/ui/alert-dialog.tsx | 139 - client/src/components/ui/alert.tsx | 59 - client/src/components/ui/aspect-ratio.tsx | 5 - client/src/components/ui/avatar.tsx | 48 - client/src/components/ui/breadcrumb.tsx | 115 - client/src/components/ui/calendar.tsx | 64 - client/src/components/ui/carousel.tsx | 260 - client/src/components/ui/chart.tsx | 363 - client/src/components/ui/checkbox.tsx | 28 - client/src/components/ui/collapsible.tsx | 9 - client/src/components/ui/command.tsx | 153 - client/src/components/ui/context-menu.tsx | 198 - client/src/components/ui/dialog.tsx | 120 - client/src/components/ui/drawer.tsx | 116 - client/src/components/ui/dropdown-menu.tsx | 198 - client/src/components/ui/form.tsx | 176 - client/src/components/ui/hover-card.tsx | 27 - client/src/components/ui/input-otp.tsx | 69 - client/src/components/ui/menubar.tsx | 234 - client/src/components/ui/navigation-menu.tsx | 128 - client/src/components/ui/pagination.tsx | 117 - client/src/components/ui/popover.tsx | 29 - client/src/components/ui/progress.tsx | 26 - client/src/components/ui/radio-group.tsx | 42 - client/src/components/ui/resizable.tsx | 43 - client/src/components/ui/scroll-area.tsx | 46 - client/src/components/ui/separator.tsx | 29 - client/src/components/ui/sheet.tsx | 138 - client/src/components/ui/sidebar.tsx | 762 -- client/src/components/ui/skeleton.tsx | 15 - client/src/components/ui/slider.tsx | 26 - client/src/components/ui/switch.tsx | 27 - client/src/components/ui/table.tsx | 117 - client/src/components/ui/textarea.tsx | 24 - client/src/components/ui/toast.tsx | 127 - client/src/components/ui/toaster.tsx | 33 - client/src/components/ui/toggle-group.tsx | 59 - client/src/components/ui/toggle.tsx | 43 - client/src/components/ui/tooltip.tsx | 28 - client/src/hooks/use-mobile.tsx | 19 - client/src/hooks/use-toast.ts | 191 - client/src/index.css | 13 - client/src/lib/api.ts | 365 - client/src/lib/queryClient.ts | 57 - client/src/lib/utils.ts | 6 - client/src/main.tsx | 8 - client/src/pages/home.tsx | 216 - client/src/pages/not-found.tsx | 21 - drizzle.config.ts | 14 - generated-icon.png | Bin 878484 -> 0 bytes client/index.html => index.html | 5 +- package-lock.json | 7394 +++++------------ package.json | 132 +- postcss.config.js | 2 +- server/index.ts | 70 - server/routes.ts | 736 -- server/storage.ts | 144 - server/vite.ts | 88 - shared/schema.ts | 74 - src/App.tsx | 15 + src/components/debug-panel.tsx | 45 + src/components/results-container.tsx | 113 + src/components/search-form.tsx | 91 + src/components/species-tabs.tsx | 1130 +++ {client/src => src}/components/ui/badge.tsx | 2 +- {client/src => src}/components/ui/button.tsx | 25 +- {client/src => src}/components/ui/card.tsx | 2 +- {client/src => src}/components/ui/input.tsx | 4 +- {client/src => src}/components/ui/label.tsx | 2 +- {client/src => src}/components/ui/select.tsx | 2 +- {client/src => src}/components/ui/tabs.tsx | 23 +- src/env.d.ts | 10 + src/index.css | 76 + src/lib/api.ts | 382 + src/lib/query-client.ts | 10 + src/lib/supabase.ts | 40 + src/lib/utils.ts | 49 + src/main.tsx | 19 + src/pages/home.tsx | 110 + src/types/supabase.ts | 301 + src/utils/supabase-admin.js | 53 + supabase_cites.sql | 113 + tailwind.config.ts => tailwind.config.js | 92 +- theme.json | 6 - tsconfig.json | 32 +- tsconfig.node.json | 10 + vite.config.ts | 37 +- 107 files changed, 4898 insertions(+), 14243 deletions(-) create mode 100644 .env.example delete mode 100644 .replit delete mode 100644 attached_assets/Pasted--11-28-51-PM-express-serving-on-port-5000-11-29-02-PM-express-GET-api-cites-status-401-in-2ms--1742513423785.txt delete mode 100644 attached_assets/Pasted-API-V4-v4-OAS-3-0-api-docs-v4-openapi-yaml-Authorize-Assessment-Return-assessment-data-re-1742510048337.txt delete mode 100644 attached_assets/Pasted-Feedback-Species-Species-API-DocumentationSign-InRegister-an-Account-Species-CITES-Checklist-AP-1742506789633.txt delete mode 100644 attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742511134407.txt delete mode 100644 attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742512107918.txt delete mode 100644 attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742512823907.txt delete mode 100644 attached_assets/Pasted-To-gather-detailed-information-about-species-by-connecting-to-multiple-APIs-follow-these-steps--1742508730468.txt delete mode 100644 client/src/App.tsx delete mode 100644 client/src/components/api-status.tsx delete mode 100644 client/src/components/authentication-panel.tsx delete mode 100644 client/src/components/recent-searches.tsx delete mode 100644 client/src/components/results-container.tsx delete mode 100644 client/src/components/saved-species.tsx delete mode 100644 client/src/components/search-form.tsx delete mode 100644 client/src/components/species-tabs.tsx delete mode 100644 client/src/components/ui/accordion.tsx delete mode 100644 client/src/components/ui/alert-dialog.tsx delete mode 100644 client/src/components/ui/alert.tsx delete mode 100644 client/src/components/ui/aspect-ratio.tsx delete mode 100644 client/src/components/ui/avatar.tsx delete mode 100644 client/src/components/ui/breadcrumb.tsx delete mode 100644 client/src/components/ui/calendar.tsx delete mode 100644 client/src/components/ui/carousel.tsx delete mode 100644 client/src/components/ui/chart.tsx delete mode 100644 client/src/components/ui/checkbox.tsx delete mode 100644 client/src/components/ui/collapsible.tsx delete mode 100644 client/src/components/ui/command.tsx delete mode 100644 client/src/components/ui/context-menu.tsx delete mode 100644 client/src/components/ui/dialog.tsx delete mode 100644 client/src/components/ui/drawer.tsx delete mode 100644 client/src/components/ui/dropdown-menu.tsx delete mode 100644 client/src/components/ui/form.tsx delete mode 100644 client/src/components/ui/hover-card.tsx delete mode 100644 client/src/components/ui/input-otp.tsx delete mode 100644 client/src/components/ui/menubar.tsx delete mode 100644 client/src/components/ui/navigation-menu.tsx delete mode 100644 client/src/components/ui/pagination.tsx delete mode 100644 client/src/components/ui/popover.tsx delete mode 100644 client/src/components/ui/progress.tsx delete mode 100644 client/src/components/ui/radio-group.tsx delete mode 100644 client/src/components/ui/resizable.tsx delete mode 100644 client/src/components/ui/scroll-area.tsx delete mode 100644 client/src/components/ui/separator.tsx delete mode 100644 client/src/components/ui/sheet.tsx delete mode 100644 client/src/components/ui/sidebar.tsx delete mode 100644 client/src/components/ui/skeleton.tsx delete mode 100644 client/src/components/ui/slider.tsx delete mode 100644 client/src/components/ui/switch.tsx delete mode 100644 client/src/components/ui/table.tsx delete mode 100644 client/src/components/ui/textarea.tsx delete mode 100644 client/src/components/ui/toast.tsx delete mode 100644 client/src/components/ui/toaster.tsx delete mode 100644 client/src/components/ui/toggle-group.tsx delete mode 100644 client/src/components/ui/toggle.tsx delete mode 100644 client/src/components/ui/tooltip.tsx delete mode 100644 client/src/hooks/use-mobile.tsx delete mode 100644 client/src/hooks/use-toast.ts delete mode 100644 client/src/index.css delete mode 100644 client/src/lib/api.ts delete mode 100644 client/src/lib/queryClient.ts delete mode 100644 client/src/lib/utils.ts delete mode 100644 client/src/main.tsx delete mode 100644 client/src/pages/home.tsx delete mode 100644 client/src/pages/not-found.tsx delete mode 100644 drizzle.config.ts delete mode 100644 generated-icon.png rename client/index.html => index.html (51%) delete mode 100644 server/index.ts delete mode 100644 server/routes.ts delete mode 100644 server/storage.ts delete mode 100644 server/vite.ts delete mode 100644 shared/schema.ts create mode 100644 src/App.tsx create mode 100644 src/components/debug-panel.tsx create mode 100644 src/components/results-container.tsx create mode 100644 src/components/search-form.tsx create mode 100644 src/components/species-tabs.tsx rename {client/src => src}/components/ui/badge.tsx (97%) rename {client/src => src}/components/ui/button.tsx (68%) rename {client/src => src}/components/ui/card.tsx (99%) rename {client/src => src}/components/ui/input.tsx (67%) rename {client/src => src}/components/ui/label.tsx (97%) rename {client/src => src}/components/ui/select.tsx (99%) rename {client/src => src}/components/ui/tabs.tsx (79%) create mode 100644 src/env.d.ts create mode 100644 src/index.css create mode 100644 src/lib/api.ts create mode 100644 src/lib/query-client.ts create mode 100644 src/lib/supabase.ts create mode 100644 src/lib/utils.ts create mode 100644 src/main.tsx create mode 100644 src/pages/home.tsx create mode 100644 src/types/supabase.ts create mode 100644 src/utils/supabase-admin.js create mode 100644 supabase_cites.sql rename tailwind.config.ts => tailwind.config.js (56%) delete mode 100644 theme.json create mode 100644 tsconfig.node.json diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..a31a5d9 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +VITE_SUPABASE_URL=your_supabase_url +VITE_SUPABASE_ANON_KEY=your_supabase_anon_key \ No newline at end of file diff --git a/.gitignore b/.gitignore index f9ba7f8..9cdc482 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,36 @@ +# dependencies node_modules +.pnp +.pnp.js + +# testing +coverage + +# production +build dist + +# misc .DS_Store -server/public -vite.config.ts.* -*.tar.gz \ No newline at end of file +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Supabase +.supabase + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? \ No newline at end of file diff --git a/.replit b/.replit deleted file mode 100644 index 66129d4..0000000 --- a/.replit +++ /dev/null @@ -1,42 +0,0 @@ -modules = ["nodejs-20", "bash", "web"] -run = "npm run dev" -hidden = [".config", ".git", "generated-icon.png", "node_modules", "dist"] - -[nix] -channel = "stable-24_05" - -[deployment] -deploymentTarget = "autoscale" -run = ["npm", "run", "start"] -build = ["npm", "run", "build"] - -[[ports]] -localPort = 5000 -externalPort = 80 - -[workflows] -runButton = "Project" - -[[workflows.workflow]] -name = "Project" -mode = "parallel" -author = "agent" - -[[workflows.workflow.tasks]] -task = "workflow.run" -args = "Start application" - -[[workflows.workflow]] -name = "Start application" -author = "agent" - -[workflows.workflow.metadata] -agentRequireRestartOnSave = false - -[[workflows.workflow.tasks]] -task = "packager.installForAll" - -[[workflows.workflow.tasks]] -task = "shell.exec" -args = "npm run dev" -waitForPort = 5000 diff --git a/README.md b/README.md index b5acda1..672ac8b 100644 --- a/README.md +++ b/README.md @@ -1,227 +1,98 @@ -# Species Information System +# Arctic Species 2025 Frontend -A comprehensive web application that integrates with multiple biodiversity APIs to provide detailed information about species, their conservation status, habitats, threats, and protection measures. - -## Overview - -This application allows users to search for species using the CITES+ API and IUCN Red List API, view detailed information about them, and save this information for future reference. The system provides a unified interface to access and compare data from multiple sources, making it easier for researchers, conservationists, and wildlife enthusiasts to gather comprehensive information about species. +A comprehensive web application for tracking and analyzing Arctic species data, including CITES trade records, IUCN assessments, and conservation status. This project is part of the Arctic Species 2025 initiative. ## Features -- **API Integration**: - - CITES+ API for species listings, legislation, distributions, and references - - IUCN Red List API for conservation status, threats, habitats, and conservation measures - - (Coming soon) GBIF for occurrence data - - (Coming soon) Wikidata for additional taxonomic information - - (Coming soon) SBDI Bioatlas for biodiversity data +- **Arctic Species Search & Details** + - Search by scientific name or common name + - Detailed species information including taxonomy + - Multiple common names support + - Arctic subpopulation tracking + - Region-specific conservation status -- **Search Functionality**: - - Search species by scientific name (Latin name) - - View recent search history - - API status indicators to confirm connections +- **CITES Information** + - Complete CITES listing history + - Current CITES status + - Detailed trade records with filtering + - Historical trade data analysis + - Arctic-specific trade patterns -- **Detailed Species Information**: - - Basic taxonomic data (kingdom, phylum, class, order, family, genus) - - CITES listing status and appendices - - Geographic distribution - - Scientific references - - Conservation status (IUCN Red List category) - - Threats facing the species - - Habitat information - - Conservation measures +- **IUCN Assessments** + - Latest IUCN Red List status + - Historical assessment tracking + - Population trend analysis + - Arctic region-specific assessments -- **Data Management**: - - Save species information for offline access - - View previously saved species - - In-memory storage (with option for PostgreSQL database) +- **Timeline View** + - Chronological view of species events + - CITES listing changes + - IUCN assessment updates + - Trade record history + - Arctic conservation milestones -## Technical Stack +## Tech Stack -- **Frontend**: - - React with TypeScript - - TanStack Query for data fetching - - Shadcn UI components - - Tailwind CSS for styling - - React Hook Form for form handling - -- **Backend**: - - Node.js with Express - - RESTful API architecture - - Axios for API requests - - Zod for validation - - In-memory storage (with PostgreSQL option) - -## API Configuration - -### CITES+ API -The application requires a CITES+ API token for authentication. To obtain a token: -1. Visit [https://api.speciesplus.net/documentation](https://api.speciesplus.net/documentation) -2. Register for an account -3. Generate an API token from your account dashboard -4. Enter the token in the application's authentication panel - -### IUCN Red List API -The application supports both IUCN Red List API v3 and v4 versions: - -#### IUCN API v3 (Legacy) -To use the v3 API: -1. Visit [https://apiv3.iucnredlist.org/api/v3/docs](https://apiv3.iucnredlist.org/api/v3/docs) -2. Register for an account and request an API key -3. The key will be automatically configured in the application's environment variables (`IUCN_API_KEY`) - -#### IUCN API v4 (Recommended) -For enhanced functionality with the v4 API: -1. Visit [https://apiv3.iucnredlist.org/api/v4/docs](https://apiv3.iucnredlist.org/api/v4/docs) -2. Register for an account and request access to the v4 API -3. Generate a bearer token for the v4 API -4. Enter the token in the application's authentication panel (IUCN tab) - -The application will intelligently use v4 if available, with automatic fallback to v3 when needed. +- **Frontend**: React + TypeScript + Vite +- **UI Components**: Shadcn/ui +- **Styling**: Tailwind CSS +- **Database**: Supabase (PostgreSQL) +- **State Management**: React Query +- **Routing**: React Router ## Getting Started ### Prerequisites -- Node.js 18.x or higher -- NPM 8.x or higher -### Installation +- Node.js (v18 or higher) +- npm or yarn +- Supabase account and project + +### Environment Setup 1. Clone the repository: - ``` - git clone https://github.com/yourusername/species-information-system.git - cd species-information-system + ```bash + git clone https://github.com/yourusername/arctic-species-2025-frontend.git + cd arctic-species-2025-frontend ``` 2. Install dependencies: - ``` + ```bash npm install ``` -3. Set up environment variables: - Create a `.env` file in the root directory and add: +3. Create a `.env` file in the root directory with your Supabase credentials: ``` - IUCN_API_KEY=your_iucn_api_key + VITE_SUPABASE_URL=your_supabase_url + VITE_SUPABASE_ANON_KEY=your_supabase_anon_key ``` 4. Start the development server: - ``` + ```bash npm run dev ``` -5. Open your browser and navigate to `http://localhost:5000` +The application will be available at `http://localhost:5173` -### Using the Application +## Database Schema -1. **API Authentication**: - - Click the "API Token" button to open the authentication panel - - In the CITES tab, enter your CITES+ API token - - In the IUCN tab, enter your IUCN v4 bearer token (if available) - - The API status indicators will show if both APIs are successfully connected, including which version of the IUCN API is active +The application uses the following main tables: -2. **Searching for Species**: - - Enter a scientific name (e.g., "Panthera tigris") in the search box - - Select a species from the search results +- `species`: Core species information +- `common_names`: Alternative names for species +- `subpopulations`: Species subpopulation data +- `iucn_assessments`: IUCN Red List assessments +- `cites_listings`: CITES listing history +- `cites_trade_records`: CITES trade data +- `timeline_events`: Chronological events -3. **Viewing Species Information**: - - Navigate through the tabs to see different categories of information - - CITES Legislation: View protection status under CITES - - Distribution: See geographical range of the species - - References: View scientific publications about the species - - IUCN Status: View conservation status and population trend - - Threats: View factors threatening the species - - Habitats: View habitat information - - Conservation Measures: View protection and conservation efforts +## Contributing -4. **Saving Species**: - - Click the "Save Species" button to store information locally - - Access saved species from the sidebar - -## API Status Indicators - -The application provides real-time status indicators for both APIs: -- **CITES API**: Shows connection status to the CITES+ API -- **IUCN API**: Shows connection status to the IUCN Red List API - -Hovering over each indicator will show additional details about the connection status. - -## Error Handling - -The application includes comprehensive error handling for API connections: -- Clear visual feedback when APIs are not connected -- Detailed error messages in tooltips -- Fallback to saved data when APIs are unavailable - -## Data Processing - -To improve reliability and prevent API errors, the application processes scientific names before querying the IUCN API: -- Scientific names are simplified to genus and species components -- This prevents 414 (URI too long) errors when querying with subspecies names - -## Development - -### Project Structure - -``` -/client - /src - /components - UI components - /hooks - Custom React hooks - /lib - Utility functions and API client - /pages - Application pages -/server - /routes.ts - API endpoints - /storage.ts - Data storage implementation -/shared - /schema.ts - Shared data schemas -``` - -### Adding a New API - -To add a new biodiversity API: - -1. Define API endpoints and response types in `client/src/lib/api.ts` -2. Add server routes in `server/routes.ts` -3. Update the API status component in `client/src/components/api-status.tsx` -4. Add new data display components as needed -5. Update the species tabs in `client/src/components/species-tabs.tsx` - -### Testing - -Run tests with: -``` -npm test -``` - -## Limitations and Known Issues - -- Some species may not have data in all API sources -- API rate limits may apply (refer to API documentation for details) -- IUCN API v3 may return 414 errors for very long scientific names (this is minimized in the implementation) -- IUCN API v4 requires a separate bearer token authentication - -## API Version Handling - -The application intelligently manages API versions with the following approach: - -- **IUCN API Version Selection**: - - The system first attempts to use IUCN API v4 if a bearer token is available - - If v4 returns an error or isn't available, the system automatically falls back to v3 - - All API responses include an `apiVersion` field indicating which version was used - -- **Version-Specific Authentication**: - - CITES+ API: Uses a token-based authentication via query parameter - - IUCN v3: Uses an API key via environment variable and query parameter - - IUCN v4: Uses OAuth 2.0 Bearer token authentication via headers - -## Future Enhancements - -- Integration with GBIF, Wikidata, and SBDI Bioatlas -- Offline mode with IndexedDB storage -- Export functionality for research data -- Visualization tools for geographic distribution -- User accounts for saving preferences and searches -- Bulk data import/export features -- Mobile application version +1. Fork the repository +2. Create your feature branch (`git checkout -b feature/AmazingFeature`) +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) +4. Push to the branch (`git push origin feature/AmazingFeature`) +5. Open a Pull Request ## License @@ -229,11 +100,7 @@ This project is licensed under the MIT License - see the LICENSE file for detail ## Acknowledgments -- CITES+ API for providing species trade and protection data -- IUCN Red List API for conservation status data -- All contributors to the biodiversity data sources used in this application - -## Contact - -For questions, feedback, or contributions, please reach out to: -[Your Contact Information] \ No newline at end of file +- CITES Secretariat for trade data +- IUCN Red List for assessment data +- Arctic Council for regional guidance +- All contributors and maintainers \ No newline at end of file diff --git a/attached_assets/Pasted--11-28-51-PM-express-serving-on-port-5000-11-29-02-PM-express-GET-api-cites-status-401-in-2ms--1742513423785.txt b/attached_assets/Pasted--11-28-51-PM-express-serving-on-port-5000-11-29-02-PM-express-GET-api-cites-status-401-in-2ms--1742513423785.txt deleted file mode 100644 index b202ac6..0000000 --- a/attached_assets/Pasted--11-28-51-PM-express-serving-on-port-5000-11-29-02-PM-express-GET-api-cites-status-401-in-2ms--1742513423785.txt +++ /dev/null @@ -1,26 +0,0 @@ - -11:28:51 PM [express] serving on port 5000 -11:29:02 PM [express] GET /api/cites/status 401 in 2ms :: {"success":false,"connected":false,"message… -11:29:02 PM [express] GET /api/species 200 in 0ms :: {"success":true,"species":[]} -11:29:02 PM [express] GET /api/searches 200 in 1ms :: {"success":true,"searches":[]} -IUCN API check failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org -11:29:02 PM [express] GET /api/iucn/status 500 in 93ms :: {"success":false,"connected":false,"message… -11:29:03 PM [express] GET /api/cites/status 401 in 1ms :: {"success":false,"connected":false,"message… -11:29:03 PM [express] GET /api/species 304 in 1ms :: {"success":true,"species":[]} -11:29:03 PM [express] GET /api/searches 200 in 1ms :: {"success":true,"searches":[]} -IUCN API check failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org -11:29:03 PM [express] GET /api/iucn/status 500 in 28ms :: {"success":false,"connected":false,"message… -11:29:32 PM [express] POST /api/token 200 in 8787ms :: {"success":true,"token":{"id":1,"token":"vypRg… -11:29:32 PM [express] GET /api/token 200 in 1ms :: {"token":"vypRgcZfUGD4nCr8jt9Qkwtt","iucnToken":nu… -11:29:43 PM [express] GET /api/species/search 200 in 4033ms :: {"success":true,"data":{"pagination":{… -IUCN API habitats lookup failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org -11:29:43 PM [express] GET /api/iucn/habitats 500 in 13ms :: {"success":false,"message":"Error from IU… -IUCN API threats lookup failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org -11:29:43 PM [express] GET /api/iucn/threats 500 in 8ms :: {"success":false,"message":"Error from IUCN… -IUCN API species lookup failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org -11:29:43 PM [express] GET /api/iucn/species 500 in 6ms :: {"success":false,"message":"Error from IUCN… -11:29:43 PM [express] GET /api/species/8084 200 in 136ms :: {"success":true,"data":{"cites_listings":… -IUCN API conservation measures lookup failed: getaddrinfo ENOTFOUND apiv4.iucnredlist.org -11:29:43 PM [express] GET /api/iucn/measures 500 in 6ms :: {"success":false,"message":"Error from IUC… -11:29:43 PM [express] GET /api/species/8084 200 in 290ms :: {"success":true,"data":[{"id":19400,"iso_… -11:29:44 PM [express] GET /api/species/8084 200 in 309ms :: {"success":true,"data":[{"id":6292,"citat… diff --git a/attached_assets/Pasted-API-V4-v4-OAS-3-0-api-docs-v4-openapi-yaml-Authorize-Assessment-Return-assessment-data-re-1742510048337.txt b/attached_assets/Pasted-API-V4-v4-OAS-3-0-api-docs-v4-openapi-yaml-Authorize-Assessment-Return-assessment-data-re-1742510048337.txt deleted file mode 100644 index cb6517a..0000000 --- a/attached_assets/Pasted-API-V4-v4-OAS-3-0-api-docs-v4-openapi-yaml-Authorize-Assessment-Return-assessment-data-re-1742510048337.txt +++ /dev/null @@ -1,378 +0,0 @@ -API V4 - v4 -OAS 3.0 -/api-docs/v4/openapi.yaml - -Authorize -Assessment -Return assessment data relating to a specific assessment_id. You do not need to supply a latest assessment_id; you can therefore return data on latest and historic assessments if the assessment_id is known. You can gather a list of current and historic assessment_id for a specific species by using api/v4/taxa/scientific_name/{scientific_name} - - - -GET -/api/v4/assessment/{assessment_id} -Retrieves an assessment - - -Biogeographical Realms -Return the latest assessments for a biogeographical realm. - - - -GET -/api/v4/biogeographical_realms/ -Returns a list of biogeographic realm codes - - - -GET -/api/v4/biogeographical_realms/{code} -Returns a collection of assessments for a biogeographical realm code - - -Comprehensive Groups -Return the latest assessments for a comprehensive group - - - -GET -/api/v4/comprehensive_groups/ -Returns a list of comprehensive groups - - - -GET -/api/v4/comprehensive_groups/{name} -Returns a collection of assessments for a comprehensive group name - - -Conservation Actions -Description coming soon... - - - -GET -/api/v4/conservation_actions/ -returns a list of conservation actions - - - -GET -/api/v4/conservation_actions/{code} -returns a collection of assessments for a conservation action code - - -Countries -Return the latest assessments for a given country. - - - -GET -/api/v4/countries/ -Returns a list of countries by ISO alpha-2 code - - - -GET -/api/v4/countries/{code} -Returns a collection of assessments for a given country ISO alpha-2 code - - -FAOs -Documentation coming soon.. - - - -GET -/api/v4/faos/ -Returns a list of FAOs - - - -GET -/api/v4/faos/{code} -Returns a collection of assessments for an FAO code - - -Growth Forms -Return the latest assessments for a given growth form. - - - -GET -/api/v4/growth_forms/ -Returns a list of growth forms - - - -GET -/api/v4/growth_forms/{code} -Returns a collection of assessments for a given growth form code - - -Green Status -Return the latest Green Status assessments. - - - -GET -/api/v4/green_status/all -Returns a list of all Green Status assessments - - -Habitats -Return the latest assessments for a given habitat (e.g. Forest - Temperate or Marine Intertidal). These habitat codes correspond to the IUCN Red List Habitats Classification Scheme (v3.1) - - - -GET -/api/v4/habitats/ -Returns a list of habitat codes. - - - -GET -/api/v4/habitats/{code} -Returns a collection of assessments for a given habitat code - - -Information -Endpoints for supplying general API-specific information. - - - -GET -/api/v4/information/api_version -Returns the current version number of the IUCN Red List of Threatened Species API - - - -GET -/api/v4/information/red_list_version -Returns the current IUCN Red List of Threatened Species version - - -Population Trends -Return a list of the latest assessments based on a population trend (i.e. increasing, decreasing stable or unknown) - - - -GET -/api/v4/population_trends/ -Returns a list of population trends - - - -GET -/api/v4/population_trends/{code} -Returns a collection of assessments for a given population trend code - - -Red List Categories -Return a list of the latest assessments for a given category. (Not Evaluated, Data Deficient, Least Concern, Near Threatened, Vulnerable, Endangered, Critically Endangered, Extinct in the Wild and Extinct). - - - -GET -/api/v4/red_list_categories/ -Returns a list of Red List categories - - - -GET -/api/v4/red_list_categories/{code} -Returns a collection of assessments for a given Red List category code - - -Research -Return a list of the latest assessments for a given research category. - - - -GET -/api/v4/research/ -Returns a list of habitat codes. - - - -GET -/api/v4/research/{code} -Returns a collection of assessments for a given research code - - -Scopes -Return latest assessments for a given geographical assessment scope (e.g. Global, Mediterranean) - - - -GET -/api/v4/scopes/ -returns a list of scopes - - - -GET -/api/v4/scopes/{code} -Returns a collection of assessments for a given scope code - - -Statistics -Return aggregated statistics. - - - -GET -/api/v4/statistics/count -Return count of the number of species with assessments - - -Stresses -Return a list of the latest assessments based on the stresses species’ are subject to (e.g. Ecosystem degradation, species disturbance etc.) - - - -GET -/api/v4/stresses/ -Returns a list of stressors - - - -GET -/api/v4/stresses/{code} -returns a collection of assessments for a given stress code - - -Systems -Return assessments belonging to broad systems (e.g. terrestrial, freshwater or marine) - - - -GET -/api/v4/systems/ -Returns a list of systems - - - -GET -/api/v4/systems/{code} -Returns a collection of assessments for a given system code - - -Taxa -Return summary assessment data at the species level and other higher taxonomic levels (kingdom to family, inclusive). When querying at the species level, the API returns the latest and historic assessment information. - - - -GET -/api/v4/taxa/sis/{sis_id} -Returns a collection of assessments for a given SIS id - - - -GET -/api/v4/taxa/scientific_name -Returns a collection of assessments for a given genus_name and species_name (i.e. Latin binomial) and optional infra_name (i.e. Latin trinomial) - - - -GET -/api/v4/taxa/kingdom/ -Returns a list of all kingdom names - - - -GET -/api/v4/taxa/kingdom/{kingdom_name} -Returns a collection of the latests assessments for a given kingdom_name - - - -GET -/api/v4/taxa/phylum/ -Returns a list of all phylum names - - - -GET -/api/v4/taxa/phylum/{phylum_name} -Returns a collection of the latests assessments for a given phylum_name - - - -GET -/api/v4/taxa/class/ -Returns a list of all class names - - - -GET -/api/v4/taxa/class/{class_name} -Returns a collection of the latests assessments for a given class_name - - - -GET -/api/v4/taxa/order/ -Returns a list of all order names - - - -GET -/api/v4/taxa/order/{order_name} -Returns a collection of the latests assessments for a given order_name - - - -GET -/api/v4/taxa/family/ -Returns a list of all family names - - - -GET -/api/v4/taxa/family/{family_name} -Returns a collection of the latests assessments for a given family_name - - - -GET -/api/v4/taxa/possibly_extinct -Returns a collection of the all latest global assessments for taxa that are possibly extinct - - - -GET -/api/v4/taxa/possibly_extinct_in_the_wild -Returns a collection of the all latest global assessments for taxa that are possibly extinct in the wild - - -Threats -Return a list of the latest assessments which are subject to a specific threat (e.g. energy production and mining, climate change and severe weather) - - - -GET -/api/v4/threats/ -Returns a list of threats - - - -GET -/api/v4/threats/{code} -Returns a collection of assessments for a given threat code - - -Use and Trade -Return a list of the latest assessments which are subject to a specific uses and trade. - - - -GET -/api/v4/use_and_trade/ -Returns a list of use and trades - - - -GET -/api/v4/use_and_trade/{code} -Returns a collection of assessments for a given use and t \ No newline at end of file diff --git a/attached_assets/Pasted-Feedback-Species-Species-API-DocumentationSign-InRegister-an-Account-Species-CITES-Checklist-AP-1742506789633.txt b/attached_assets/Pasted-Feedback-Species-Species-API-DocumentationSign-InRegister-an-Account-Species-CITES-Checklist-AP-1742506789633.txt deleted file mode 100644 index 324e2c1..0000000 --- a/attached_assets/Pasted-Feedback-Species-Species-API-DocumentationSign-InRegister-an-Account-Species-CITES-Checklist-AP-1742506789633.txt +++ /dev/null @@ -1,48 +0,0 @@ -Feedback -Species+ -Species+API DocumentationSign InRegister an Account -Species+/CITES Checklist API Documentation -Application Programming Interface (API) to support CITES Parties to increase the accuracy and efficiency of curating CITES species data for permitting purposes. - -Getting Started -Signing up for API access -You can sign up for an API account here. Once you have signed up, visit Sign in to log in to the API Dashboard and retrieve your generated token. - -Authenticating your requests -Your authentication token needs to be passed into every request you make via the HTTP header below: -X-Authentication-Token: 8QW6Qgh57sBG2k0gtt -Tokens can be manually regenerated from the API Dashboard - -Tools for testing the API -There are a number of free tools available that allow you to test the API before you start integrating it in your systems. For example, curl is a popular command-line tool that could be used for this purpose: - -curl -i "https://api.speciesplus.net/api/v1/taxon_concepts.xml?name=Mammalia" -H "X-Authentication-Token:YOUR_TOKEN_HERE" - -Please note: we now support encrypted connections, please switch your integrations to use https://api.speciesplus.net. -There are also a number of tools that can be installed as an add-on to your browser; they can be found for example by searching for "rest client" in the add-ons repository for your browser. - -Formats -All endpoint can return both JSON and XML data. The default is JSON, if you would like to receive XML data, you can add .xml to the endpoint as below: - -https://api.speciesplus.net/api/v1/taxon_concepts.xml -Optional parameters -Whereas authentication is passed via a HTTP header, other parameters for refining your response data are provided via the query string. These are detailed below and where appropriate in the documentation for each endpoint. Parameters can be combined. - -API Calls -CITES Legislation -HTTP Verb / Endpoint Description -[GET] api/v1/taxon_concepts/:taxon_concept_id/cites_legislation Lists current CITES appendix listings and reservations, CITES quotas, and CITES suspensions for a given taxon concept -Distributions -HTTP Verb / Endpoint Description -[GET] api/v1/taxon_concepts/:taxon_concept_id/distributions Lists distributions for a given taxon concept -EU Legislation -HTTP Verb / Endpoint Description -[GET] api/v1/taxon_concepts/:taxon_concept_id/eu_legislation Lists current EU annex listings, SRG opinions, and EU suspensions for a given taxon concept -References -HTTP Verb / Endpoint Description -[GET] api/v1/taxon_concepts/:taxon_concept_id/references Lists references for a given taxon concept -Taxon Concepts -HTTP Verb / Endpoint Description -[GET] api/v1/taxon_concepts Lists taxon concepts -CITES logoPowered by logo -Send feedback \ No newline at end of file diff --git a/attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742511134407.txt b/attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742511134407.txt deleted file mode 100644 index 0839213..0000000 --- a/attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742511134407.txt +++ /dev/null @@ -1,58 +0,0 @@ -Got it, you need the essential information to use the IUCN Red List API V4, without the code. Here's a concise guide: - -**1. Base URL:** - -* The base URL for all API requests is: `https://apiv4.iucnredlist.org` - -**2. Authentication:** - -* The API uses Bearer token authentication. -* You'll need to include an `Authorization` header in your HTTP requests. -* The header value should be: `Bearer YOUR_API_TOKEN` (replace `YOUR_API_TOKEN` with your actual token). - -**3. Common Endpoints and Parameters:** - -Here are a few common endpoints with examples of parameters you can pass: - -* **Get a list of biogeographical realms:** - * Endpoint: `GET /api/v4/biogeographical_realms/` - * No parameters needed. -* **Get assessments for a biogeographical realm:** - * Endpoint: `GET /api/v4/biogeographical_realms/{code}` (replace `{code}` with the realm code, e.g., `NT`) - * Parameters (query parameters): - * `page`: Page number (integer). - * `year_published`: Filter by year published (integer). - * `latest`: Filter by latest (boolean). - * `possibly_extinct`: Filter by possibly extinct (boolean). - * `possibly_extinct_in_the_wild`: Filter by possibly extinct in the wild (boolean). - * `scope_code`: Filter by scope code (integer). -* **Get taxa by scientific name:** - * Endpoint: `GET /api/v4/taxa/scientific_name` - * Parameters (query parameters): - * `genus_name`: The genus name (string, required). - * `species_name`: The species name (string, required). - * `infra_name`: The infra-name (string, optional). - * `subpopulation_name`: The subpopulation name (string, optional). -* **Get assessments by kingdom name:** - * Endpoint: `GET /api/v4/taxa/kingdom/{kingdom_name}` (replace `{kingdom_name}` with the kingdom name, e.g., `Animalia`) - * Parameters (query parameters): - * `page`: Page number (integer). - * `year_published`: Filter by year published (integer). - * `latest`: Filter by latest (boolean). - * `scope_code`: Filter by scope code (integer). - -**4. Request Example (using cURL):** - -```bash -curl -H "Authorization: Bearer YOUR_API_TOKEN" "https://apiv4.iucnredlist.org/api/v4/biogeographical_realms/NT?page=1" -``` - -**5. Response Format:** - -* The API returns JSON responses. - -**Important Notes:** - -* Replace `YOUR_API_TOKEN` with your actual token. -* Refer to the official API documentation for a complete list of endpoints and parameters. -* The API documentation will also provide example responses, which will help you understand the returned data. diff --git a/attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742512107918.txt b/attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742512107918.txt deleted file mode 100644 index 0839213..0000000 --- a/attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742512107918.txt +++ /dev/null @@ -1,58 +0,0 @@ -Got it, you need the essential information to use the IUCN Red List API V4, without the code. Here's a concise guide: - -**1. Base URL:** - -* The base URL for all API requests is: `https://apiv4.iucnredlist.org` - -**2. Authentication:** - -* The API uses Bearer token authentication. -* You'll need to include an `Authorization` header in your HTTP requests. -* The header value should be: `Bearer YOUR_API_TOKEN` (replace `YOUR_API_TOKEN` with your actual token). - -**3. Common Endpoints and Parameters:** - -Here are a few common endpoints with examples of parameters you can pass: - -* **Get a list of biogeographical realms:** - * Endpoint: `GET /api/v4/biogeographical_realms/` - * No parameters needed. -* **Get assessments for a biogeographical realm:** - * Endpoint: `GET /api/v4/biogeographical_realms/{code}` (replace `{code}` with the realm code, e.g., `NT`) - * Parameters (query parameters): - * `page`: Page number (integer). - * `year_published`: Filter by year published (integer). - * `latest`: Filter by latest (boolean). - * `possibly_extinct`: Filter by possibly extinct (boolean). - * `possibly_extinct_in_the_wild`: Filter by possibly extinct in the wild (boolean). - * `scope_code`: Filter by scope code (integer). -* **Get taxa by scientific name:** - * Endpoint: `GET /api/v4/taxa/scientific_name` - * Parameters (query parameters): - * `genus_name`: The genus name (string, required). - * `species_name`: The species name (string, required). - * `infra_name`: The infra-name (string, optional). - * `subpopulation_name`: The subpopulation name (string, optional). -* **Get assessments by kingdom name:** - * Endpoint: `GET /api/v4/taxa/kingdom/{kingdom_name}` (replace `{kingdom_name}` with the kingdom name, e.g., `Animalia`) - * Parameters (query parameters): - * `page`: Page number (integer). - * `year_published`: Filter by year published (integer). - * `latest`: Filter by latest (boolean). - * `scope_code`: Filter by scope code (integer). - -**4. Request Example (using cURL):** - -```bash -curl -H "Authorization: Bearer YOUR_API_TOKEN" "https://apiv4.iucnredlist.org/api/v4/biogeographical_realms/NT?page=1" -``` - -**5. Response Format:** - -* The API returns JSON responses. - -**Important Notes:** - -* Replace `YOUR_API_TOKEN` with your actual token. -* Refer to the official API documentation for a complete list of endpoints and parameters. -* The API documentation will also provide example responses, which will help you understand the returned data. diff --git a/attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742512823907.txt b/attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742512823907.txt deleted file mode 100644 index 0839213..0000000 --- a/attached_assets/Pasted-Got-it-you-need-the-essential-information-to-use-the-IUCN-Red-List-API-V4-without-the-code-Here-s-1742512823907.txt +++ /dev/null @@ -1,58 +0,0 @@ -Got it, you need the essential information to use the IUCN Red List API V4, without the code. Here's a concise guide: - -**1. Base URL:** - -* The base URL for all API requests is: `https://apiv4.iucnredlist.org` - -**2. Authentication:** - -* The API uses Bearer token authentication. -* You'll need to include an `Authorization` header in your HTTP requests. -* The header value should be: `Bearer YOUR_API_TOKEN` (replace `YOUR_API_TOKEN` with your actual token). - -**3. Common Endpoints and Parameters:** - -Here are a few common endpoints with examples of parameters you can pass: - -* **Get a list of biogeographical realms:** - * Endpoint: `GET /api/v4/biogeographical_realms/` - * No parameters needed. -* **Get assessments for a biogeographical realm:** - * Endpoint: `GET /api/v4/biogeographical_realms/{code}` (replace `{code}` with the realm code, e.g., `NT`) - * Parameters (query parameters): - * `page`: Page number (integer). - * `year_published`: Filter by year published (integer). - * `latest`: Filter by latest (boolean). - * `possibly_extinct`: Filter by possibly extinct (boolean). - * `possibly_extinct_in_the_wild`: Filter by possibly extinct in the wild (boolean). - * `scope_code`: Filter by scope code (integer). -* **Get taxa by scientific name:** - * Endpoint: `GET /api/v4/taxa/scientific_name` - * Parameters (query parameters): - * `genus_name`: The genus name (string, required). - * `species_name`: The species name (string, required). - * `infra_name`: The infra-name (string, optional). - * `subpopulation_name`: The subpopulation name (string, optional). -* **Get assessments by kingdom name:** - * Endpoint: `GET /api/v4/taxa/kingdom/{kingdom_name}` (replace `{kingdom_name}` with the kingdom name, e.g., `Animalia`) - * Parameters (query parameters): - * `page`: Page number (integer). - * `year_published`: Filter by year published (integer). - * `latest`: Filter by latest (boolean). - * `scope_code`: Filter by scope code (integer). - -**4. Request Example (using cURL):** - -```bash -curl -H "Authorization: Bearer YOUR_API_TOKEN" "https://apiv4.iucnredlist.org/api/v4/biogeographical_realms/NT?page=1" -``` - -**5. Response Format:** - -* The API returns JSON responses. - -**Important Notes:** - -* Replace `YOUR_API_TOKEN` with your actual token. -* Refer to the official API documentation for a complete list of endpoints and parameters. -* The API documentation will also provide example responses, which will help you understand the returned data. diff --git a/attached_assets/Pasted-To-gather-detailed-information-about-species-by-connecting-to-multiple-APIs-follow-these-steps--1742508730468.txt b/attached_assets/Pasted-To-gather-detailed-information-about-species-by-connecting-to-multiple-APIs-follow-these-steps--1742508730468.txt deleted file mode 100644 index 7491bf2..0000000 --- a/attached_assets/Pasted-To-gather-detailed-information-about-species-by-connecting-to-multiple-APIs-follow-these-steps--1742508730468.txt +++ /dev/null @@ -1,165 +0,0 @@ -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 \ No newline at end of file diff --git a/client/src/App.tsx b/client/src/App.tsx deleted file mode 100644 index 093b683..0000000 --- a/client/src/App.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { Switch, Route } from "wouter"; -import { queryClient } from "./lib/queryClient"; -import { QueryClientProvider } from "@tanstack/react-query"; -import { Toaster } from "@/components/ui/toaster"; -import NotFound from "@/pages/not-found"; -import Home from "@/pages/home"; - -function Router() { - return ( - - - - - ); -} - -function App() { - return ( - - - - - ); -} - -export default App; diff --git a/client/src/components/api-status.tsx b/client/src/components/api-status.tsx deleted file mode 100644 index 830f542..0000000 --- a/client/src/components/api-status.tsx +++ /dev/null @@ -1,117 +0,0 @@ -import { useState, useEffect } from "react"; -import { useQuery } from "@tanstack/react-query"; -import { apiClient } from "@/lib/api"; -import { Badge } from "@/components/ui/badge"; -import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; - -interface ApiStatusProps { - citesToken: string | null; - iucnToken?: string | null; -} - -export default function ApiStatus({ citesToken, iucnToken }: ApiStatusProps) { - const [iucnStatus, setIucnStatus] = useState<'checking' | 'connected' | 'error'>('checking'); - const [citesStatus, setCitesStatus] = useState<'checking' | 'connected' | 'error'>('checking'); - - // Check CITES API status - const { - data: citesApiData, - isLoading: isCitesLoading - } = useQuery({ - queryKey: ['api-status-check-cites'], - queryFn: async () => { - return await apiClient.checkCitesApiStatus(); - }, - retry: 1, - staleTime: 60000, // 1 minute - }); - - // Check IUCN API status - const { - data: iucnApiData, - isLoading: isIucnLoading - } = useQuery({ - queryKey: ['api-status-check-iucn'], - queryFn: async () => { - return await apiClient.checkIucnApiStatus(); - }, - retry: 1, - staleTime: 60000, // 1 minute - }); - - useEffect(() => { - if (isCitesLoading) { - setCitesStatus('checking'); - } else if (citesApiData?.connected) { - setCitesStatus('connected'); - } else { - setCitesStatus('error'); - } - }, [isCitesLoading, citesApiData]); - - useEffect(() => { - if (isIucnLoading) { - setIucnStatus('checking'); - } else if (iucnApiData?.connected) { - setIucnStatus('connected'); - } else { - setIucnStatus('error'); - } - }, [isIucnLoading, iucnApiData]); - - return ( -
- - - -
- - CITES API: {citesStatus === 'checking' ? 'Checking...' : citesStatus === 'connected' ? 'Connected' : 'Not Connected'} - -
-
- - {citesStatus === 'connected' - ? citesToken - ? `CITES+ API is connected and working (Token: ${citesToken.substring(0, 6)}...)` - : 'CITES+ API is connected and working' - : citesStatus === 'checking' - ? 'Checking CITES+ API connection...' - : citesApiData?.message || 'CITES+ API is not connected. Click "API Token" and add your CITES+ API token.'} - -
-
- - - - -
- - IUCN API v4: {iucnStatus === 'checking' - ? 'Checking...' - : iucnStatus === 'connected' - ? 'Connected' - : 'Not Connected'} - -
-
- - {iucnStatus === 'connected' - ? iucnToken - ? `IUCN Red List API v4 is connected and working (Token: ${iucnToken.substring(0, 6)}...)` - : 'IUCN Red List API v4 is connected and working' - : iucnStatus === 'checking' - ? 'Checking IUCN Red List API v4 connection...' - : iucnApiData?.message || 'IUCN Red List API v4 connection issue. To use IUCN API features, click "API Token" and add your API token.'} - -
-
-
- ); -} \ No newline at end of file diff --git a/client/src/components/authentication-panel.tsx b/client/src/components/authentication-panel.tsx deleted file mode 100644 index ca2f38d..0000000 --- a/client/src/components/authentication-panel.tsx +++ /dev/null @@ -1,187 +0,0 @@ -import { useState, useEffect } from "react"; -import { useMutation, useQuery } from "@tanstack/react-query"; -import { queryClient } from "@/lib/queryClient"; -import { apiClient } from "@/lib/api"; -import { useToast } from "@/hooks/use-toast"; -import { Card, CardContent } from "@/components/ui/card"; -import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; -import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; - -interface AuthenticationPanelProps { - token: string; - iucnToken?: string; - onSave: () => void; -} - -export default function AuthenticationPanel({ token, iucnToken: initialIucnToken, onSave }: AuthenticationPanelProps) { - const { toast } = useToast(); - const [citesToken, setCitesToken] = useState(token || ""); - const [iucnToken, setIucnToken] = useState(initialIucnToken || ""); - const [activeTab, setActiveTab] = useState("cites"); - - // Fetch both tokens from the server - const { data: tokenData } = useQuery({ - queryKey: ['/api/token'], - queryFn: async () => { - return await apiClient.getTokens(); - }, - enabled: true, // Always fetch the tokens - }); - - // Update local state when token data is fetched - useEffect(() => { - if (tokenData) { - setCitesToken(tokenData.token || ""); - setIucnToken(tokenData.iucnToken || ""); - } - }, [tokenData]); - - const saveTokenMutation = useMutation({ - mutationFn: async (params: { citesToken: string; iucnToken?: string }) => { - return await apiClient.saveToken(params.citesToken, params.iucnToken); - }, - onSuccess: (response) => { - if (response.success) { - queryClient.invalidateQueries({ queryKey: ['/api/token'] }); - toast({ - title: "Success", - description: "API tokens have been saved successfully", - }); - onSave(); - } else { - toast({ - title: "Error", - description: response.message || "Failed to save API tokens", - variant: "destructive", - }); - } - }, - onError: () => { - toast({ - title: "Error", - description: "Failed to save API tokens", - variant: "destructive", - }); - } - }); - - const handleSaveTokens = () => { - if (!citesToken.trim()) { - toast({ - title: "Validation Error", - description: "Please enter a CITES API token", - variant: "destructive", - }); - return; - } - - saveTokenMutation.mutate({ - citesToken, - iucnToken: iucnToken.trim() ? iucnToken : undefined - }); - }; - - const handleGetCitesToken = () => { - window.open("https://api.speciesplus.net/", "_blank"); - }; - - const handleGetIucnToken = () => { - window.open("https://apiv4.iucnredlist.org/api/v4/docs", "_blank"); - }; - - return ( - - -

- - - - API Authentication -

- - - - CITES+ API - IUCN Red List API - - - -
- - setCitesToken(e.target.value)} - /> -
- The CITES+ API provides species listings, distributions, and legislation information. -
- -
-
- - -
- - setIucnToken(e.target.value)} - /> -
- The IUCN Red List API provides conservation status, threats, habitats, and conservation measures. -
- -
-
-
- -
- -
- Both tokens are stored securely. -
-
-
-
- ); -} diff --git a/client/src/components/recent-searches.tsx b/client/src/components/recent-searches.tsx deleted file mode 100644 index 168a8cb..0000000 --- a/client/src/components/recent-searches.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { Card, CardContent } from "@/components/ui/card"; -import { Button } from "@/components/ui/button"; -import { Search } from "@shared/schema"; - -interface RecentSearchesProps { - recentSearches: Search[]; - onSelectSearch: (query: string) => void; -} - -export default function RecentSearches({ recentSearches, onSelectSearch }: RecentSearchesProps) { - return ( - - -

- - - - - Recent Searches -

- -
- {recentSearches.length > 0 ? ( - recentSearches.map((item) => ( -
- -
- )) - ) : ( -

No recent searches

- )} -
-
-
- ); -} diff --git a/client/src/components/results-container.tsx b/client/src/components/results-container.tsx deleted file mode 100644 index 040f7d0..0000000 --- a/client/src/components/results-container.tsx +++ /dev/null @@ -1,275 +0,0 @@ -import { useState, useEffect } from "react"; -import { useMutation, useQuery } from "@tanstack/react-query"; -import { - apiClient, - CITES_API_ENDPOINTS, - IUCN_API_ENDPOINTS, - CitesLegislation, - Distribution, - IucnSpeciesResponse, - IucnThreatsResponse, - IucnHabitatsResponse, - IucnMeasuresResponse -} from "@/lib/api"; -import { useToast } from "@/hooks/use-toast"; -import { Card, CardContent } from "@/components/ui/card"; -import { Button } from "@/components/ui/button"; -import SpeciesTabs from "@/components/species-tabs"; - -interface ResultsContainerProps { - currentSpecies: any; - onSpeciesSaved: () => void; -} - -export default function ResultsContainer({ - currentSpecies, - onSpeciesSaved -}: ResultsContainerProps) { - const { toast } = useToast(); - const [apiResponse, setApiResponse] = useState(""); - - // Load species details when a species is selected - const { data: citesLegislation, isLoading: isLoadingLegislation } = useQuery({ - queryKey: ['/api/species/details', currentSpecies?.id, 'cites_legislation'], - queryFn: async () => { - if (!currentSpecies?.id) return null; - const response = await apiClient.getSpeciesDetails( - currentSpecies.id, - CITES_API_ENDPOINTS.CITES_LEGISLATION - ); - return response.success ? response.data : null; - }, - enabled: !!currentSpecies?.id, - }); - - const { data: distributions, isLoading: isLoadingDistributions } = useQuery({ - queryKey: ['/api/species/details', currentSpecies?.id, 'distributions'], - queryFn: async () => { - if (!currentSpecies?.id) return null; - const response = await apiClient.getSpeciesDetails( - currentSpecies.id, - CITES_API_ENDPOINTS.DISTRIBUTIONS - ); - return response.success ? response.data : null; - }, - enabled: !!currentSpecies?.id, - }); - - const { data: references, isLoading: isLoadingReferences } = useQuery({ - queryKey: ['/api/species/details', currentSpecies?.id, 'references'], - queryFn: async () => { - if (!currentSpecies?.id) return null; - const response = await apiClient.getSpeciesDetails( - currentSpecies.id, - CITES_API_ENDPOINTS.REFERENCES - ); - return response.success ? response.data : null; - }, - enabled: !!currentSpecies?.id, - }); - - // IUCN API Queries - const { data: iucnData, isLoading: isLoadingIucnSpecies } = useQuery({ - queryKey: ['/api/iucn/species', currentSpecies?.full_name], - queryFn: async () => { - if (!currentSpecies?.full_name) return null; - const response = await apiClient.getIucnSpeciesByName(currentSpecies.full_name); - - // Debug log - console.log("IUCN Species API response:", response); - if (response.success && response.data) { - console.log("IUCN response data structure:", Object.keys(response.data)); - if (response.data.result) { - console.log("IUCN result items:", response.data.result.length); - } - } - - return response.success ? response.data : null; - }, - enabled: !!currentSpecies?.full_name, - }); - - const { data: iucnThreats, isLoading: isLoadingIucnThreats } = useQuery({ - queryKey: ['/api/iucn/threats', currentSpecies?.full_name], - queryFn: async () => { - if (!currentSpecies?.full_name) return null; - const response = await apiClient.getIucnThreats(currentSpecies.full_name); - return response.success ? response.data : null; - }, - enabled: !!currentSpecies?.full_name, - }); - - const { data: iucnHabitats, isLoading: isLoadingIucnHabitats } = useQuery({ - queryKey: ['/api/iucn/habitats', currentSpecies?.full_name], - queryFn: async () => { - if (!currentSpecies?.full_name) return null; - const response = await apiClient.getIucnHabitats(currentSpecies.full_name); - return response.success ? response.data : null; - }, - enabled: !!currentSpecies?.full_name, - }); - - const { data: iucnMeasures, isLoading: isLoadingIucnMeasures } = useQuery({ - queryKey: ['/api/iucn/measures', currentSpecies?.full_name], - queryFn: async () => { - if (!currentSpecies?.full_name) return null; - const response = await apiClient.getIucnMeasures(currentSpecies.full_name); - return response.success ? response.data : null; - }, - enabled: !!currentSpecies?.full_name, - }); - - const saveSpeciesMutation = useMutation({ - mutationFn: async () => { - if (!currentSpecies) return null; - - // Prepare species data for saving - const speciesData = { - scientificName: currentSpecies.full_name, - commonName: currentSpecies.common_names?.[0]?.name || '', - rank: currentSpecies.rank, - kingdom: currentSpecies.taxonomy?.kingdom || '', - phylum: currentSpecies.taxonomy?.phylum || '', - class: currentSpecies.taxonomy?.class || '', - order: currentSpecies.taxonomy?.order || '', - family: currentSpecies.taxonomy?.family || '', - genus: currentSpecies.taxonomy?.genus || '', - citesListings: currentSpecies.cites_listings || [], - citesId: currentSpecies.id, - apiData: currentSpecies, - }; - - return await apiClient.saveSpecies(speciesData); - }, - onSuccess: (response) => { - if (response?.success) { - onSpeciesSaved(); - } else { - toast({ - title: "Error", - description: response?.message || "Failed to save species data", - variant: "destructive", - }); - } - }, - onError: () => { - toast({ - title: "Error", - description: "Failed to save species data", - variant: "destructive", - }); - } - }); - - // Update API response when currentSpecies changes - useEffect(() => { - if (currentSpecies) { - setApiResponse(JSON.stringify(currentSpecies, null, 2)); - } - }, [currentSpecies]); - - const handleSaveToDatabase = () => { - saveSpeciesMutation.mutate(); - }; - - const isLoading = isLoadingLegislation || isLoadingDistributions || isLoadingReferences || - isLoadingIucnSpecies || isLoadingIucnThreats || isLoadingIucnHabitats || isLoadingIucnMeasures || - saveSpeciesMutation.isPending; - - // No species selected yet - if (!currentSpecies) { - return ( - - - - - - -

No Species Data Yet

-

Search for a species to view CITES information

-
-
- ); - } - - return ( - - - {/* Species Header */} -
-
-
-

{currentSpecies.full_name}

-

- {currentSpecies.common_names?.[0]?.name || 'No common name available'} -

-
-
- - {currentSpecies.cites_listings?.[0]?.appendix - ? `CITES Appendix ${currentSpecies.cites_listings[0].appendix}` - : 'No CITES listing'} - -
-
-
-

- {currentSpecies.taxonomy - ? `Class: ${currentSpecies.taxonomy.class} | Order: ${currentSpecies.taxonomy.order} | Family: ${currentSpecies.taxonomy.family}` - : 'No taxonomy information available'} -

-
-
- - {/* Tabs Content */} - - - {/* Save Button */} -
- -
-
-
- ); -} diff --git a/client/src/components/saved-species.tsx b/client/src/components/saved-species.tsx deleted file mode 100644 index 9fd3c97..0000000 --- a/client/src/components/saved-species.tsx +++ /dev/null @@ -1,82 +0,0 @@ -import { Card, CardContent } from "@/components/ui/card"; -import { Button } from "@/components/ui/button"; -import { Species } from "@shared/schema"; -import { format } from "date-fns"; - -interface SavedSpeciesProps { - savedSpecies: Species[]; - onSelectSpecies: (species: any) => void; -} - -export default function SavedSpecies({ savedSpecies, onSelectSpecies }: SavedSpeciesProps) { - const handleViewDetails = (species: Species) => { - onSelectSpecies(species.apiData); - }; - - return ( - - -

- - - - - - Saved Species -

- -
- {savedSpecies.length > 0 ? ( - savedSpecies.map((species) => ( -
-
-
-
-

{species.scientificName}

-

{species.commonName || 'No common name'}

-
- {species.citesListings && ( - - {Array.isArray(species.citesListings) && species.citesListings[0]?.appendix - ? `Appendix ${species.citesListings[0].appendix}` - : 'No listing'} - - )} -
-
- - Saved on: {species.searchedAt ? format(new Date(species.searchedAt), 'yyyy-MM-dd') : 'Unknown'} - - -
-
-
- )) - ) : ( -
-

No species saved to database yet

-
- )} -
-
-
- ); -} diff --git a/client/src/components/search-form.tsx b/client/src/components/search-form.tsx deleted file mode 100644 index d81ac89..0000000 --- a/client/src/components/search-form.tsx +++ /dev/null @@ -1,154 +0,0 @@ -import { useState } from "react"; -import { useMutation } from "@tanstack/react-query"; -import { apiClient } from "@/lib/api"; -import { useToast } from "@/hooks/use-toast"; -import { Card, CardContent } from "@/components/ui/card"; -import { Button } from "@/components/ui/button"; -import { Input } from "@/components/ui/input"; -import { Label } from "@/components/ui/label"; -import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; - -interface SearchFormProps { - token: string | null; - onSpeciesFound: (species: any) => void; -} - -export default function SearchForm({ token, onSpeciesFound }: SearchFormProps) { - const { toast } = useToast(); - const [searchQuery, setSearchQuery] = useState(""); - const [responseFormat, setResponseFormat] = useState<"json" | "xml">("json"); - - const searchMutation = useMutation({ - mutationFn: async ({ query, format }: { query: string, format: "json" | "xml" }) => { - return await apiClient.searchSpecies(query, format); - }, - onSuccess: (response) => { - if (response.success && response.data?.taxon_concepts?.length) { - onSpeciesFound(response.data.taxon_concepts[0]); - toast({ - title: "Success", - description: "Species information retrieved successfully", - }); - } else { - toast({ - title: "No results", - description: "No species found matching your search criteria", - variant: "destructive", - }); - } - }, - onError: (error: any) => { - toast({ - title: "Error", - description: error.message || "Failed to search for species", - variant: "destructive", - }); - } - }); - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - - if (!searchQuery.trim()) { - toast({ - title: "Validation Error", - description: "Please enter a species name to search", - variant: "destructive", - }); - return; - } - - if (!token) { - toast({ - title: "API Token Required", - description: "Please set your CITES+ API token first", - variant: "destructive", - }); - return; - } - - searchMutation.mutate({ query: searchQuery, format: responseFormat }); - }; - - return ( - - -

- - - - - Species Search -

-
-
- - setSearchQuery(e.target.value)} - required - /> -

- Example: Panthera leo, Tiger, Elephas maximus -

-
-
- - setResponseFormat(value as "json" | "xml")} - > -
- - -
-
- - -
-
-
- -
-
-
- ); -} diff --git a/client/src/components/species-tabs.tsx b/client/src/components/species-tabs.tsx deleted file mode 100644 index bb65d8f..0000000 --- a/client/src/components/species-tabs.tsx +++ /dev/null @@ -1,458 +0,0 @@ -import { useState, useEffect } from "react"; -import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs"; -import { Button } from "@/components/ui/button"; -import { Skeleton } from "@/components/ui/skeleton"; -import { useToast } from "@/hooks/use-toast"; - -interface SpeciesTabsProps { - species: any; - citesLegislation: any; - distributions: any; - references: any; - iucnData: any; - iucnThreats: any; - iucnHabitats: any; - iucnMeasures: any; - apiResponse: string; - isLoading: boolean; -} - -export default function SpeciesTabs({ - species, - citesLegislation, - distributions, - references, - iucnData, - iucnThreats, - iucnHabitats, - iucnMeasures, - apiResponse, - isLoading -}: SpeciesTabsProps) { - const { toast } = useToast(); - const [activeTab, setActiveTab] = useState("overview"); - - // Debug logging for IUCN data - useEffect(() => { - console.log("SpeciesTabs received iucnData:", iucnData); - console.log("SpeciesTabs received iucnThreats:", iucnThreats); - console.log("SpeciesTabs received iucnHabitats:", iucnHabitats); - console.log("SpeciesTabs received iucnMeasures:", iucnMeasures); - }, [iucnData, iucnThreats, iucnHabitats, iucnMeasures]); - - // Handle copy API response to clipboard - const handleCopyResponse = async () => { - try { - await navigator.clipboard.writeText(apiResponse); - toast({ - title: "Copied", - description: "API response copied to clipboard", - }); - } catch (err) { - toast({ - title: "Error", - description: "Failed to copy API response", - variant: "destructive", - }); - } - }; - - if (isLoading) { - return ( -
- - -
- ); - } - - return ( - - - Overview - CITES Legislation - Distribution - Conservation Status - References - API Response - - - {/* Overview Tab */} - -
-
-

CITES Status

- {species.cites_listings && species.cites_listings.length > 0 ? ( - <> -

- Listed in CITES Appendix {species.cites_listings[0].appendix} - since {new Date(species.cites_listings[0].effective_at).toLocaleDateString()} -

-

- {species.cites_listings[0].appendix === 'I' - ? 'All commercial international trade is prohibited.' - : species.cites_listings[0].appendix === 'II' - ? 'International trade is regulated and requires permits.' - : 'International trade is regulated within countries that have requested monitoring assistance.'} -

- - ) : ( -

No CITES listing information available.

- )} -
-
-

Taxonomic Information

-

Rank: {species.rank || 'Unknown'}

-

Author: {species.author_year || 'Unknown'}

-
-
-
-

Species Information

-

- {species.full_name} {species.common_names?.[0] ? `(${species.common_names[0].name})` : ''} is - a species of {species.taxonomy?.family?.toLowerCase() || 'organism'}. -

-
- {species.taxonomy?.kingdom && ( - - {species.taxonomy.kingdom} - - )} - {species.taxonomy?.class && ( - - {species.taxonomy.class} - - )} - {species.taxonomy?.order && ( - - {species.taxonomy.order} - - )} - {species.taxonomy?.family && ( - - {species.taxonomy.family} - - )} -
-
-
- - {/* CITES Legislation Tab */} - -
-

Appendix Listings

-
- - - - - - - - - - {citesLegislation?.cites_listings && citesLegislation.cites_listings.length > 0 ? ( - citesLegislation.cites_listings.map((listing: any, index: number) => ( - - - - - - )) - ) : ( - - - - )} - -
AppendixEffective FromNotes
{listing.appendix} - {new Date(listing.effective_at).toLocaleDateString()} - {listing.annotation || 'None'}
No listing information available
-
-
- -
-

CITES Quotas

-
- - - - - - - - - - - {citesLegislation?.cites_quotas && citesLegislation.cites_quotas.length > 0 ? ( - citesLegislation.cites_quotas.map((quota: any, index: number) => ( - - - - - - - )) - ) : ( - - - - )} - -
YearQuotaPublication DateNotes
{quota.year}{quota.quota} - {quota.publication_date ? new Date(quota.publication_date).toLocaleDateString() : 'N/A'} - {quota.notes || 'None'}
No quota information available
-
-
- -
-

CITES Suspensions

-
- - - - - - - - - - - {citesLegislation?.cites_suspensions && citesLegislation.cites_suspensions.length > 0 ? ( - citesLegislation.cites_suspensions.map((suspension: any, index: number) => ( - - - - - - - )) - ) : ( - - - - )} - -
Start DateEnd DateApplies toNotes
- {suspension.start_date ? new Date(suspension.start_date).toLocaleDateString() : 'N/A'} - - {suspension.end_date ? new Date(suspension.end_date).toLocaleDateString() : 'Ongoing'} - {suspension.applies_to || 'All'}{suspension.notes || 'None'}
No suspension information available
-
-
-
- - {/* Distribution Tab */} - -
-

Geographic Range

-
- - - - - - - - - - {distributions?.distributions && distributions.distributions.length > 0 ? ( - distributions.distributions.map((distribution: any, index: number) => ( - - - - - - )) - ) : ( - - - - )} - -
Country/TerritoryStatusReferences
{distribution.name} - {distribution.tags && distribution.tags.length > 0 - ? distribution.tags.join(', ') - : 'Native'} - - {distribution.references && distribution.references.length > 0 - ? distribution.references.map((ref: any) => ref.citation || 'Unnamed reference').join('; ') - : 'No references available'} -
No distribution information available
-
-
-
- - {/* Conservation Status Tab */} - -
-
-

IUCN Red List Status

- {iucnData?.result && iucnData.result.length > 0 ? ( -
-
-
- - {iucnData.result[0].category === 'EX' ? 'Extinct' : - iucnData.result[0].category === 'EW' ? 'Extinct in the Wild' : - iucnData.result[0].category === 'CR' ? 'Critically Endangered' : - iucnData.result[0].category === 'EN' ? 'Endangered' : - iucnData.result[0].category === 'VU' ? 'Vulnerable' : - iucnData.result[0].category === 'NT' ? 'Near Threatened' : - iucnData.result[0].category === 'LC' ? 'Least Concern' : - iucnData.result[0].category === 'DD' ? 'Data Deficient' : - iucnData.result[0].category === 'NE' ? 'Not Evaluated' : - iucnData.result[0].category} - -
-

Assessed: {iucnData.result[0].assessment_date}

-

Criteria: {iucnData.result[0].criteria || 'Not specified'}

-

- Population trend: { - iucnData.result[0].population_trend === 'decreasing' ? 'Decreasing ↓' : - iucnData.result[0].population_trend === 'increasing' ? 'Increasing ↑' : - iucnData.result[0].population_trend === 'stable' ? 'Stable →' : - 'Unknown' - } -

-
- ) : ( -

No IUCN Red List data available for this species.

- )} -
-
-

Habitat Types

- {iucnHabitats?.result && iucnHabitats.result.length > 0 ? ( -
    - {iucnHabitats.result.map((habitat: any, index: number) => ( -
  • - - - {habitat.habitat} - {habitat.suitability && ` (${habitat.suitability})`} - {habitat.majorimportance === 'Yes' && ' - Major importance'} - -
  • - ))} -
- ) : ( -

No habitat information available.

- )} -
-
- -
-

Threats

- {iucnThreats?.result && iucnThreats.result.length > 0 ? ( -
- - - - - - - - - - - - {iucnThreats.result.map((threat: any, index: number) => ( - - - - - - - - ))} - -
ThreatTimingScopeSeverityScore
{threat.title}{threat.timing || 'Unknown'}{threat.scope || 'Unknown'}{threat.severity || 'Unknown'}{threat.score || 'Unknown'}
-
- ) : ( -

No threat information available.

- )} -
- -
-

Conservation Measures

- {iucnMeasures?.result && iucnMeasures.result.length > 0 ? ( -
    - {iucnMeasures.result.map((measure: any, index: number) => ( -
  • - - - {measure.title} - {measure.year ? ` (${measure.year})` : ''} - -
  • - ))} -
- ) : ( -

No conservation measures information available.

- )} -
-
- - {/* References Tab */} - -
-

Standard References

-
    - {references?.references && references.references.length > 0 ? ( - references.references.map((ref: any, index: number) => ( -
  • - {ref.citation || `${ref.author || 'Unknown'} (${ref.year || 'n.d.'}). ${ref.title || 'Untitled'}.`} -
  • - )) - ) : ( -
  • No reference information available
  • - )} -
-
-
- - {/* API Response Tab */} - -
-
-

Raw API Response

-
- -
-
-
-
{apiResponse}
-
-
-
-
- ); -} diff --git a/client/src/components/ui/accordion.tsx b/client/src/components/ui/accordion.tsx deleted file mode 100644 index e6a723d..0000000 --- a/client/src/components/ui/accordion.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import * as React from "react" -import * as AccordionPrimitive from "@radix-ui/react-accordion" -import { ChevronDown } from "lucide-react" - -import { cn } from "@/lib/utils" - -const Accordion = AccordionPrimitive.Root - -const AccordionItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -AccordionItem.displayName = "AccordionItem" - -const AccordionTrigger = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( - - svg]:rotate-180", - className - )} - {...props} - > - {children} - - - -)) -AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName - -const AccordionContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( - -
{children}
-
-)) - -AccordionContent.displayName = AccordionPrimitive.Content.displayName - -export { Accordion, AccordionItem, AccordionTrigger, AccordionContent } diff --git a/client/src/components/ui/alert-dialog.tsx b/client/src/components/ui/alert-dialog.tsx deleted file mode 100644 index 8722561..0000000 --- a/client/src/components/ui/alert-dialog.tsx +++ /dev/null @@ -1,139 +0,0 @@ -import * as React from "react" -import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog" - -import { cn } from "@/lib/utils" -import { buttonVariants } from "@/components/ui/button" - -const AlertDialog = AlertDialogPrimitive.Root - -const AlertDialogTrigger = AlertDialogPrimitive.Trigger - -const AlertDialogPortal = AlertDialogPrimitive.Portal - -const AlertDialogOverlay = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName - -const AlertDialogContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - - - - -)) -AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName - -const AlertDialogHeader = ({ - className, - ...props -}: React.HTMLAttributes) => ( -
-) -AlertDialogHeader.displayName = "AlertDialogHeader" - -const AlertDialogFooter = ({ - className, - ...props -}: React.HTMLAttributes) => ( -
-) -AlertDialogFooter.displayName = "AlertDialogFooter" - -const AlertDialogTitle = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName - -const AlertDialogDescription = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -AlertDialogDescription.displayName = - AlertDialogPrimitive.Description.displayName - -const AlertDialogAction = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName - -const AlertDialogCancel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName - -export { - AlertDialog, - AlertDialogPortal, - AlertDialogOverlay, - AlertDialogTrigger, - AlertDialogContent, - AlertDialogHeader, - AlertDialogFooter, - AlertDialogTitle, - AlertDialogDescription, - AlertDialogAction, - AlertDialogCancel, -} diff --git a/client/src/components/ui/alert.tsx b/client/src/components/ui/alert.tsx deleted file mode 100644 index 41fa7e0..0000000 --- a/client/src/components/ui/alert.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import * as React from "react" -import { cva, type VariantProps } from "class-variance-authority" - -import { cn } from "@/lib/utils" - -const alertVariants = cva( - "relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground", - { - variants: { - variant: { - default: "bg-background text-foreground", - destructive: - "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive", - }, - }, - defaultVariants: { - variant: "default", - }, - } -) - -const Alert = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes & VariantProps ->(({ className, variant, ...props }, ref) => ( -
-)) -Alert.displayName = "Alert" - -const AlertTitle = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)) -AlertTitle.displayName = "AlertTitle" - -const AlertDescription = React.forwardRef< - HTMLParagraphElement, - React.HTMLAttributes ->(({ className, ...props }, ref) => ( -
-)) -AlertDescription.displayName = "AlertDescription" - -export { Alert, AlertTitle, AlertDescription } diff --git a/client/src/components/ui/aspect-ratio.tsx b/client/src/components/ui/aspect-ratio.tsx deleted file mode 100644 index c4abbf3..0000000 --- a/client/src/components/ui/aspect-ratio.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import * as AspectRatioPrimitive from "@radix-ui/react-aspect-ratio" - -const AspectRatio = AspectRatioPrimitive.Root - -export { AspectRatio } diff --git a/client/src/components/ui/avatar.tsx b/client/src/components/ui/avatar.tsx deleted file mode 100644 index 991f56e..0000000 --- a/client/src/components/ui/avatar.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import * as React from "react" -import * as AvatarPrimitive from "@radix-ui/react-avatar" - -import { cn } from "@/lib/utils" - -const Avatar = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -Avatar.displayName = AvatarPrimitive.Root.displayName - -const AvatarImage = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -AvatarImage.displayName = AvatarPrimitive.Image.displayName - -const AvatarFallback = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)) -AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName - -export { Avatar, AvatarImage, AvatarFallback } diff --git a/client/src/components/ui/breadcrumb.tsx b/client/src/components/ui/breadcrumb.tsx deleted file mode 100644 index 60e6c96..0000000 --- a/client/src/components/ui/breadcrumb.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import * as React from "react" -import { Slot } from "@radix-ui/react-slot" -import { ChevronRight, MoreHorizontal } from "lucide-react" - -import { cn } from "@/lib/utils" - -const Breadcrumb = React.forwardRef< - HTMLElement, - React.ComponentPropsWithoutRef<"nav"> & { - separator?: React.ReactNode - } ->(({ ...props }, ref) =>