All Projects â†’ mheadd â†’ simple-rest-api

mheadd / simple-rest-api

Licence: other
😎 A simple RESTful API in three easy steps.

Projects that are alternatives of or similar to simple-rest-api

worldcup
Free open public domain football data for the World Cup (incl. Qatar 2022, Russia 2018, Brazil 2014, etc.) and World Cup Quali(fiers)
Stars: ✭ 530 (+2020%)
Mutual labels:  opendata
dtp-stat-archive
Карта ДТП v1.0. 👉 База знаний о проекте: https://github.com/dtpstat/dtp-project/wiki
Stars: ✭ 142 (+468%)
Mutual labels:  opendata
who-owns-what
Who owns what in nyc?
Stars: ✭ 146 (+484%)
Mutual labels:  opendata
covid19-time-series-utilities
several utilities to help wrangle COVID-19 data into a time-series format
Stars: ✭ 34 (+36%)
Mutual labels:  opendata
solidata frontend
first draft for solidata_frontend : vue+nuxt+vuetify+i18n+axios
Stars: ✭ 15 (-40%)
Mutual labels:  opendata
dwdweather2
Python client to access weather data from Deutscher Wetterdienst (DWD), the federal meteorological service in Germany.
Stars: ✭ 68 (+172%)
Mutual labels:  opendata
SemanticWikibase
Makes Wikibase data available in Semantic MediaWiki
Stars: ✭ 14 (-44%)
Mutual labels:  opendata
coletores
Coletores de dados sobre remunerações do sistema de justiça brasileiro
Stars: ✭ 18 (-28%)
Mutual labels:  opendata
open.undp.org
[DEPRECATED]: UNDP Project Portal
Stars: ✭ 21 (-16%)
Mutual labels:  opendata
operacao-politica-supervisionada
Sistema de auditoria da OPS
Stars: ✭ 52 (+108%)
Mutual labels:  opendata
tweetyourmep
TweetyourMEP
Stars: ✭ 17 (-32%)
Mutual labels:  opendata
ra-data-postgrest
react admin client for postgREST
Stars: ✭ 80 (+220%)
Mutual labels:  postgrest
espana
Free open public domain football data (football.db) for España (Spain) / Europe - Primera División / La Liga, etc.
Stars: ✭ 64 (+156%)
Mutual labels:  opendata
qsv
CSVs sliced, diced & analyzed.
Stars: ✭ 438 (+1652%)
Mutual labels:  opendata
EconData
R package containing a host of datasets useful for economic research. Complete with raw data and cleaning functions.
Stars: ✭ 28 (+12%)
Mutual labels:  opendata
websegura
Analizamos y mostramos seguridad HTTPS de sitios web públicos, como medida para visualizar aquellos que pueden suponer un riesgo para sus usuarios.
Stars: ✭ 27 (+8%)
Mutual labels:  opendata
data-federation-project
A project focused on tools and best practices to supported federated data collection efforts
Stars: ✭ 27 (+8%)
Mutual labels:  opendata
coronavirus-dresden
Collects official SARS-CoV-2 infection statistics published by the city of Dresden.
Stars: ✭ 19 (-24%)
Mutual labels:  opendata
2017-wmata-ridership-data
Intraday ridership data from Washington Metro Area Transit Authority for 2009 and 2017 inaugurations and the Women's March.
Stars: ✭ 15 (-40%)
Mutual labels:  opendata
database-of-embassies
Database of embassies and consulates. Download as CSV, no registration, public domain. Powered by Wikidata.
Stars: ✭ 33 (+32%)
Mutual labels:  opendata

Simple REST API in 3 Easy Steps

A powerful, simple, RESTful API generated from a CSV or text document in three easy steps.

Build a REST API from a CSV in 3 easy steps

In order to follow these steps, you'll need to have Docker and csvkit installed.

Run Postgres container

