This repository contains scripts to fetch marina data from the Marinas.com API and process it into an Excel file. This guide will help you replicate the process.
We use the Marinas.com API to retrieve data about marinas across the United States. The data is fetched in chunks, processed on the fly, and saved into a tabular format suitable for ingestion into Excel.
+------------------------+
| Grid Points (Lat/Lon)|
| Generation |
+-----------+------------+
|
v
+-----------+------------+
| Fetch Data Using curl |
| (Marinas.com API) |
+-----------+------------+
|
v
+-----------+------------+
| Flatten JSON Structure|
+-----------+------------+
|
v
+-----------+------------+
| Append Data to List |
+-----------+------------+
|
v
+-----------+------------+
| Convert List to DataFrame |
+-----------+------------+
|
v
+-----------+------------+
| Save DataFrame to Excel |
+------------------------+
fetch_and_process_marinas_us.py
: Main script to fetch and process marina data for the entire US.us_marinas_data_small_area.xlsx
: Example output file for a smaller test area.
-
Clone the repository
git clone https://github.com/yourusername/marinas.git cd marinas
-
Install dependencies
pip install pandas
-
Get an API Key
Register on Marinas.com and get an API key.
-
Set the API Key
Open the
fetch_and_process_marinas_us.py
script and replace theapi_key
variable with your API key.
-
Run the script
python fetch_and_process_marinas_us.py
This will fetch marina data for the entire US, process it, and save the results to an Excel file (
us_marinas_data.xlsx
).
This script performs the following steps:
- Grid Points Generation: Generates grid points for the entire US using 1-degree steps for latitude and longitude.
- Fetch and Process Data: For each grid point, it fetches data using
curl
, processes the JSON response, flattens the data, and appends it to a list. - Rate Limiting: Introduces a delay between requests to ensure no more than 300 requests per minute.
- Save to Excel: At the end, the list is converted to a DataFrame and saved to an Excel file (
us_marinas_data.xlsx
).
You can find an example output file for a smaller test area (us_marinas_data_small_area.xlsx
) in the repository.
- Ensure that you adhere to the rate limits specified by the Marinas.com API to avoid being blocked.
- The script covers the entire US; you can adjust the bounding box and grid steps for smaller regions if needed.
Feel free to fork this repository and submit pull requests if you have any improvements or additional features.
This project is licensed under the GPLv3+ License - see the LICENSE file for details.