Giter Club home page Giter Club logo

salary-api's Introduction

REST API

what is this?

simple api example using flask. a flask api object contains one or more functionalities (GET, POST, etc).

Create virtenv for the project:

  1. $ virtualenv rest-api
  2. $ source rest-api/bin/activate
  3. $ mkdir ~/rest-app
  4. $ cd ~/rest-app

Clone the repo to 'rest-app' project workspace:

git clone https://github.com/95rade/Salary-API.git

Import db to sqlite3:

  1. $ sqlite3 salaries.db
  2. sqlite> .mode csv salaries
  3. sqlite> .import employee_chicago.csv salaries

Note: Every time db is updated you have to re-import it into sqlite3:

install modules:

pip install -r requirements.txt
pip freeze

run

python app.py

then go to http://localhost:5000/departments

you could drill down by deparments too!

try http://localhost:5000/dept/police

My code walk-through is as follows

  • I downloaded latest Salary dataset from chicago data site

  • Dumped that CSV into my SQLite db.

  • Used SQLAlchemy to connect to database and do select operations.

  • Created Flask-Restful classes to map functions with API URL

  • Returned the queried data as JSON ,which can be used universally.

See how simple it is to create a data API. We can also add support to PUT,POST and DELETE on data too.We can also have an authentication system for fetching data through API. Python and Flask are very powerful tools to create API rapidly. GitHub link is given below. Give it a try and extend it with the things mentioned above.

https://github.com/narenaryan/Salary-API

ToDo: Add POST, PUT and DELETE methods.

salary-api's People

Contributors

95rade avatar kwikiel avatar mynameisvinn avatar narenaryan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.