Set up a Docker container to run the Postgres database. You can write your own Dockerfile to do this, or just pull the latest from Docker Hub.

~$ docker pull postgres

Now, run the container and pass in environmental variables to set the user, password and to create a database. (Note, the user created using this command will have superuser privileges but you can access container and set up a read only user if preferred. More info in the docs.)

~$ docker run --name postres-database \
-p 5432:5432 \
-e POSTGRES_USER=simpleapi \
-e POSTGRES_PASSWORD=simpleapi \
-e POSTGRES_DB=simpleapi \
-d postgres:latest

Run PostgREST and link it to Postgres container

Set up a Docker container to run PostgREST and connect to the Postgres database container. Again, you can write your own Dockerfile for this (or use this one), or just pull one of the many fine PostgREST images on Docker Hub.

~$ docker pull suzel/docker-postgrest

Now, run the container and pass in the details of the Postgres container.

~$ docker run --name postgrest-service \
-p 3000:3000 \
-e POSTGREST_VERSION=0.3.1.1 \
-e POSTGREST_DBHOST={docker-container-ip} \
-e POSTGREST_DBPORT=5432 \
-e POSTGREST_DBNAME=simpleapi \
-e POSTGREST_DBUSER=simpleapi \
-e POSTGREST_DBPASS=simpleapi \
-d suzel/docker-postgrest:latest

Now you should be able to see both containers running in Docker:

~$ docker ps

CONTAINER ID        IMAGE                           COMMAND                  CREATED             STATUS              PORTS                    NAMES
f667f2e68157        suzel/docker-postgrest:latest   "/bin/sh -c 'postgres"   2 minutes ago       Up 2 minutes        0.0.0.0:3000->3000/tcp   postgrest-service
f46707bbd549        postgres:latest                 "/docker-entrypoint.s"   2 minutes ago       Up 2 minutes        0.0.0.0:5432->5432/tcp   postres-database

Insert Data and Test API

Now, lets get some data.

~$ curl -s "http://data.louisvilleky.gov/sites/default/files/temp_import/FoodServiceData.txt" > inspections.csv

Check to make sure the data is valid CSV and then inset it into our Postgres instance from step 1 above using csvkit.

~$ csvsql --db postgres://simpleapi:simpleapi@{docker-container-ip}:5432/simpleapi --insert inspections.csv

Now, you can access the data at: http://{docker-container-ip}:3000/

You can query the data using the PostgREST query API, like so:

~$ curl -s "http://192.168.99.100:3000/inspections?Grade=eq.A" -H 'Range-Unit: items' -H 'Range: 0-1' | jq .
[
  {
    "Intersection": null,
    "State": "KY",
    "City": "LOUISVILLE",
    "Address2": null,
    "Address": "MOBILE FOOD UNIT",
    "PlaceName": null,
    "EstablishmentName": "FUNNEL CAKE #5",
    "InspectionID": 1104831,
    "EstablishmentID": 27867,
    "Zip": 40202,
    "TypeDescription": "SELF-CONTAINED MOBILE FOOD UNITS",
    "Latitude": 38.2526647,
    "Longitude": -85.7584557,
    "InspectionDate": "2015-05-24",
    "Score": 98,
    "Grade": "A",
    "NameSearch": "FUNNELCAKE"
  },
  {
    "Intersection": null,
    "State": "KY",
    "City": "LOUISVILLE",
    "Address2": null,
    "Address": "MOBILE FOOD UNIT",
    "PlaceName": null,
    "EstablishmentName": "FUNNEL CAKE #5",
    "InspectionID": 1132274,
    "EstablishmentID": 27867,
    "Zip": 40202,
    "TypeDescription": "SELF-CONTAINED MOBILE FOOD UNITS",
    "Latitude": 38.2526647,
    "Longitude": -85.7584557,
    "InspectionDate": "2015-08-25",
    "Score": 100,
    "Grade": "A",
    "NameSearch": "FUNNELCAKE"
  }
]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].