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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
recordThe record to write.
responseQueueThe queue on which api response is dispatched.
completioncompletion 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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
recordsThe records to write.
responseQueueThe queue on which api response is dispatched.
completionhandler 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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
pointThe
Pointto write.responseQueueThe queue on which api response is dispatched.
completioncompletion 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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
pointsThe
Pointsto write.responseQueueThe queue on which api response is dispatched.
completionhandler 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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
tupleThe
Tupleto write.responseQueueThe queue on which api response is dispatched.
completioncompletion 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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
tuplesThe
Tuplesto write.responseQueueThe queue on which api response is dispatched.
completionhandler to receive the data and the error objects
-
Write time-series data into InfluxDB.
See also
Swift.ResultDeclaration
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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
recordThe record to write.
responseQueueThe queue on which api response is dispatched.
completioncompletion handler to receive the
Swift.Result -
Write time-series data into InfluxDB.
See also
Swift.ResultDeclaration
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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
recordsThe records to write. It can be
String,PointorTuple.responseQueueThe queue on which api response is dispatched.
completioncompletion handler to receive the
Swift.Result -
Write time-series data into InfluxDB.
See also
Swift.ResultDeclaration
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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
pointThe
Pointto write.responseQueueThe queue on which api response is dispatched.
completioncompletion handler to receive the
Swift.Result -
Write time-series data into InfluxDB.
See also
Swift.ResultDeclaration
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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
pointsThe
Pointsto write.responseQueueThe queue on which api response is dispatched.
completioncompletion handler to receive the
Swift.Result -
Write time-series data into InfluxDB.
See also
Swift.ResultDeclaration
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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
tupleThe
Tupleto write.responseQueueThe queue on which api response is dispatched.
completioncompletion handler to receive the
Swift.Result -
Write time-series data into InfluxDB.
See also
Swift.ResultDeclaration
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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
tuplesThe
Tuplesto write.responseQueueThe queue on which api response is dispatched.
completioncompletion 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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
recordThe record to write.
responseQueueThe 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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
recordsThe records to write.
responseQueueThe 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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
pointThe
Pointto write.responseQueueThe 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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
pointsThe
Pointto write.responseQueueThe 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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
tupleThe
Tupleto write.responseQueueThe 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
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
tuplesThe
Tuplesto write.responseQueueThe 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 throwsParameters
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
recordThe record to write.
responseQueueThe 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 throwsParameters
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
recordsThe records to write.
responseQueueThe 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 throwsParameters
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
pointThe
Pointto write.responseQueueThe 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 throwsParameters
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
pointsThe
Pointsto write.responseQueueThe 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 throwsParameters
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
tupleThe
Tupleto write.responseQueueThe 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 throwsParameters
bucketThe destination bucket for writes. Takes either the
IDorNameinterchangeably.orgThe destination organization for writes. Takes either the
IDorNameinterchangeably.precisionThe precision for the unix timestamps within the body line-protocol.
tuplesThe
Tuplesto write.responseQueueThe queue on which api response is dispatched.
View on GitHub
WriteAPI Class Reference