Table Operation: Retrieve Multiple Records
Overview¶
The "API" retrieves multiple records for the specified site ID. For tables with "Site Integration", information about each integrated record is also retrieved. To retrieve a single record, use the "Record Retrieval API".
Limitations¶
- The maximum number of records that can be retrieved is the PageSize in Api.json (200 by default). To retrieve more than 200 records, refer to "FAQ: I want to retrieve data exceeding 200 records via API".
- To retrieve a single record, use the "Retrieve Single Record" API.
Preparations¶
- 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. Specify the "Filter" conditions and "Sort" of records in "JSON Data Layout: View". View is optional.
| Setting column | Value |
|---|---|
| HTTP Method | POST |
| Content-Type | application/json |
| Character code | UTF-8 |
| URL | http://{server name}/api/items/{site ID}/get |
| Body | Please refer to the json data below |
JSON¶
Response¶
JSON data in the following format will be returned. For the data layout in the response section, please refer to "JSON Data Layout: Item".
If you want to retrieve more than 200 records, please refer to FAQ: FAQ: I want to retrieve data exceeding 200 records via API.
JSON¶
{
"StatusCode": 200,
"Response": {
"Offset": 0,
"PageSize": 200,
"TotalCount": 2,
"Data": [
{
"SiteId": 6,
"UpdatedTime": "2021-06-11T21:26:34",
"ResultId": 335,
"Ver": 2,
"Title": "Web Database Development Co., Ltd.",
"Body": "",
"Status": 0,
"Manager": 10,
"Owner": 10,
"Locked": false,
"Comments": "[]",
"Creator": 10,
"Updator": 12,
"CreatedTime": "2021-05-25T16:56:00",
"ItemTitle": "Web Database Development Co., Ltd.",
"ApiVersion": 1.1,
"ClassHash": {
"ClassA": "Nerima Ward, Tokyo,
"ClassB": "789-789-789"
},
"NumHash": {},
"DateHash": {},
"DescriptionHash": {},
"CheckHash": {},
"AttachmentsHash": {
"AttachmentsA": []
}
},
{
"SiteId": 6,
"UpdatedTime": "2021-06-09T21:23:00",
"ResultId": 336,
"Ver": 1,
"Title": "Information Sharing Innovation Research Institute",
"Body": "",
"Status": 0,
"Manager": 11,
"Owner": 11,
"Locked": false,
"Comments": "[]",
"Creator": 11,
"Updator": 11,
"CreatedTime": "2021-05-25T16:56:00",
"ItemTitle": "Information Sharing Innovation Research Institute",
"ApiVersion": 1.1,
"ClassHash": {
"ClassA": "Shinjuku Ward, Tokyo",
"ClassB": "333-333-333"
},
"NumHash": {},
"DateHash": {},
"DescriptionHash": {},
"CheckHash": {},
"AttachmentsHash": {
"AttachmentsA": []
}
}
]
}
}
Code Samples¶
Modify 【 ... 】 in the code as necessary.¶
1. Get all records
Gets all records of the specified site.
Python(api_record_get_multi_p1.py)¶
# Library for communicating with websites and APIs
import requests
# Server name, API key, and site ID
BASE_URL = "【Server name】"
API_KEY = "【API key】"
SITE_ID = 【Site ID】
# Get all records of the specified site
def get_records():
url = f"{BASE_URL}/api/items/{SITE_ID}/get"
payload = {
"ApiVersion": 1.1,
"ApiKey": API_KEY,
}
resp = requests.post(url, json=payload)
resp.raise_for_status()
data = resp.json()
return data["Response"]["Data"]
if __name__ == "__main__":
for row in get_records():
print(row["Title"], row["ClassHash"]["ClassA"])
Run¶
Execution Result¶
2. Get records by date range
Specifies a date range and gets the target records.
Python(api_record_get_multi_p2.py)¶
# Library for communicating with websites and APIs
import requests
# Server name, API key, and site ID
BASE_URL = "【Server name】"
API_KEY = "【API key】"
SITE_ID = 【Site ID】
# Specify a date range and get the records
def get_by_date(start, end):
url = f"{BASE_URL}/api/items/{SITE_ID}/get"
view = {
"ColumnFilterHash": {
"DateA": f'["{start} 00:00:00,{end} 23:59:59"]'
},
"ColumnSorterHash": {"DateA": "asc"},
}
payload = {
"ApiVersion": 1.1,
"ApiKey": API_KEY,
"View": view,
}
resp = requests.post(url, json=payload)
resp.raise_for_status()
data = resp.json()
return data["Response"]["Data"]
if __name__ == "__main__":
# Get with the date range 2025/01/01 to 2025/01/13
data = get_by_date("2025/01/01", "2025/01/13")
for row in data:
print(row["Title"], row["ClassHash"]["ClassA"], row["DateHash"]["DateA"])
Run¶
Execution Result¶
3. Narrow down by status
Specifies the status and gets the records. The status is retrieved as its display name.
Python(api_record_get_multi_p3.py)¶
# Library for communicating with websites and APIs
import requests
# Server name, API key, and site ID
BASE_URL = "【Server name】"
API_KEY = "【API key】"
SITE_ID = 【Site ID】
# Specify the status and get the records (the status is retrieved as its display name)
def get_by_status(status_codes):
url = f"{BASE_URL}/api/items/{SITE_ID}/get"
view = {
"ColumnFilterHash": {"Status": f"{status_codes}"},
"ColumnSorterHash": {"DateA": "asc"},
"ApiColumnKeyDisplayType": "ColumnName",
"ApiColumnValueDisplayType": "DisplayValue",
"ApiDataType": "KeyValues",
}
payload = {
"ApiVersion": 1.1,
"ApiKey": API_KEY,
"View": view,
}
resp = requests.post(url, json=payload)
resp.raise_for_status()
data = resp.json()
return data["Response"]["Data"]
if __name__ == "__main__":
# Get status 100 or 200
data = get_by_status('["100","200"]')
for row in data:
print(row["Title"], row["ClassA"], row["Status"])
Run¶
Execution Result¶
4. Search for a specific string (partial match) and get the records
Searches for a specific string (partial match) and gets the records.
Python(api_record_get_multi_p4.py)¶
# Library for communicating with websites and APIs
import requests
# Server name, API key, and site ID
BASE_URL = "【Server name】"
API_KEY = "【API key】"
SITE_ID = 【Site ID】
# Search for a specific string (partial match) and get the records
def get_by_text(text):
url = f"{BASE_URL}/api/items/{SITE_ID}/get"
view = {
"ColumnFilterHash": {"DescriptionA": f"{text}"},
"ColumnSorterHash": {"DateA": "asc"},
"ColumnFilterSearchTypes": {"DescriptionA": "PartialMatch"},
}
payload = {
"ApiVersion": 1.1,
"ApiKey": API_KEY,
"View": view,
}
resp = requests.post(url, json=payload)
resp.raise_for_status()
data = resp.json()
return data["Response"]["Data"]
if __name__ == "__main__":
# Search with the string "release"
data = get_by_text("release")
for row in data:
print(
row["Title"],
row["ClassHash"]["ClassA"],
row["DescriptionHash"]["DescriptionA"],
)
Run¶
Execution Result¶
5. Get only specific columns
Specifies only the columns you want and gets the records.
Python(api_record_get_multi_p5.py)¶
# Library for communicating with websites and APIs
import requests
# Server name, API key, and site ID
BASE_URL = "【Server name】"
API_KEY = "【API key】"
SITE_ID = 【Site ID】
# Specify only specific columns and get them
def get_selected_columns():
url = f"{BASE_URL}/api/items/{SITE_ID}/get"
view = {
"ApiDataType": "KeyValues",
"GridColumns": ["Title", "Status", "DateA", "NumA"],
}
payload = {
"ApiVersion": 1.1,
"ApiKey": API_KEY,
"View": view,
}
resp = requests.post(url, json=payload)
resp.raise_for_status()
data = resp.json()
return data["Response"]["Data"]
if __name__ == "__main__":
records = get_selected_columns()
# --- Console output example ---
for rec in records:
print(rec["Project name"], rec["Status"], rec["Registration date"], rec["Estimated effort"])
Run¶
Execution Result¶
6. Get more than 200 records
Gets more than 200 records.
Python(api_record_get_multi_p6.py)¶
# Library for communicating with websites and APIs
import requests
# Server name, API key, and site ID
BASE_URL = "【Server name】"
API_KEY = "【API key】"
SITE_ID = 【Site ID】
# Get all records of the specified site, exceeding 200 records
def fetch_all_records():
url = f"{BASE_URL}/api/items/{SITE_ID}/get"
offset = 0
all_rows = []
while True:
# Specify Offset to advance the page
payload = {
"ApiVersion": 1.1,
"ApiKey": API_KEY,
"Offset": offset,
}
res = requests.post(
url, json=payload, headers={"Content-Type": "application/json"}
)
res.raise_for_status()
data = res.json()
response = data["Response"]
rows = response["Data"]
total = response["TotalCount"] # Total number of records
page_size = response[
"PageSize"
] # Maximum number retrieved at once (PageSize in Api.json, default 200)
current_offset = response["Offset"]
# Add the records retrieved this time
all_rows.extend(rows)
print(f"Offset={current_offset}, retrieved={len(rows)}, total={total}")
# When (start position + number retrievable at once) > total, everything up to the end has been retrieved
if current_offset + page_size >= total:
break
# Advance Offset to the start position of the next page
offset = current_offset + page_size
return all_rows
if __name__ == "__main__":
records = fetch_all_records()
print(f"Final number of records retrieved: {len(records)}")
for r in records:
print(r["Title"], r["ClassHash"]["ClassA"])