All Projects → damienzeng73 → redash-api-client

damienzeng73 / redash-api-client

Licence: MIT license
Redash API Client written in Python

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to redash-api-client

nis-python-client
Python client for NEM NIS API (https://nemproject.github.io). XEM\NEM\Crypto
Stars: ✭ 16 (-55.56%)
Mutual labels:  api-client
backlog kit
Client library for the Nulab's Backlog API version 2 written in Ruby.
Stars: ✭ 28 (-22.22%)
Mutual labels:  api-client
closeio-api
Python API Client for Close
Stars: ✭ 53 (+47.22%)
Mutual labels:  api-client
my api client
A framework of Web API Client. Provides features error handling, retrying, pagination and so on.
Stars: ✭ 19 (-47.22%)
Mutual labels:  api-client
Clamor
The Python Discord API Framework
Stars: ✭ 14 (-61.11%)
Mutual labels:  api-client
braze-php-sdk
A PHP client to interact with Braze API
Stars: ✭ 15 (-58.33%)
Mutual labels:  api-client
JSON-API-Client
Abstract client-side php implementation of the json api specification (jsonapi.org)
Stars: ✭ 17 (-52.78%)
Mutual labels:  api-client
kdecole-api
Unofficial Node.js API client of Kdecole (Skolengo EMS)
Stars: ✭ 31 (-13.89%)
Mutual labels:  api-client
ssc-restapi-client
Communicate with Fortify Software Security Center through REST API in java, a swagger generated client
Stars: ✭ 13 (-63.89%)
Mutual labels:  api-client
Jib.jl
A Julia implementation of Interactive Brokers API
Stars: ✭ 42 (+16.67%)
Mutual labels:  api-client
bitflyer-api-dotnet-client
bitFlyer HTTP APIs Client Library for .NET (C#)
Stars: ✭ 23 (-36.11%)
Mutual labels:  api-client
jacky
🐄 HTTP JSON API Client for Laravel & Lumen
Stars: ✭ 17 (-52.78%)
Mutual labels:  api-client
dnsimple-python
The DNSimple API client for Python.
Stars: ✭ 66 (+83.33%)
Mutual labels:  api-client
cells-client
Command line client to communicate with cells REST api.
Stars: ✭ 17 (-52.78%)
Mutual labels:  api-client
wporg-client
Standalone HTTP client for public WordPress.org API.
Stars: ✭ 73 (+102.78%)
Mutual labels:  api-client
tempo-api-python-client
Python bindings for Tempo - https://apidocs.tempo.io/
Stars: ✭ 17 (-52.78%)
Mutual labels:  api-client
v-shopware-api-client
The reliable way to import and update a bazillion products.
Stars: ✭ 20 (-44.44%)
Mutual labels:  api-client
jellyfin-apiclient-python
Python API Client for Jellyfin
Stars: ✭ 30 (-16.67%)
Mutual labels:  api-client
NClient
💫 NClient is an automatic type-safe .Net HTTP client that allows you to call web service API methods using annotated interfaces or controllers without boilerplate code.
Stars: ✭ 25 (-30.56%)
Mutual labels:  api-client
pywnedpasswords
Checkt pwnedpasswords.com in a secure way
Stars: ✭ 22 (-38.89%)
Mutual labels:  api-client

Redash-API-Client

PyPI version fury.io PyPI pyversions PyPI license Downloads

Redash API Client written in Python.

Dependencies

  • Python3.6+

Installation

pip install redash-api-client

Getting Started

from redashAPI import RedashAPIClient

# Create API client instance
"""
    :args:
    API_KEY
    REDASH_HOST (optional): `http://localhost:5000` by default
"""
Redash = RedashAPIClient(API_KEY, REDASH_HOST)

Redash's RESTful API

URI Supported Methods
users GET, POST
users/1 GET, POST
data_sources GET, POST
data_sources/1 GET, POST, DELETE
queries GET, POST
queries/1 GET, POST, DELETE
query_results POST
query_results/1 GET
visualizations POST
visualizations/1 POST, DELETE
dashboards GET, POST
dashboards/slug GET, POST, DELETE
widgets POST
widgets/1 POST, DELETE
### EXAMPLE ###

# List all Data Sources
res = Redash.get('data_sources')
res.json()
"""
[
    {
        'name': 'data_source1',
        'pause_reason': None,
        'syntax': 'sql',
        'paused': 0,
        'view_only': False,
        'type': 'pg',
        'id': 1
    },
    ...
]
"""

# Retrieve specific Data Source
res = Redash.get('data_sources/1')
res.json()
"""
{
    "scheduled_queue_name": "scheduled_queries",
    "name": "test1",
    "pause_reason": "None",
    "queue_name": "queries",
    "syntax": "sql",
    "paused": 0,
    "options": {
        "password": "--------",
        "dbname": "bi",
        "user": ""
    },
    "groups": {
        "1":False
    },
    "type": "pg",
    "id": 1
}
"""

# Create New Data Source
Redash.post('data_sources', {
    "name": "New Data Source",
    "type": "pg",
    "options": {
        "dbname": DB_NAME,
        "host": DB_HOST,
        "user": DB_USER,
        "passwd": DB_PASSWORD,
        "port": DB_PORT
    }
})
"""
{
    "scheduled_queue_name": "scheduled_queries",
    "name": "New Data Source",
    "pause_reason": "None",
    "queue_name": "queries",
    "syntax": "sql",
    "paused": 0,
    "options": {
        "dbname": DB_NAME,
        "host": DB_HOST,
        "user": DB_USER,
        "passwd": DB_PASSWORD,
        "port": DB_PORT
    },
    "groups": {
        "2": False
    },
    "type": "pg",
    "id": 2
}
"""

# Delete specific Data Source
Redash.delete('data_sources/2')

Create Data Source

  • _type

  • name

    • Name for Data Source.
  • options

    • Configuration.
### EXAMPLE ###

Redash.create_data_source("pg", "First Data Source", {
    "dbname": DB_NAME,
    "host": DB_HOST,
    "user": DB_USER,
    "passwd": DB_PASSWORD,
    "port": DB_PORT
})

Create Query

  • ds_id

    • Data Source ID.
  • name

    • Name for query.
  • qry

    • Query string.
  • desc (optional)

    • Description.
  • with_results (optional)

    • Generate query results automatically, True by default.
  • options (optional)

    • Custom options.
### EXAMPLE ###

Redash.create_query(1, "First Query", "SELECT * FROM table_name;")

Refresh Query

  • qry_id

    • Query ID.
### EXAMPLE ###

Redash.refresh_query(1)

Generate Query Result

  • ds_id

    • Data Source ID.
  • qry

    • Query String.
  • qry_id (optional)

    • Query ID.
  • max_age (optional)

    • If query results less than max_age seconds old are available, return them, otherwise execute the query; if omitted or -1, returns any cached result, or executes if not available. Set to zero to always execute.
  • parameters (optional)

    • A set of parameter values to apply to the query.
  • return_results (optional)

    • Return results if query is executed successfully, True by default.
### EXAMPLE ###

Redash.generate_query_results(1)

Query and Wait Result

  • ds_id

    • Data Source ID.
  • qry

    • Query String.
  • timeout (optional)

    • Defines the time in seconds to wait before cutting the request.
### EXAMPLE ###

Redash.query_and_wait_result(1, 'select * from my_table;', 60)

Create Visualization

  • qry_id

    • Query ID.
  • _type

    • Type of Visualization. (table, line, column, area, pie, scatter, bubble, box, pivot)
  • name

    • Name for Visualization.
  • columns (optional)

    • Columns for Table. (Required if _type is table)
  • x_axis (optional)

    • Column for X Axis. (Required if _type is not table nor pivot)
  • y_axis (optional)

    • Columns for Y Axis (Required if _type is not table nor pivot)
  • size_column (optional)

    • Column for size. (Bubble)
  • group_by (optional)

    • Group by specific column.
  • custom_options (optional)

    • Custom options for Visualization.
  • desc (optional)

    • Description.
### EXAMPLE 1 ###

Redash.create_visualization(1, "table", "First Visualization", columns=[
    {"name": "column1", "type": "string"},
    {"name": "column2", "type": "datetime"}
])

### EXAMPLE 2 ###
Redash.create_visualization(1, "line", "Second Visualization", x_axis="column1", y_axis=[
    {"type": "line", "name": "column2", "label": "c2"}
])

Create Dashboard

  • name

    • Name for Dashboard.
### EXAMPLE ###

Redash.create_dashboard("First Dashboard")

Add Widget into Dashboard

  • db_id

    • Dashboard ID.
  • text (optional)

    • Text Widget.
  • vs_id (optional)

    • Visualization ID.
  • full_width (optional)

    • Full width or not, False by default.
  • position (optional)

    • Custom position for Widget.
### EXAMPLE 1 ###

Redash.add_widget(1, text="Test")

### EXAMPLE 2 ###
Redash.add_widget(1, visualization_id=1, full_width=True)

Publish Dashboard

  • db_id

    • Dashboard ID.
### EXAMPLE ###

url = Redash.publish_dashboard(1)

License

This project is licensed under the MIT License - see the LICENSE file for details.

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