/farmers-markets

An open API of farmer's market data across the U.S.

Primary LanguagePythonMIT LicenseMIT

Farmer's Markets

Farmer's Markets is a simple API built with data from: https://catalog.data.gov/dataset/farmers-markets-geographic-data.

Table of Contents

Tech Stack

Backend: Python, Flask, Flask-RESTful PostgreSQL, PostGIS, SQLAlchemy, GeoAlchemy2
Frontend: JSON

How to Run Farmer's Markets Locally

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

  1. Python 2.7.0
  2. PostgreSQL

Installation Instructions

  1. Clone this repository:
$ git clone https://github.com/jttyeung/farmers-markets.git
  1. Set up a Python virtualenv and activate it.
$ virtualenv env
$ source env/bin/activate
  1. Install all app dependencies listed in requirements.txt.
$ pip install -r requirements.txt
  1. Make sure you have PostgreSQL running (psql).
  2. Create a database named farmers-markets.
$ createdb farmers-markets
  1. Open the database, add the PostGIS database extension, and exit out of the database.
$ psql farmers-markets
CREATE EXTENSION postgis;
\quit
  1. Create tables in your database.
$ python model.py
  1. Go into the /static/data/ directory and seed the database using the dump.sql file.
$ cd static/data
$ psql farmers-markets < dump.sql
  1. Start the Flask server.
$ python server.py
  1. Go to localhost:5000 to view the application.

Usage

To use the app, simply visit one of the REST API endpoints to retrieve data:

  • /markets - This will give you data for all the markets in the U.S.
  • /markets/<fm_id> - Search data by farmer's market ID.
  • /markets/<state_id> - Search data by state ID. -- coming soon!

Author

Joanne Yeung is a full-stack engineer in San Francisco, CA. Learn more on LinkedIn: https://linkedin.com/in/jttyeung

License

This project is licensed under the MIT License.