A REST API that allows users to search for information on solar objects.
Currently the API is hosted as a Heroku app. You can query for data following these API routes:
/api/shuttle/mission/<mission_name>
/api/shuttle/launch_year/<year>
Open Space runs on python3, please make sure you are using the latest. You will need these dependencies:
sudo apt-get install python3 python3-dev
sudo apt-get install build-essential libssl-dev libffi-dev python-dev
Create the project directiory:
mkdir openspaceapi
cd openspaceapi
Setup the virtual environment. We use Python3:
python3 -m venv venv
source venv/bin/activate
Install all the required Python packages. Simply save the requirements.txt file from this project on your local machine and install.
cd openspaceapi
pip install -r requirements.txt
To read the contents of the Wikipedia page, use the scrapy crawl function:
cd wikiscraper
scrapy crawl SpaceShuttleMissions -o shuttlemissions.json
This will execute the web scrapper and write the contents to a JSON file.
To setup the database, please follow the following steps to setup the PostgreSQL database.
PostgreSQL is used for database. To install PostgreSQL, ensure you have the latest and install postgres:
sudo apt update
sudo apt install postgresql postgresql-contrib
To utilize the PostgreSQL database, a user account is needed. On the system, first add a new user account:
sudo adduser openspaceapi-db-user
Next, create a new user on PostgreSQL database and set up the password:
sudo -u postgres createuser --interactive
The user in my case was 'openspaceapi-db-user' with a superuser role
Open up PostgresSQL and update the password:
ALTER USER "<USERNAME>" PASSWORD '<PASSWORD';
To create the database, use this action
createdb <DATABASENAME>
The database in my case was 'openspacedpidb'.
To create the tables, DBComm's init_db() function is used. First, make sure you are in the 'webapp' directory. Create an instance of python and run the init_db() command.
cd openspaceapi
python3
Once the Python shell opens, import init_db and run it:
from webapp.database.dbcomm import init_db
init_db()
To populate the database with the data that was scraped by the wikiscraper, we'll use the populate DB python file. First, make sure ou are in the 'webapp' directory. Then run the file
cd webapp
python3 -m database.populateDB