API Reference

InfluxDBClient

class influxdb_client.InfluxDBClient(url, token, debug=None, timeout=10000, enable_gzip=False, org: str = None, default_tags: dict = None)[source]

InfluxDBClient is client for InfluxDB v2.

Initialize defaults.

Parameters:
  • url – InfluxDB server API url (ex. http://localhost:9999).
  • token – auth token
  • debug – enable verbose logging of http requests
  • timeout – default http client timeout
  • enable_gzip – Enable Gzip compression for http requests. Currently only the “Write” and “Query” endpoints supports the Gzip compression.
  • org – organization name (used as a default in query and write API)
authorizations_api() → influxdb_client.client.authorizations_api.AuthorizationsApi[source]

Create the Authorizations API instance.

Returns:authorizations api
buckets_api() → influxdb_client.client.bucket_api.BucketsApi[source]

Create the Bucket API instance.

Returns:buckets api
close()[source]

Shutdown the client.

delete_api() → influxdb_client.client.delete_api.DeleteApi[source]

Get the delete metrics API instance.

Returns:delete api
classmethod from_config_file(config_file: str = 'config.ini', debug=None, enable_gzip=False)[source]

Configure client via ‘*.ini’ file in segment ‘influx2’.

classmethod from_env_properties(debug=None, enable_gzip=False)[source]

Configure client via environment properties.

health() → influxdb_client.domain.health_check.HealthCheck[source]

Get the health of an instance.

Returns:HealthCheck
labels_api() → influxdb_client.client.labels_api.LabelsApi[source]

Create the Labels API instance.

Returns:labels api
organizations_api() → influxdb_client.client.organizations_api.OrganizationsApi[source]

Create the Organizations API instance.

Returns:organizations api
query_api() → influxdb_client.client.query_api.QueryApi[source]

Create a Query API instance.

Returns:Query api instance
ready() → influxdb_client.domain.ready.Ready[source]

Get The readiness of the InfluxDB 2.0.

Returns:Ready
tasks_api() → influxdb_client.client.tasks_api.TasksApi[source]

Create the Tasks API instance.

Returns:tasks api
users_api() → influxdb_client.client.users_api.UsersApi[source]

Create the Users API instance.

Returns:users api
write_api(write_options=<influxdb_client.client.write_api.WriteOptions object>, point_settings=<influxdb_client.client.write_api.PointSettings object>) → influxdb_client.client.write_api.WriteApi[source]

Create a Write API instance.

Parameters:
  • point_settings
  • write_options – write api configuration
Returns:

write api instance

QueryApi

class influxdb_client.QueryApi(influxdb_client)[source]

Implementation for ‘/api/v2/query’ endpoint.

Initialize query client.

Parameters:influxdb_client – influxdb client
query(query: str, org=None) → List[influxdb_client.client.flux_table.FluxTable][source]

Execute synchronous Flux query and return result as a List[‘FluxTable’].

Parameters:
  • query – the Flux query
  • org – organization name (optional if already specified in InfluxDBClient)
Returns:

query_csv(query: str, org=None, dialect: influxdb_client.domain.dialect.Dialect = {'annotations': ['datatype', 'group', 'default'], 'comment_prefix': '#', 'date_time_format': 'RFC3339', 'delimiter': ',', 'header': True})[source]

Execute the Flux query and return results as a CSV iterator. Each iteration returns a row of the CSV file.

Parameters:
  • query – a Flux query
  • org – organization name (optional if already specified in InfluxDBClient)
  • dialect – csv dialect format
Returns:

The returned object is an iterator. Each iteration returns a row of the CSV file (which can span multiple input lines).

query_data_frame(query: str, org=None, data_frame_index: List[str] = None)[source]

Execute synchronous Flux query and return Pandas DataFrame.

Note that if a query returns more then one table than the client generates a DataFrame for each of them.

Parameters:
  • query – the Flux query
  • org – organization name (optional if already specified in InfluxDBClient)
  • data_frame_index – the list of columns that are used as DataFrame index
Returns:

query_data_frame_stream(query: str, org=None, data_frame_index: List[str] = None)[source]

Execute synchronous Flux query and return stream of Pandas DataFrame as a Generator[‘pd.DataFrame’].

Note that if a query returns more then one table than the client generates a DataFrame for each of them.

Parameters:
  • query – the Flux query
  • org – organization name (optional if already specified in InfluxDBClient)
  • data_frame_index – the list of columns that are used as DataFrame index
Returns:

query_raw(query: str, org=None, dialect={'annotations': ['datatype', 'group', 'default'], 'comment_prefix': '#', 'date_time_format': 'RFC3339', 'delimiter': ',', 'header': True})[source]

Execute synchronous Flux query and return result as raw unprocessed result as a str.

Parameters:
  • query – a Flux query
  • org – organization name (optional if already specified in InfluxDBClient)
  • dialect – csv dialect format
Returns:

str

query_stream(query: str, org=None) → Generator[[influxdb_client.client.flux_table.FluxRecord, Any], None][source]

Execute synchronous Flux query and return stream of FluxRecord as a Generator[‘FluxRecord’].

Parameters:
  • query – the Flux query
  • org – organization name (optional if already specified in InfluxDBClient)
Returns:

WriteApi

class influxdb_client.WriteApi(influxdb_client, write_options: influxdb_client.client.write_api.WriteOptions = <influxdb_client.client.write_api.WriteOptions object>, point_settings: influxdb_client.client.write_api.PointSettings = <influxdb_client.client.write_api.PointSettings object>)[source]

Implementation for ‘/api/v2/write’ endpoint.

Initialize defaults.

flush()[source]

Flush data.

write(bucket: str, org: str = None, record: Union[str, List[str], influxdb_client.client.write.point.Point, List[Point], dict, List[dict], bytes, List[bytes], rx.core.observable.observable.Observable] = None, write_precision: influxdb_client.domain.write_precision.WritePrecision = 'ns', **kwargs) → Any[source]

Write time-series data into InfluxDB.

Parameters:
  • org (str) – specifies the destination organization for writes; take either the ID or Name interchangeably; if both orgID and org are specified, org takes precedence. (required)
  • bucket (str) – specifies the destination bucket for writes (required)
  • write_precision (WritePrecision) – specifies the precision for the unix timestamps within the body line-protocol. The precision specified on a Point has precedes and is use for write.
  • record – Points, line protocol, Pandas DataFrame, RxPY Observable to write
  • data_frame_measurement_name – name of measurement for writing Pandas DataFrame
  • data_frame_tag_columns – list of DataFrame columns which are tags, rest columns will be fields

BucketsApi

class influxdb_client.BucketsApi(influxdb_client)[source]

Implementation for ‘/api/v2/buckets’ endpoint.

Initialize defaults.

create_bucket(bucket=None, bucket_name=None, org_id=None, retention_rules=None, description=None) → influxdb_client.domain.bucket.Bucket[source]

Create a bucket.

Parameters:
  • bucket (Bucket) – bucket to create (required)
  • bucket_name – bucket name
  • description – bucket description
  • org_id – org_id
  • bucket_name – bucket name
  • retention_rules – retention rules array or single BucketRetentionRules
Returns:

Bucket If the method is called asynchronously, returns the request thread.

delete_bucket(bucket)[source]

Delete a bucket.

Parameters:bucket – bucket id or Bucket
Returns:Bucket If the method is called asynchronously, returns the request thread.
find_bucket_by_id(id)[source]

Find bucket by ID.

Parameters:id
Returns:
find_bucket_by_name(bucket_name)[source]

Find bucket by name.

Parameters:bucket_name – bucket name
Returns:Bucket
find_buckets()[source]

Get all buckets.

class influxdb_client.domain.Bucket(links=None, id=None, type='user', name=None, description=None, org_id=None, rp=None, created_at=None, updated_at=None, retention_rules=None, labels=None)[source]

NOTE: This class is auto generated by OpenAPI Generator.

Ref: https://openapi-generator.tech

Do not edit the class manually.

Bucket - a model defined in OpenAPI.

created_at

Get the created_at of this Bucket.

Returns:The created_at of this Bucket.
Return type:datetime
description

Get the description of this Bucket.

Returns:The description of this Bucket.
Return type:str
id

Get the id of this Bucket.

Returns:The id of this Bucket.
Return type:str
labels

Get the labels of this Bucket.

Returns:The labels of this Bucket.
Return type:list[Label]

Get the links of this Bucket.

Returns:The links of this Bucket.
Return type:BucketLinks
name

Get the name of this Bucket.

Returns:The name of this Bucket.
Return type:str
org_id

Get the org_id of this Bucket.

Returns:The org_id of this Bucket.
Return type:str
retention_rules

Get the retention_rules of this Bucket.

Rules to expire or retain data. No rules means data never expires.

Returns:The retention_rules of this Bucket.
Return type:list[BucketRetentionRules]
rp

Get the rp of this Bucket.

Returns:The rp of this Bucket.
Return type:str
to_dict()[source]

Return the model properties as a dict.

to_str()[source]

Return the string representation of the model.

type

Get the type of this Bucket.

Returns:The type of this Bucket.
Return type:str
updated_at

Get the updated_at of this Bucket.

Returns:The updated_at of this Bucket.
Return type:datetime

LabelsApi

class influxdb_client.LabelsApi(influxdb_client)[source]

Implementation for ‘/api/v2/labels’ endpoint.

Initialize defaults.

clone_label(cloned_name: str, label: influxdb_client.domain.label.Label) → influxdb_client.domain.label.Label[source]

Create the new instance of the label as a copy existing label.

Parameters:
  • cloned_name – new label name
  • label – existing label
Returns:

clonned Label

create_label(name: str, org_id: str, properties: Dict[str, str] = None) → influxdb_client.domain.label.Label[source]

Create a new label.

Parameters:
  • name – label name
  • org_id – organization id
  • properties – optional label properties
Returns:

created label

delete_label(label: Union[str, influxdb_client.domain.label.Label])[source]

Delete the label.

Parameters:label – label id or Label
find_label_by_id(label_id: str)[source]

Retrieve the label by id.

Parameters:label_id
Returns:Label
find_label_by_org(org_id) → List[influxdb_client.domain.label.Label][source]

Get the list of all labels for given organization.

Parameters:org_id – organization id
Returns:list of labels
find_labels() → List[influxdb_client.domain.label.Label][source]

Get all available labels.

Returns:labels
update_label(label: influxdb_client.domain.label.Label)[source]

Update an existing label name and properties.

Parameters:label – label
Returns:the updated label

OrganizationsApi

class influxdb_client.OrganizationsApi(influxdb_client)[source]

Implementation for ‘/api/v2/orgs’ endpoint.

Initialize defaults.

create_organization(name: str = None, organization: influxdb_client.domain.organization.Organization = None) → influxdb_client.domain.organization.Organization[source]

Create an organization.

delete_organization(org_id: str)[source]

Delete an organization.

find_organization(org_id)[source]

Retrieve an organization.

find_organizations()[source]

List all organizations.

me()[source]

Return the current authenticated user.

class influxdb_client.domain.Organization(links=None, id=None, name=None, description=None, created_at=None, updated_at=None, status='active')[source]

NOTE: This class is auto generated by OpenAPI Generator.

Ref: https://openapi-generator.tech

Do not edit the class manually.

Organization - a model defined in OpenAPI.

created_at

Get the created_at of this Organization.

Returns:The created_at of this Organization.
Return type:datetime
description

Get the description of this Organization.

Returns:The description of this Organization.
Return type:str
id

Get the id of this Organization.

Returns:The id of this Organization.
Return type:str

Get the links of this Organization.

Returns:The links of this Organization.
Return type:OrganizationLinks
name

Get the name of this Organization.

Returns:The name of this Organization.
Return type:str
status

Get the status of this Organization.

If inactive the organization is inactive.

Returns:The status of this Organization.
Return type:str
to_dict()[source]

Return the model properties as a dict.

to_str()[source]

Return the string representation of the model.

updated_at

Get the updated_at of this Organization.

Returns:The updated_at of this Organization.
Return type:datetime

UsersApi

class influxdb_client.UsersApi(influxdb_client)[source]

Implementation for ‘/api/v2/users’ endpoint.

Initialize defaults.

create_user(name: str) → influxdb_client.domain.user.User[source]

Create a user.

me() → influxdb_client.domain.user.User[source]

Return the current authenticated user.

class influxdb_client.domain.User(id=None, oauth_id=None, name=None, status='active', links=None)[source]

NOTE: This class is auto generated by OpenAPI Generator.

Ref: https://openapi-generator.tech

Do not edit the class manually.

User - a model defined in OpenAPI.

id

Get the id of this User.

Returns:The id of this User.
Return type:str

Get the links of this User.

Returns:The links of this User.
Return type:UserLinks
name

Get the name of this User.

Returns:The name of this User.
Return type:str
oauth_id

Get the oauth_id of this User.

Returns:The oauth_id of this User.
Return type:str
status

Get the status of this User.

If inactive the user is inactive.

Returns:The status of this User.
Return type:str
to_dict()[source]

Return the model properties as a dict.

to_str()[source]

Return the string representation of the model.

TasksApi

class influxdb_client.TasksApi(influxdb_client)[source]

Implementation for ‘/api/v2/tasks’ endpoint.

Initialize defaults.

add_label(label_id: str, task_id: str) → influxdb_client.domain.label_response.LabelResponse[source]

Add a label to a task.

add_member(member_id, task_id)[source]

Add a member to a task.

add_owner(owner_id, task_id)[source]

Add an owner to a task.

cancel_run(task_id: str, run_id: str)[source]

Cancel a currently running run.

Parameters:
  • task_id
  • run_id
clone_task(task: influxdb_client.domain.task.Task) → influxdb_client.domain.task.Task[source]

Clone a task.

create_task(task: influxdb_client.domain.task.Task = None, task_create_request: influxdb_client.domain.task_create_request.TaskCreateRequest = None) → influxdb_client.domain.task.Task[source]

Create a new task.

create_task_cron(name: str, flux: str, cron: str, org_id: str) → influxdb_client.domain.task.Task[source]

Create a new task with cron repetition schedule.

create_task_every(name, flux, every, organization) → influxdb_client.domain.task.Task[source]

Create a new task with every repetition schedule.

delete_label(label_id: str, task_id: str)[source]

Delete a label from a task.

delete_member(member_id, task_id)[source]

Remove a member from a task.

delete_owner(owner_id, task_id)[source]

Remove an owner from a task.

delete_task(task_id: str)[source]

Delete a task.

find_task_by_id(task_id) → influxdb_client.domain.task.Task[source]

Retrieve a task.

find_tasks(**kwargs)[source]

List all tasks.

Parameters:
  • name (str) – only returns tasks with the specified name
  • after (str) – returns tasks after specified ID
  • user (str) – filter tasks to a specific user ID
  • org (str) – filter tasks to a specific organization name
  • org_id (str) – filter tasks to a specific organization ID
  • limit (int) – the number of tasks to return
Returns:

Tasks

find_tasks_by_user(task_user_id)[source]

List all tasks by user.

get_labels(task_id)[source]

List all labels for a task.

get_logs(task_id: str) → List[influxdb_client.domain.log_event.LogEvent][source]

Retrieve all logs for a task.

Parameters:task_id – task id
get_members(task_id: str)[source]

List all task members.

get_owners(task_id)[source]

List all owners of a task.

get_run(task_id: str, run_id: str) → influxdb_client.domain.run.Run[source]

Get run record for specific task and run id.

Parameters:
  • task_id – task id
  • run_id – run id
Returns:

Run for specified task and run id

get_run_logs(task_id: str, run_id: str) → List[influxdb_client.domain.log_event.LogEvent][source]

Retrieve all logs for a run.

get_runs(task_id, **kwargs) → List[influxdb_client.domain.run.Run][source]

Retrieve list of run records for a task.

Parameters:
  • task_id – task id
  • after (str) – returns runs after specified ID
  • limit (int) – the number of runs to return
  • after_time (datetime) – filter runs to those scheduled after this time, RFC3339
  • before_time (datetime) – filter runs to those scheduled before this time, RFC3339
retry_run(task_id: str, run_id: str)[source]

Retry a task run.

Parameters:
  • task_id – task id
  • run_id – run id
run_manually(task_id: str, scheduled_for: <module 'datetime' from '/home/docs/.pyenv/versions/3.6.8/lib/python3.6/datetime.py'> = None)[source]

Manually start a run of the task now overriding the current schedule.

Parameters:
  • task_id
  • scheduled_for – planned execution
update_task(task: influxdb_client.domain.task.Task) → influxdb_client.domain.task.Task[source]

Update a task.

update_task_request(task_id, task_update_request: influxdb_client.domain.task_update_request.TaskUpdateRequest) → influxdb_client.domain.task.Task[source]

Update a task.

class influxdb_client.domain.Task(id=None, type=None, org_id=None, org=None, name=None, description=None, status=None, labels=None, authorization_id=None, flux=None, every=None, cron=None, offset=None, latest_completed=None, last_run_status=None, last_run_error=None, created_at=None, updated_at=None, links=None)[source]

NOTE: This class is auto generated by OpenAPI Generator.

Ref: https://openapi-generator.tech

Do not edit the class manually.

Task - a model defined in OpenAPI.

authorization_id

Get the authorization_id of this Task.

The ID of the authorization used when this task communicates with the query engine.

Returns:The authorization_id of this Task.
Return type:str
created_at

Get the created_at of this Task.

Returns:The created_at of this Task.
Return type:datetime
cron

Get the cron of this Task.

A task repetition schedule in the form ‘* * * * * *’; parsed from Flux.

Returns:The cron of this Task.
Return type:str
description

Get the description of this Task.

An optional description of the task.

Returns:The description of this Task.
Return type:str
every

Get the every of this Task.

A simple task repetition schedule; parsed from Flux.

Returns:The every of this Task.
Return type:str
flux

Get the flux of this Task.

The Flux script to run for this task.

Returns:The flux of this Task.
Return type:str
id

Get the id of this Task.

Returns:The id of this Task.
Return type:str
labels

Get the labels of this Task.

Returns:The labels of this Task.
Return type:list[Label]
last_run_error

Get the last_run_error of this Task.

Returns:The last_run_error of this Task.
Return type:str
last_run_status

Get the last_run_status of this Task.

Returns:The last_run_status of this Task.
Return type:str
latest_completed

Get the latest_completed of this Task.

Timestamp of latest scheduled, completed run, RFC3339.

Returns:The latest_completed of this Task.
Return type:datetime

Get the links of this Task.

Returns:The links of this Task.
Return type:TaskLinks
name

Get the name of this Task.

The name of the task.

Returns:The name of this Task.
Return type:str
offset

Get the offset of this Task.

Duration to delay after the schedule, before executing the task; parsed from flux, if set to zero it will remove this option and use 0 as the default.

Returns:The offset of this Task.
Return type:str
org

Get the org of this Task.

The name of the organization that owns this Task.

Returns:The org of this Task.
Return type:str
org_id

Get the org_id of this Task.

The ID of the organization that owns this Task.

Returns:The org_id of this Task.
Return type:str
status

Get the status of this Task.

Returns:The status of this Task.
Return type:TaskStatusType
to_dict()[source]

Return the model properties as a dict.

to_str()[source]

Return the string representation of the model.

type

Get the type of this Task.

The type of task, this can be used for filtering tasks on list actions.

Returns:The type of this Task.
Return type:str
updated_at

Get the updated_at of this Task.

Returns:The updated_at of this Task.
Return type:datetime