Records v1 BETA
The Records API is a beta feature of Metatext that allows users to add, retrieve, update, and delete records for their NLP projects. With this API, users can easily manage their data by adding new records with text, labels, and custom metadata, retrieving existing records with prediction results and other information, updating records, and deleting records as needed.
Adding records
By using the Inference API, it calls your NLP model that was deployed automatically after the training process. Here you will find the configuration to use them.
Endpoint
Request Example
Example using Python:
import requests
project_id = "YOUR_PROJECT_ID"
api_key = "YOUR_API_KEY"
url = f"https://api.metatext.ai/v1/project/{project_id}/record"
payload = { "text": "hello world" }
headers = { "content-type": "application/json", "x-api-key": api_key }
response = requests.post(url=url, json=payload, headers=headers)
print(response.json())
# output: {
"record_id": "NEW_RECORD_ID",
"project_id": "YOUR_PROJECT_ID"
}
Path parameters
project_id string | Your project ID (alphanumeric format up to 64 characters) |
Payload
text string required | Your text |
labels array of strings optional | Labels for your text |
metadata map optional | Custom data for record identify |
Response
record_id string | The record ID (alphanumeric format up to 64 characters) |
Getting records
By using the Inference API, it calls your NLP model that was deployed automatically after the training process. Here you will find the configuration to use them.
Endpoint
Request Example
Example using Python:
import requests
project_id = "YOUR_PROJECT_ID"
record_id = "NEW_RECORD_ID"
api_key = "YOUR_API_KEY"
url = f"https://api.metatext.ai/v1/project/{project_id}/record/{record_id}"
headers = { "content-type": "application/json", "x-api-key": api_key }
response = requests.get(url=url, headers=headers)
print(response.json())
# output: {
"record_id": "NEW_RECORD_ID",
"project_id": "YOUR_PROJECT_ID",
"dataset_id": "PROJECT_DATASET_ID",
"text": "hello world",
"labels": ["Label A", "Label B"],
"prediction": ["Label A", "Label B"],
"confidence": [0.98, 0.92],
"updated_at": "2023-05-01 14:00:01",
"updated_at": "2023-05-01 10:50:46"
}
Response
project_id string | The project ID (alphanumeric format up to 64 characters) |
record_id string | The record ID (alphanumeric format up to 64 characters) |
dataset_id string | The dataset ID (alphanumeric format up to 64 characters) |
text string | The record text |
labels array of strings | The labels assigned to the record |
prediction array of string | The predictions for the record |
confidence array of numbers | The confidence scores for the predictions |
metadata map | The metadata for the record |
updated_at string | The creation time in string format |
created_at string | The creation time in string format |
Updating records
By using the Inference API, it calls your NLP model that was deployed automatically after the training process. Here you will find the configuration to use them.
Endpoint
Request Example
Example using Python:
import requests
project_id = "YOUR_PROJECT_ID"
record_id = "YOUR_RECORD_ID"
api_key = "YOUR_API_KEY"
url = f"https://api.metatext.ai/v1/project/{project_id}/record/{record_id}"
payload = { "labels": ["Label A"] }
headers = { "content-type": "application/json", "x-api-key": api_key }
response = requests.put(url=url, json=payload, headers=headers)
print(response.json())
# output: {
"record_id": "NEW_RECORD_ID",
"project_id": "YOUR_PROJECT_ID"
}
Deleting records
By using the Inference API, it calls your NLP model that was deployed automatically after the training process. Here you will find the configuration to use them.
Endpoint
Request Example
Example using Python:
import requests
project_id = "YOUR_PROJECT_ID"
record_id = "YOUR_RECORD_ID"
api_key = "YOUR_API_KEY"
url = f"https://api.metatext.ai/v1/project/{project_id}/record/{record_id}"
headers = { "content-type": "application/json", "x-api-key": api_key }
response = requests.delete(url=url, headers=headers)