Skip to main content

Python api client - https://api.objectways.com/docs

Project description

Newton API client

This is python package to call all API from (https://api.objectways.com/docs)

Import package and create a client

"api_url" is and optional parameter for private installs

from pprint import pprint
from objectways import newton

client = newton.Newton(api_url="YOUR_API_URL",api_key="YOUR_API_KEY")

1. Task

1.1. Add new task

body = {
  "project_id": "449354de1168469a8229f605",
  "file_name": "document.pdf",
  "file_type": "application/pdf",
  "source": "s3://examples/pdfs/document.pdf"
}

pprint(client.add_task(body))

1.2. Add bulk tasks

body = {
  "project_id": "cd1a965e334a9a63e2f17932",
  "task_list": [
    {
      "source": "s3://examples/pdfs/document.pdf",
      "annotations": "s3://examples/pdfs/annotation.json"
    },
    {
      "source": "s3://examples/pdfs/document2.pdf"
    },
    {
      "source": "s3://examples/pdfs/document3.pdf",
      "annotations": {
        "tags": [
          {
            "page": 1,
            "range": [
              192,
              198
            ],
            "text": "Oxford",
            "id": 1,
            "type": "NAME"
          }
        ]
      }
    }
  ]
}

pprint(client.add_bulk_tasks(body))

1.3. Add labels to task

body = {
  "annotations": "s3://examples/pdfs/annotation.json"
}

pprint(client.add_labels_to_task(task_id=task_id,body=body))

1.4. Add task file

data = client.add_task_file(
    project_id="449354de1168469a8229f605", 
    file_path="examples/pdfs/document.pdf",
    mime_type="application/pdf",
    annotations=None
)

pprint(data)

1.5. Get Task by task_id

data = client.get_task(
    task_id="449354de1168469a8229f605", 
)

pprint(data)

1.6. Delete Task by task_id

data = client.delete_task(
    task_id="449354de1168469a8229f605", 
)

pprint(data)

1.7. Get tasks by filters

  • Find all the tasks by task_id, file_name, file_type and trail
  • If all of task_id, file_name, file_type are None, it will return all possible tasks
tasks = client.get_tasks(
    project_id="449354de1168469a8229f605", 
    task_id="449354de1168469a8229f605-0",
    file_name=None,
    file_type=None,
    trail = False
)

pprint(tasks)

1.8. Export Tasks by project_id

response = client.export_tasks(
    project_id="449354de1168469a8229f605", 
)

pprint(response)

1.9. Get Bounding box coordinates for Words for a task

  • Get Bounding Box coordinates of all pages in a document
  • Optionally pass "page" number to restrict by the page
response = client.get_word_boxes(
    task_id="449354de1168469a8229f605",
    page = 1 
)

pprint(response)

2. Project

2.1. Create a new project

body = {
  "project_name": "TestProject",
  "project_type": "NER",
  "enable_text_mode_option": True,
  "disable_quality_audit": True,
  ...
}
# check API docs for the full body: https://api.objectways.com/docs/#/projects/upload_project

pprint(client.create_project(body))

2.2. Get project by project_id

response = client.get_project(
    project_id="449354de1168469a8229f605", 
)

2.3. Update project

body = {
  "project_name": "TestProject",
  "project_type": "NER",
  "enable_text_mode_option": True,
  "disable_quality_audit": True,
  ...
}
response = client.update_project(
    project_id="449354de1168469a8229f605",
    body=body 
)

2.4. Delete project

response = client.delete_project(
    project_id="449354de1168469a8229f605",
)

2.5. Get projects by Filters

  • Find all the projects by project_id, project_name or active
  • If all of project_id, project_name, active are None, it will return all possible projects
projects = client.get_projects(
    project_id="449354de1168469a8229f605", 
    project_name=None, 
    active=None
)

3. Team Management

3.1. Add member to the team

member = client.add_team_member(
    project_id="449354de1168469a8229f605", 
    email="someone@email.com", 
    role="annotator|reviewer|supervisor"
)

3.2. Get project team members

team = client.get_project_team_members(
    project_id="449354de1168469a8229f605", 
)

3.3. Remove member from the project team

team = client.remove_project_team_member(
    project_id="449354de1168469a8229f605",
    email="someone@email.com" 
)

4. Dataset Management

4.1. Create a new Dataset

body = {
  "dataset_name": "Test Dataset",
  "dataset_description": "This is a test Dataset",
  "dataset_type": "Image",
  "item_format": "image/tiff",
  "meta_data": {
    "key": "value"
  },
  "s3IntermediateUrl": "s3://test-dataset/intermediate",
  "aws_credentials_enabled": true,
  "aws_credentials": {
    "awsKey": "...",
    "awsSecret": "...",
    "awsRegion": "us-east-1",
    "awsType": "key"
  }
}
# check API docs for the full body:http://54.83.23.220:8089/docs/#/datasets/upload_dataset

pprint(client.create_dataset(body))

4.2. Get dataset by dataset_id

response = client.get_dataset(
    dataset_id="449354de1168469a8229f605", 
)

4.3. Update dataset

body = {
  "dataset_name": "Test Dataset",
  "dataset_description": "This is a test Dataset",
  "dataset_type": "Image",
  "item_format": "image/tiff",
  "meta_data": {
    "key": "value"
  },
  "s3IntermediateUrl": "s3://mybucket/test-dataset/intermediate",
  "aws_credentials_enabled": true,
  "aws_credentials": {
    "awsKey": "xxxxx",
    "awsSecret": "xxx",
    "awsRegion": "us-east-1",
    "awsType": "key"
  }
}
response = client.update_dataset(
    dataset_id="449354de1168469a8229f605",
    body=body 
)

4.4. List datasets by Filters

  • Find all the datasets by dataset_id, dataset_name or active
  • If all of dataset_id, dataset_name, active are None, it will return all possible datasets
projects = client.list_datasets(
    dataset_id="449354de1168469a8229f605", 
    dataset_name=None, 
    active=None
)

4.5. Create a new Dataset Item

body = {
  "dataset_id": "208eb554d3fa1e161b2c6a44",
  "dataset_items": [
    {
      "meta_data": {
        "batch": "10",
        "test": "cell"
      },
      "source": "s3://mybucket/test-dataset/file1.tiff"
    },
    {
      "meta_data": {
        "batch": "1",
        "test": "cell"
      },
      "source": "s3://mybucket/test-dataset/file2.tiff"
    } 
    ....
    ....
  ]
}
# check API docs for the full body:https://adl.objectways.com/docs/#/datasets/upload_dataset

pprint(client.create_dataset_item(body))

4.6. Get dataset_item by item_id

response = client.get_dataset_item(
    item_id="449354de1168469a8229f605" 
)

4.7. Delete dataset_item by item_id

response = client.delete_dataset_item(
    item_id="449354de1168469a8229f605" 
)

4.8. List dataset items by Filters

  • Find all the dataset items by dataset_id, dataset_version
  • If dataset_version is None, it will return all possible dataset items for all versions
projects = client.list_dataset_items(
    dataset_id="449354de1168469a8229f605", 
    dataset_version=3 
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

newton-api-client-1.0.9.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

newton_api_client-1.0.9-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file newton-api-client-1.0.9.tar.gz.

File metadata

  • Download URL: newton-api-client-1.0.9.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.8

File hashes

Hashes for newton-api-client-1.0.9.tar.gz
Algorithm Hash digest
SHA256 83af9ea7e8e1c46f9adcea28a4c37ba1c52bf5c2ceb13660afbeaafdf8d5a235
MD5 c35021891949293c50d8eddf796ed261
BLAKE2b-256 4f2c8a418b068d4b9cad3b604cff9c1f53e2a479851bf4015fd38ac2cf25122d

See more details on using hashes here.

File details

Details for the file newton_api_client-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: newton_api_client-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.3 CPython/3.8.8

File hashes

Hashes for newton_api_client-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 50d896a0d7f9582b0cbcc4bcea1b79ce2a0d081954900951a661361d3f8876d2
MD5 798b6116b8e6bfc51dc27e18be4a1cb7
BLAKE2b-256 725e40efd85739d167276e13d96f68e9c2665b51ea945d0a4ae1d385e9aaa3c1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page