You've got a spreadsheet full of data.
How do you quickly get this data up as an API endpoint for use in Websites/Web-Apps/Mobile-Apps?
This article will show you the simple steps to get here
Mac OS X or Linux Based Machine
Python and pip installed (usually this is already there by default)
Step 1) Start with your data in the spreadsheet
Step 2) Download your spreadsheet as a CSV file (comma seperated values)
Step 3) Use a csv -> json convertor. I will use https://www.csvjson.com/csv2json Download the Json File created.
Step 4) Now I have the json file I am going to serve using Flask.
Step 5) Install Python Flask on your machine.
$ pip install Flask
Step 6) Create a directory folder and a "data" sub-folder. Add your data.json to the "data" folder.
Step 7) In your main directory. Create a new python file called server.py
Step 8) Open your server.py file in a text editor (like notepad or sublime) and add the following 8 lines of code.
from flask import Flask, render_template from flask import url_for app = Flask(__name__, static_url_path='/static') @app.route('/') def send(): return "file" % url_for('static', filename='data.json') if __name__ == '__main__': app.run()
Step 9) In your terminal navigate to your folder where the server.py file is sitting.
> cd api > FLASK_APP=server.py flask run
This should start the Flask server locally on your computer. Likely http://localhost:5000
If you navigate in your browser to the URL http://localhost:5000/static/data.json you should now have an endpoint that is serving an array of JSON data, ready for use in your application.
You have just created your first API endpoint and a simple web-server to boot
Keep on Learning!