Welcome to the Boat and Load Tracker API!
Caution
This deployed API connects to a production database to store data on a cloud server. To ensure your privacy, kindly refrain from entering any personal/sensitive information.
The Boat and Load Tracker is a supply chain API that allows a user to perform various interdependent Create, Read, Update and Delete (CRUD) operations on entities such as Owners, Boats and Loads. Secure access is to the API is implemeted with Auth0. API documentation is included which details endpoint calls and responses.
The following is a brief overview of the file structure
./API documentation.pdf - Describes API endpoint calls & responses
./templates - Home screen for API login
./boats.py - Route handler for boat endpoints
./loads.py - Route handler for load endpoints
./owner.py - Route handler for owner enpoint
This API includes the following features:
- A homescreen to authentic new and current users with Auth0.
- Bearer token is issued from Auth0 and is used to securely perform CRUD operations for JWT protected endpoints (endpoints associated with an owner)
- All entities are stored in Google Datastore (Owners, Boats and Loads)
- API documentation
- Postman collection included for testing.
- REST architecture for scalability, flexibility simplicity and ease of use.
Welcome Screen
Auth0 Login Screen
Callback screen with JWT infomation
- Programming Languages: Python, Javascript, HTML
- Frameworks: Flask-RESTful
- API testing: Postman
- Access Management: Auth0
You may make API calls using the host URL (listed in resume) and endpoints (listed in the documentaion) with a method of your choosing. Please keep in mind that the request header will require your bearer token. Retrieve your bearer token using Option 2, section 3.1 - 3.3.
Example POST request using Python:
import requests
# Refer to API doc for endpoints
url = 'ADD URL FROM RESUME HERE' + 'ADD ENDPOINT HERE'
bearer_token = "ADD BEARER TOKEN HERE"
headers = {
'Authorization': f'Bearer {bearer_token}',
'Content-type': 'application/json'
}
# Refer to API doc for keys and values for post requests
body = {
'key1': 'value1',
'key2': 'value2',
'key3': 'value3'
}
# Create the post request. Store the response in "response"
response = requests.post(url, headers=headers, json=body)
# Print the status code and response
print(f'Status Code {response.status_code}')
print(f'Response Text: {response.json()}')Example GET request using Python:
import requests
# Refer to API doc for endpoints
url = 'ADD URL FROM RESUME HERE' + 'ADD ENDPOINT HERE'
bearer_token = "ADD BEARER TOKEN HERE"
headers = {
'Authorization': f'Bearer {bearer_token}',
'Content-type': 'application/json'
}
# Create the get request. Store the response in "response"
response = requests.get(url, headers=headers)
print(f'Status Code {response.status_code}')
print(f'Response Text: {response.json()}')PUT, PATCH and DELETE requests are constructed similarly. The requests method will need to be changed and the body may need to be included. Please see API doc for details.
Prerequisites: Postman
You may explore the API using the proivded Postman Environment and Collection.
Note
If you would prefer not to use your own email to create an Auth0 account (section 3), you may use a disposable email from temp-email.org/en
Once you have downloaded Postman:
- Configure the Postman environment
- Download the Postman environment Environment File
- Open Postman, click on the Environments tab on the left side
- Drag the downloaded environment file into the environment pane of Postman.
- In the top right corner of the application window, there may be a dropdown menu that says "No Environment". Click this dropdown and select the environment that was added.
- Add the Postman Collection
- Download the Postman Collection Collection File
- Click on the Collections tab on the left side of the Postman application.
- Drag the downloaded collection file into the Postman collections pane
- Retrieve a Bearer token
- Access the API login page (see resume for URL)
- Following the instructions, you will be re-routed to Auth0 to login or create a new user account.
- After successful login, you will be redirected to the back to the API login page. Your bearer token will be displayed under "Encoded JWT". Please copy this bearer token
- Add the App URL your Bearer token to the Postman environment
- Open the enviroments tab in Postman
- Double click on the environment tab.
- Add your Bearer token to "jwt1" variable in both the current value and initial value fields.
- Add the App URL (listed in the resume) to the "app_url" variable in both the current value and initial value fields.
- Run the collection
- Click on the collections tab on the left pane
- right click on the collection and select "run collection.