WriteAPI
public class WriteAPI
The asynchronous API to Write time-series data into InfluxDB 2.x.
Example:
//
// Record defined as String
//
let recordString = "demo,type=string value=1i"
try await client.makeWriteAPI().write(record: recordString)
// For Success write
print("Successfully written data:\n\n\(recordString)")
//
// Record defined as Data Point
//
let recordPoint = InfluxDBClient
.Point("demo")
.addTag(key: "type", value: "point")
.addField(key: "value", value: .int(2))
//
// Record defined as Data Point with Timestamp
//
let recordPointDate = InfluxDBClient
.Point("demo")
.addTag(key: "type", value: "point-timestamp")
.addField(key: "value", value: .int(2))
.time(time: .date(Date()))
try await client.makeWriteAPI().write(points: [recordPoint, recordPointDate])
// For Success write
print("Successfully written data:\n\n\([recordPoint, recordPointDate])")
//
// Record defined as Tuple
//
let recordTuple: InfluxDBClient.Point.Tuple
= (measurement: "demo", tags: ["type": "tuple"], fields: ["value": .int(3)], time: nil)
try await client.makeWriteAPI().write(tuple: recordTuple)
// For Success write
print("Successfully written data:\n\n\(recordTuple)")
-
Write time-series data into InfluxDB.
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, record: String, responseQueue: DispatchQueue = .main, completion: @escaping (_ response: Void?, _ error: InfluxDBClient.InfluxDBError?) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
record
The record to write.
responseQueue
The queue on which api response is dispatched.
completion
completion handler to receive the data and the error objects
-
Write time-series data into InfluxDB.
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, records: [String], responseQueue: DispatchQueue = .main, completion: @escaping (_ response: Void?, _ error: InfluxDBClient.InfluxDBError?) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
records
The records to write.
responseQueue
The queue on which api response is dispatched.
completion
handler to receive the data and the error objects
-
Write time-series data into InfluxDB.
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, point: InfluxDBClient.Point, responseQueue: DispatchQueue = .main, completion: @escaping (_ response: Void?, _ error: InfluxDBClient.InfluxDBError?) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
point
The
Point
to write.responseQueue
The queue on which api response is dispatched.
completion
completion handler to receive the data and the error objects
-
Write time-series data into InfluxDB.
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, points: [InfluxDBClient.Point], responseQueue: DispatchQueue = .main, completion: @escaping (_ response: Void?, _ error: InfluxDBClient.InfluxDBError?) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
points
The
Points
to write.responseQueue
The queue on which api response is dispatched.
completion
handler to receive the data and the error objects
-
Write time-series data into InfluxDB.
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, tuple: InfluxDBClient.Point.Tuple, responseQueue: DispatchQueue = .main, completion: @escaping (_ response: Void?, _ error: InfluxDBClient.InfluxDBError?) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
tuple
The
Tuple
to write.responseQueue
The queue on which api response is dispatched.
completion
completion handler to receive the data and the error objects
-
Write time-series data into InfluxDB.
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, tuples: [InfluxDBClient.Point.Tuple], responseQueue: DispatchQueue = .main, completion: @escaping (_ response: Void?, _ error: InfluxDBClient.InfluxDBError?) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
tuples
The
Tuples
to write.responseQueue
The queue on which api response is dispatched.
completion
handler to receive the data and the error objects
-
Write time-series data into InfluxDB.
See also
Swift.Result
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, record: String, responseQueue: DispatchQueue = .main, completion: @escaping ( _ result: Swift.Result<Void, InfluxDBClient.InfluxDBError>) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
record
The record to write.
responseQueue
The queue on which api response is dispatched.
completion
completion handler to receive the
Swift.Result
-
Write time-series data into InfluxDB.
See also
Swift.Result
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, records: [String], responseQueue: DispatchQueue = .main, completion: @escaping ( _ result: Swift.Result<Void, InfluxDBClient.InfluxDBError>) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
records
The records to write. It can be
String
,Point
orTuple
.responseQueue
The queue on which api response is dispatched.
completion
completion handler to receive the
Swift.Result
-
Write time-series data into InfluxDB.
See also
Swift.Result
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, point: InfluxDBClient.Point, responseQueue: DispatchQueue = .main, completion: @escaping ( _ result: Swift.Result<Void, InfluxDBClient.InfluxDBError>) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
point
The
Point
to write.responseQueue
The queue on which api response is dispatched.
completion
completion handler to receive the
Swift.Result
-
Write time-series data into InfluxDB.
See also
Swift.Result
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, points: [InfluxDBClient.Point], responseQueue: DispatchQueue = .main, completion: @escaping ( _ result: Swift.Result<Void, InfluxDBClient.InfluxDBError>) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
points
The
Points
to write.responseQueue
The queue on which api response is dispatched.
completion
completion handler to receive the
Swift.Result
-
Write time-series data into InfluxDB.
See also
Swift.Result
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, tuple: InfluxDBClient.Point.Tuple, responseQueue: DispatchQueue = .main, completion: @escaping ( _ result: Swift.Result<Void, InfluxDBClient.InfluxDBError>) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
tuple
The
Tuple
to write.responseQueue
The queue on which api response is dispatched.
completion
completion handler to receive the
Swift.Result
-
Write time-series data into InfluxDB.
See also
Swift.Result
Declaration
Swift
public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, tuples: [InfluxDBClient.Point.Tuple], responseQueue: DispatchQueue = .main, completion: @escaping ( _ result: Swift.Result<Void, InfluxDBClient.InfluxDBError>) -> Void)
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
tuples
The
Tuples
to write.responseQueue
The queue on which api response is dispatched.
completion
completion handler to receive the
Swift.Result
-
Write time-series data into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, record: String, responseQueue: DispatchQueue = .main) -> AnyPublisher<Void, InfluxDBClient.InfluxDBError>
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
record
The record to write.
responseQueue
The queue on which api response is dispatched.
Return Value
Publisher to attach a subscriber
-
Write time-series data into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, records: [String], responseQueue: DispatchQueue = .main) -> AnyPublisher<Void, InfluxDBClient.InfluxDBError>
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
records
The records to write.
responseQueue
The queue on which api response is dispatched.
Return Value
Publisher to attach a subscriber
-
Write time-series data into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, point: InfluxDBClient.Point, responseQueue: DispatchQueue = .main) -> AnyPublisher<Void, InfluxDBClient.InfluxDBError>
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
point
The
Point
to write.responseQueue
The queue on which api response is dispatched.
Return Value
Publisher to attach a subscriber
-
Write time-series data into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, points: [InfluxDBClient.Point], responseQueue: DispatchQueue = .main) -> AnyPublisher<Void, InfluxDBClient.InfluxDBError>
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
points
The
Point
to write.responseQueue
The queue on which api response is dispatched.
Return Value
Publisher to attach a subscriber
-
Write time-series data into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, tuple: InfluxDBClient.Point.Tuple, responseQueue: DispatchQueue = .main) -> AnyPublisher<Void, InfluxDBClient.InfluxDBError>
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
tuple
The
Tuple
to write.responseQueue
The queue on which api response is dispatched.
Return Value
Publisher to attach a subscriber
-
Write time-series data into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, tuples: [InfluxDBClient.Point.Tuple], responseQueue: DispatchQueue = .main) -> AnyPublisher<Void, InfluxDBClient.InfluxDBError>
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
tuples
The
Tuples
to write.responseQueue
The queue on which api response is dispatched.
Return Value
Publisher to attach a subscriber
-
write(bucket:
Asynchronousorg: precision: record: responseQueue: ) Write time-series data asynchronously into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, record: String, responseQueue: DispatchQueue = .main) async throws
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
record
The record to write.
responseQueue
The queue on which api response is dispatched.
-
write(bucket:
Asynchronousorg: precision: records: responseQueue: ) Write time-series data asynchronously into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, records: [String], responseQueue: DispatchQueue = .main) async throws
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
records
The records to write.
responseQueue
The queue on which api response is dispatched.
-
write(bucket:
Asynchronousorg: precision: point: responseQueue: ) Write time-series data asynchronously into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, point: InfluxDBClient.Point, responseQueue: DispatchQueue = .main) async throws
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
point
The
Point
to write.responseQueue
The queue on which api response is dispatched.
-
write(bucket:
Asynchronousorg: precision: points: responseQueue: ) Write time-series data asynchronously into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, points: [InfluxDBClient.Point], responseQueue: DispatchQueue = .main) async throws
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
points
The
Points
to write.responseQueue
The queue on which api response is dispatched.
-
write(bucket:
Asynchronousorg: precision: tuple: responseQueue: ) Write time-series data asynchronously into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, tuple: InfluxDBClient.Point.Tuple, responseQueue: DispatchQueue = .main) async throws
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
tuple
The
Tuple
to write.responseQueue
The queue on which api response is dispatched.
-
write(bucket:
Asynchronousorg: precision: tuples: responseQueue: ) Write time-series data asynchronously into InfluxDB.
Declaration
Swift
@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) public func write(bucket: String? = nil, org: String? = nil, precision: InfluxDBClient.TimestampPrecision? = nil, tuples: [InfluxDBClient.Point.Tuple], responseQueue: DispatchQueue = .main) async throws
Parameters
bucket
The destination bucket for writes. Takes either the
ID
orName
interchangeably.org
The destination organization for writes. Takes either the
ID
orName
interchangeably.precision
The precision for the unix timestamps within the body line-protocol.
tuples
The
Tuples
to write.responseQueue
The queue on which api response is dispatched.