Coder Social home page Coder Social logo

codeops_week1's Introduction

APIDATAHANDLER

This project is created to help users fetch data out of API with specific URL type, such as, www.exampple.com/objectID, www.exampple2.com/objectID with range [0-9], www.exampple.com/somedata. The data retrieved(should be in JSON format) can be used to to generate the reports in [*.json, *.html, *.pdf, *.xml, *.xlsx] format.

Example Code:

  • To fetch the data out of the API
from apidatahandler import ApiDataHandler

    URL = 'https://ghibliapi.herokuapp.com/films'

    try:
        object_to_fetch_data = ApiDataHandler(URL)
        response_data = object_to_fetch_data.request_to_response()
    except TypeError as te:
        logging.error('%s: %s', {te.__class__.__name__}, {te})
        sys.exit(1)
    except json.JSONDecodeError as jde:
        logging.error('%s: %s', jde.__class__.__name__, jde)
        sys.exit(1)
    except KeyError as key_err:
        logging.error('%s: %s', key_err.__class__.__name__, key_err)
  • To generate the reports from Json data
 object_to_fetch_data.json_to_sheets(json_data=data, file_format='csv',
                                            filename=rel_path + 'filename.csv',
                                            encoding='utf-8', index=False)
 object_to_fetch_data.json_to_sheets(json_data=data, file_format='excel',
                                            filename=rel_path + 'filename.xlsx',
                                            encoding='utf-8', index=False)
 object_to_fetch_data.json_to_sheets(json_data=data, file_format='xml',
                                            filename=rel_path + 'filename.xml',
                                            encoding='utf-8', index=False)
 object_to_fetch_data.json_to_html(json_data=data,
                                          filename=rel_path + 'ghibliStudioApi_raw_html.html',
                                          index=False, render_links=False, encoding='utf-8',
                                          columns=['id', 'title', 'original_title',
                                                   'image', 'director', 'producer', 'release_date',
                                                   'running_time', 'people', 'species',
                                                   'locations', 'vehicles'])
 object_to_fetch_data.htmltopdf(html_file=rel_path + 'ghibliStudioApi_raw_html.html',
                                       pdf_file=rel_path + 'ghibliStudioApi_raw_pdf_match.pdf',
                                       options={'orientation': 'Landscape', 'page-size': 'A3'})


All the Python files are stored inside the python_file folder for easy interaction.
For more info please check apidatahandler file.

codeops_week1's People

Contributors

saatwik-mehta avatar

Stargazers

Roman 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.