This API is a Gradle project using Nasa's APOD API.
- Clone the project
git clone https://github.com/G1TS23/Apod.gitcdinto the new directory
cd apod-
Rename
application.properties.example(in /src/main/resources/) toapplication.properties -
Replace information in
application.propertiessuch as :
- Your Database information
5 # Database
6 spring.datasource.url=jdbc:mysql://localhost:3306/apod
7 spring.datasource.username=REPLACE_WITHI_YOUR_DB_USERNAME
8 spring.datasource.password=REPLACE_WITHI_YOUR_DB_PASSWORD
- Your own JWT Secret
24 # Security
25 jwt.secret=REPLACE_WITH_YOUR_OWN_JWT_SECRET
- Your own NASA API Key from https://api.nasa.gov
41 #API
42 api.url=https://api.nasa.gov/planetary/apod
43 api.key=REPLACE_WITH_YOUR_OWN_API_KEY
-
Run your mysql server and create a schema named
apod -
Run the application
There's three different roles :
- ADMIN has access to a simple CRUD for stored Apod
- USER can call two endpoints that bounce to Nasa's API :
- /api : the picture of day
- /api/range?from=2025-02-01&to=2025-02-03 : pictures or videos within a time range)
- SCRAPPER has almost the same endpoints but that stores object in database :
- /api/scrap/today
- /api/scrap/range?from=2025-02-11&to=2025-02-14
In root directory there's a collection Apod_Bruno_Collection.json you can import in Bruno
or Postman to test the API. In order to store the userToken after login you to have to add
this post-request script :
- Bruno :
var jsonData = res.getBody();
bru.setEnvVar("userToken", jsonData.token);- Postman :
var jsonData = pm.response.json();
pm.environment.set("userToken", jsonData.token);In the collection properties create an environment variable called userToken.
- API : only for user role, bounce request from NASA's API
- CRUD : only for admin role, manipulate database
- SCRAP : only for scrapper role, retrieve data from NASA's API and store it in database
- USER : log in, register, view credentials and log out
- Olivier Falahi (based on code by Simon Bédard)