Giter Site home page Giter Site logo

deeplook / ipyrest Goto Github PK

View Code? Open in Web Editor NEW
25.0 6.0 4.0 518 KB

An emerging widget for exploring RESTful APIs in Jupyter notebooks.

License: MIT License

Python 94.84% Makefile 4.52% Shell 0.64%
rest restful api postman jupyter ipywidget widget notebook mime-types python3

ipyrest's Introduction

Ipyrest

Binder Nbviewer Travis-CI image image image image image Say Thanks!

Ipyrest is an emerging Jupyter notebook widget for exploring RESTful APIs. It has two main goals: provide a more convenient interface in the spirit of Postman, and allow for plug-in components, starting with output renderers for various MIME types, e.g. GeoJSON, see below.

About

At its core ipyrest is a wrapper for the excellent requests package based on the equally excellent ipywidgets package. The idea is to provide more interactive exploration capabilities when working with RESTful APIs. It does so by letting you build requests for an API call and understand more quickly the responses you receive. To that end you can use existing views for requests and responses or build your own. It is inspired by Postman, but without the bloat, and goes beyond it to make sure you can extend it the way you want. In essence, it's for data scientists rather than web developers.

Example

from ipyrest import Api

# Fix content-type as it is not set for gists.
def reset_content_type(resp):
    resp.headers['Content-Type'] = 'application/vnd.geo+json'

url = 'https://gist.githubusercontent.com/' \
      'deeplook/71e9ded257cfc2d8e5e9/raw/f0cfbab5f266fcb8056e8aea046f1f222346b76b/2013.geojson'
Api(url, post_process_resp=reset_content_type)

banner

Features

Ipyrest deals with the following concepts, implemented to varying degrees: HTTP Server, Service, Request, Response, Data, MIME-Types, Compression, Logging, Caching, Time-Outs, Errors, Views, Plugins, Testing, and UI.

At the moment the following plugins are available for rendering output from HTTP responses in common formats: Plain Text, CSV, HTML, Bitmaps, SVG, JSON, GeoJSON, GPX, Protobuf, (and some experimental 3D stuff).

The main dependencies are: Python >= 3.6, jupyter, ipywidgets, timeout_decorator, requests, and vcr. Plugin dependencies are: ipyleaflet, ipyvolume, geojson, qgrid, protobuf. Testing dependencies are flask, mypy, and pytest.

Installation

Released versions of ipyrest can be installed from PyPI with:

pip install ipyrest

Development versions of ipyrest can be installed either directly from GitHub or after downloading/cloning and unpacking like this in its top-level directory:

pip install git+https://github.com/deeplook/ipyrest

pip install -e .

Testing

Run pip install -r requirements_test.txt and PYTHONPATH=. pytest -s -v tests in the root directory. Some tests will automatically start a local flask webserver in tests/api_server.py which implements a set of sample API endpoints for local testing. And some of these tests need keys/tokens defined as environment variables for the respective APIs being tested. If not present these tests will be skipped.

Documentation

The docs folder is only a stub for now. At the moment it is recommended to look at examples/meetup.ipynb, mostly a tutorial-like collection of examples given as a presentation at a meetup. Some of these need appropriate API keys.

How to Contribute

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug or example for some API (ideally without authentication), e.g. from the extensive collection of Public APIs.
  2. Fork the repository on GitHub to start making your changes to the master branch (or branch off of it).
  3. Write a test which shows that the bug was fixed or that the feature works as expected.
  4. Send a pull request and bug the maintainer until it gets merged and published. :) Make sure to add yourself to AUTHORS.

ipyrest's People

Contributors

deeplook avatar deepsource-autofix[bot] avatar deepsourcebot avatar jtpio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ipyrest's Issues

Evolution

Hello,
I've found this widget very promising,
I'm a teacher and I'm using it in my class to explore elasticsearch in a notebook.
I was wondering if this project will continue and can be supported in some way
and if it can work also in jupyter lab.
Thanks
Salvo

Find and use file extension in URL in addition to MIME types

Given that many sites do not provide proper MIME types for some content, like GitHub gists, it would be useful to try extracting a "file extension" from the URL and derive a MIME type and ipyrest response view. Either using the builtin mimetypes and/or some additional mapping. Then it would be less necessary to use a separate step for post-processing the response before rendering it.

How to launch ipyrest

Silly question I know but how do I use or launch ipyrest? I'm not familiar with Jupyter notebooks so is that where I need to go learn to be able to use ipyrest?

In advance, thank you for your time!

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.