Skip to content

iqfareez/astros-api

Repository files navigation

Python NodeJS GitHub Actions

astros-api

Fetch the data and host the JSON-Server website. This project contains two parts:

  • Python part: To fetch the latest astros data
  • Node JS part: To host the JSON-Server website

Get started

Get Azure key

image

Create a new Bing Resource instance. Take the first & secondary key and save them in .env file (See .env.example for example).

Get latest astros data

Prerequisites: Node & Python 3.x

Install required packages

pip install -r requirements.txt

Run the fetcher

py fetcher.py

Start local server

npm install

Then

npm start

How it work?

flowchart TD
    subgraph "External API"
    A(OpenNotifyAPI) & B(Bing API)
    end
    B <--> C
    A <--> C
    subgraph fetcher.py
    C[[Fetch latest astros data]] --> D[(db.json)] & E[(log.json)] --> F(Commit & push)
    end
    F -->|Railway build triggered| G[Deployed to Railway]

Fetch and deploy

db.json contains the actual astronauts' database. log.json will store the date & time of the fetcher run.

The fetcher.py is scheduled to run automatically via GitHub action. The frequency is as defined in fetcher.yml script.

Hosted on Railway.

Honorable mentions

  1. http://open-notify.org/Open-Notify-API/People-In-Space/
  2. https://www.microsoft.com/en-us/bing/apis/bing-image-search-api
  3. Website template