Skip to content

Table Operation: Retrieve Single Record

Overview

The "API" will retrieve the "Record" with the specified ID. To retrieve multiple records at once, please use the "Multiple Records Retrieval API".

Limitations

Preparations

  1. In order to use the "API", you need to create an "API Key". If you access from a logged-in browser session, you can use it without specifying an "API Key".

Request

Send JSON data in the following request format. The URL will differ depending on your environment, so please refer to "API URL" and change it as appropriate.

Setting column Value
HTTP Method POST
Content-Type application/json
Character Code UTF-8
URL http://{server name}/{path}/api/{controller name}/{record ID}/get
Body Please refer to the json data below
JSON
{
     "ApiVersion": 1.1,
     "ApiKey": "63Kfk0ds3d4S2DBsa32..."
}

Response

JSON data in the following format is returned. For the data layout in the response section, refer to "JSON Data Layout: Item".

JSON
{
    "StatusCode": 200,
    "Response": {
        "Data": [
            {
                "SiteId": 7,
                "UpdatedTime": "2021-06-12T11:26:26",
                "IssueId": 340,
                "Ver": 2,
                "Title": "Validation of AI Technology",
                "Body": "There was a request to validate AI technology for the early detection of risks in project management. \r\nThis term, we will conduct a technical validation to discover common points of projects prone to problems by utilizing progress management data and email data. \r\nFirst, we will commercialize the requirement definition phase to concretize the project.",
                "StartTime": "1899-12-30T00:00:00",
                "CompletionTime": "2021-06-18T00:00:00",
                "WorkValue": 0.0,
                "ProgressRate": 0.0,
                "Status": 100,
                "Manager": 17,
                "Owner": 17,
                "Locked": false,
                "Comments": "[]",
                "Creator": 17,
                "Updator": 2,
                "CreatedTime": "2021-05-25T16:56:00",
                "ItemTitle": "Validation of AI Technology"",
                "ApiVersion": 1.1,
                "ClassHash": {
                    "ClassA": "338",
                    "ClassB": "Consulting",
                    "ClassC": "90%"
                },
                "NumHash": {
                    "NumA": 1500000.0,
                    "NumB": 1180000.0,
                    "NumC": 320000.0,
                    "NumD": 21.3
                },
                "DateHash": {},
                "DescriptionHash": {},
                "CheckHash": {},
                "AttachmentsHash": {
                    "AttachmentsA": []
                }
            }
        ]
    }
}

Code Samples

Modify 【 ... 】 in the code as necessary.
1. Specify a record ID and output a CSV

Gets a record and outputs it to a CSV file.

Python(api_record_get.py)
import requests
import csv

# Specify the server name, API key, record ID, and CSV file name
BASE_URL = "【Server name】"
API_KEY = "【API key】"
RECORD_ID = 【Record ID】
CSV_PATH = "api_record_get.csv"

# Function that gets one record with the Get Single Record API
def get_record(base_url: str, record_id: int, api_key: str) -> dict:
    url = f"{base_url}/api/items/{record_id}/get"

    payload = {
        "ApiVersion": 1.1,
        "ApiKey": api_key,
    }

    headers = {"Content-Type": "application/json"}

    res = requests.post(url, json=payload, headers=headers)
    res.raise_for_status()

    data = res.json()

    # The record itself is in Response.Data[0]
    item_list = data.get("Response", {}).get("Data", [])
    if not item_list:
        raise ValueError("Could not get the record.")

    return item_list[0]

def write_record_to_csv(record: dict, csv_path: str):
    row = {
        "Company name": record.get("Title"),
        "Company overview": record.get("Body"),
        "Date of establishment": record.get("DateHash", {}).get("DateC"),
        "Industry": record.get("ClassHash", {}).get("ClassF"),
    }

    fieldnames = list(row.keys())

    # UTF-8 (with BOM)
    with open(csv_path, "w", newline="", encoding="utf-8-sig") as f:
        writer = csv.DictWriter(f, fieldnames=fieldnames)
        writer.writeheader()
        writer.writerow(row)

if __name__ == "__main__":
    record = get_record(BASE_URL, RECORD_ID, API_KEY)
    write_record_to_csv(record, CSV_PATH)
    print(f"Output record {RECORD_ID} to {CSV_PATH}.")
Run
>python api_record_get.py
Execution Result
Output record {Record ID} to api_record_get.csv.