Git Product home page Git Product logo

priceapi's Introduction

priceAPI

Description

A python API to retrieve and search prices of construction materials and services. On startup, it builds several default prices sources from the files found in the data folder. Each of these sources can be easily rebuilt when updated data becomes available online.

Data sources contain a couple of generic fields such as Name, Month, Year, Currency, an URL to download price data when rebuilding, and an URL to check for updated contents. Price data itself is in the form of a table with 4 columns: Code (not very useful, each source uses its own coding system), description, price and unit.

New data sources can be added by instantiating the base source class, and writing a new build() method.

Current sources:

  • PMSP (Prefeitura Municipal de São Paulo)
  • FDE-SP (Secretaria da Educação do Estado de São Paulo)
  • SINAPI-SP (Sistema de pesquisa de preços unitários da Caixa Federal - Estado de São Paulo)

Installation

The following python modules must be present to rebuild the sources. They are not needed to simply run a search:

  • csv
  • urllib2
  • xlrd
  • openpyxl

Usage

Usage: priceapi.py [OPTIONS] searchterm1|alternativeterm1 searchterm2 ...

Separate search term by a space to retrieve only entries that contain all the search terms. Use a | character to separate alternative search term (entries containing one OR the other will be retrieved).

Options:

--location=XXX: Specify a city or country name to limit the search to.

--source=XXX: Specify a source name or comma-separated list of source names to limit the search to.

--code=XXX: Searches for a specific code. Dots and hyphens are ignored.

Example: priceapi.py --source=PMSP alvenaria 14cm

The API can also be used from python:

import priceapi
priceapi.search("alvenaria 14cm")

Which will display a table like this:

Origin    Code      Description                                                             Price     Unit

FDE-SP    04.01.031 ALVENARIA DE BLOCOS DE CONCRETO E=14CM                                  73.99     M2

SINAPI-SP 87449     ALVENARIA DE VEDAÇÃO DE BLOCOS VAZADOS DE CONCRETO DE 14X19X39CM (ESPE  57.62     M2
                    SSURA 14CM) DE PAREDES COM ÁREA LÍQUIDA MENOR QUE 6M² SEM VÃOS E ARGAM
                    ASSA DE ASSENTAMENTO COM PREPARO EM BETONEIRA. AF_06/2014
...

To search for several terms, just use a space between them.

To Do

  • Allow to search alternative terms (term1 OR term2)
  • Allow to search by location
  • Allow to search by code
  • Add computer-readable output
  • Allow to use the script from the command line
  • Allow to convert/update prices by using an index value like CUB in Brazil
  • Add more sources (outside Brazil if possible)
  • Build a GUI?
  • Parse the SINAPI pdfs (currently using an xlsx from a website where a kind soul provides a conversion)

priceapi's People

Contributors

yorikvanhavre avatar theoryshaw avatar

Watchers

 avatar James Cloos 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.