Welcome to sqlite-dinosaur-api! This project provides a simple Node.js Express API with SQLite database integration, designed to serve dinosaur facts based on various endpoints.
To get a local copy up and running, follow these simple steps.
-
Node.js
-
npm
- Clone the repo
git clone https://github.com/jrh89/sqlite-dinosaur-api.git
- Install dependencies
npm install
- CD to the frontend directory
cd frontend
- Start frontend
npm start
Open browser to localhost:3000 where you will see the UI for using the API. Spin up the server to start fetching dino facts.
To start the server locally:
- Change to the api directory
cd api
- To start the server locally:
node index.js
The server will start at http://localhost:3001.
To fetch dinosaur facts by name, use curl or any HTTP client:
curl http://localhost:3001/api/dinosaurs/name/Tyrannosaurus
Replace Tyrannosaurus with the name of the dinosaur you want to query.
To fetch dinosaurs by type, use:
curl http://localhost:3001/api/dinosaurs/type/theropod
Replace theropod with the type of dinosaur you want to query.
To fetch dinosaurs by diet, use:
curl http://localhost:3001/api/dinosaurs/diet/omnivorous
Replace omnivorous with the type of dinosaur you want to query.
To fetch dinosaurs by family, use:
curl http://localhost:3001/api/dinosaurs/family/Caudipterygidae
Replace caudipterygidae with the type of dinosaur you want to query.
To fetch dinosaurs by region, use:
curl http://localhost:3001/api/dinosaurs/region/Alberta
Replace Alberta with the type of dinosaur you want to query.
To fetch dinosaurs by class, use:
curl http://localhost:3001/api/dinosaurs/class/Ornithischia
Replace Ornithischia with the type of dinosaur you want to query.
If you encounter any issues or errors, please check the server logs or the terminal for error messages. Ensure that your SQLite database is correctly configured and accessible.
Contributions are welcome! Feel free to fork the repository and submit pull requests.
Distributed under the MIT License. See LICENSE for more information.