Skip to content

Dataloader WebAPI / Table initialization

This document has been machine translated.

Defines the data_name used by the data loader so that it can save the data. (Initializes the table)

Endpoint

https://pf.xdata.nict.jp/api/v1/dataloaderapi/jsonrpc

Request example

Below is an example of a request that defines data_name with the name test_event_001 and initializes a table with a string column of up to 256 characters called test_varchar_1.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "loaderwebapi.register_loader",
  "params": {
    "data_name": "test_event_001",
    "schema": "event",
    "record_def": {
      "test_varchar_1": {
        "udt_name": "varchar",
        "is_nullable": false,
        "column_default": "",
        "length": 256
      }
    },
    "unique_columns": [
      "location",
      "start_datetime"
    ]
  }
}

Response example

The following is the return contents in the above request example.

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "schema": "event",
    "table_name": "test_event_001"
  }
}

Parameters

Among the JSON-RPC request contents, the ones that can be specified in params are displayed below. Those marked Required are required parameters.

  • data_name: string (Required)
    • A name that points to the table in which you want to insert the data. The name defined here is also used in init_record and add_record.
  • schema: string (Optional)
    • Schema name where the table is created
    • Only use it if you know the schema structure of your database and want to specify a table creation schema.
  • record_def: object (Required)
    • Key: Attribute name (column name), Value: object representing attribute information
    • start_datetime(timestamptz), end_datetime(timestamptz), location (geometry) cannot be specified as attribute names because they are created automatically, and an error will occur if specified.
    • Structure of value object:
      • udt_name: string (Required)
        • The type name of the attribute. The values that can be specified will be described later.
      • is_nullable: bool (Optional, false if not specified)
        • true if you allow null values
      • column_default: string (Optional)
        • Default value if no attribute value is passed during add_record
      • length: int (Optional)
        • Maximum length of storable value (only available for specifiable type names)
      • srid: int (Optional, available only for geometry type, 4326 if not specified)
      • file_name_column: string (only for file type, Required)
        • The name of the column to save the file name for the file to be saved
        • Must be a string definition when specified in record_def.
      • file_type_column: string (only for file type, Required)
        • The name of the column to save the file type (content-type) for the file to be saved
        • Must be a string definition when specified with record_def
      • file_prefixid_column: string (only for file type, Required)
        • The name of the column that stores the prefix ID for the file to be saved
        • Must be an int type definition when specified in record_def
      • file_pathid_column: string (only for file type, Required)
        • The name of the column to save the path ID for the file to be saved
        • Must be a string definition when specified in record_def
      • file_relativepath_property: string (only for file type, Required)
        • The json key name to send the relative path of the file location to the file to be saved.
        • Not specified in record_def, but add_record sometimes requires a relative path to be specified, using the value specified here as the key name under properties
    • A type name that can be specified in udt_name. file, raster and bitmap types need to use base64ized strings when sending using add_record
      • time type:
        • timestamptz
        • timestamp
        • timetz
        • time
        • date
      • int type:
        • int8
        • int4
        • int2
      • float type:
        • float8
        • float4
      • string type:
        • varchar
        • bpchar
        • text
      • bool:
        • bool
      • geometry:
        • geometry
      • File (unique type definition for "file reference"):
        • file
      • Others:
        • raster
        • bytea
  • unique_columns: string array (Required)
    • You must define at least one (composite) unique key for better performance.
    • You must specify the array using the string contained in the key (and reserved column name) specified in record_def.

Return values

successful termination:

  • schema: Schema in which the table was created
  • table_name: Real table name

If an error occurs, such as when the initialization process corresponding to data_name has already been performed, error is returned.