API Access

Access the Got2 database using XML-RPC, with explanations, examples, and security tips.


๐Ÿ“˜ Got2 XML-RPC API Integration

This guide explains how developers can securely and efficiently connect to the Got2 ERP database using XML-RPC The XML-RPC interface is useful when building custom integrations from external systems like mobile apps, third-party services, or data migration tools.


๐Ÿ”ง Prerequisites

Before proceeding, ensure you have:

  • Access Got2  and enable XML-RPC enabled.
  • A valid Got2 database name.
  • A Got2 username and password with sufficient privileges (ideally an API user or admin).
  • Python 3 installed.
  • xmlrpc.client   module (standard library in Python 3).
  • Got2 instance URL (e.g., https://opticalx.got2.cloud   ).

๐Ÿš€ Step-by-Step Integration

1. Authenticate to Get UID

First, you need to authenticate and obtain a uid   (user ID), which is required for all subsequent calls.

import xmlrpc.client

url = "https://got2.example.com"
db = "got2_production"
username = "api_user@example.com"
password = "your_password"

common = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/common")
uid = common.authenticate(db, username, password, {})
print("Authenticated UID:", uid)

2. Access the Object Endpoint

Once authenticated, use the object proxy to call any model methods:

models = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/object")

๐Ÿ“‚ Common Operations


โœ… Search Records

# Example: Find all active patients
patient_ids = models.execute_kw(
    db, uid, password,
    'got2.patient', 'search',
    [[['active', '=', True]]]
)

๐Ÿ”Ž Search & Read Records

patients = models.execute_kw(
    db, uid, password,
    'got2.patient', 'search_read',
    [[['active', '=', True]]],  # domain
    {'fields': ['name', 'email'], 'limit': 10}
)

๐Ÿ“„ Read Specific Record by ID

patient = models.execute_kw(
    db, uid, password,
    'got2.patient', 'read',
    [[15]],  # record ID list
    {'fields': ['name', 'email']}
)

๐Ÿ“ Create a New Record

new_id = models.execute_kw(
    db, uid, password,
    'got2.patient', 'create',
    [{
        'name': 'John Doe',
        'email': 'john@example.com',
        'active': True,
    }]
)

โœ๏ธ Update a Record

success = models.execute_kw(
    db, uid, password,
    'got2.patient', 'write',
    [[15], {  # record ID list
        'email': 'updated@example.com'
    }]
)

๐Ÿ—‘๏ธ Delete a Record

deleted = models.execute_kw(
    db, uid, password,
    'got2.patient', 'unlink',
    [[15]]  # record ID list
)

๐Ÿ”’ Security Notes

  • Do not expose API users publicly.
  • Use HTTPS to encrypt all data.
  • Limit permissions of the API user (read/write on required models only).
  • Rotate passwords regularly and enforce strong credentials.

๐Ÿง  Tips and Advanced Use

Check Server Version

version = common.version()
print(version)

Execute Custom Method

Assume got2.patient   has a custom method send_patient_summary   .

models.execute_kw(
    db, uid, password,
    'got2.patient', 'send_patient_summary',
    [[15]]
)

Use fields_get   to Inspect Model

fields = models.execute_kw(
    db, uid, password,
    'got2.patient', 'fields_get',
    [],
    {'attributes': ['string', 'type']}
)

๐Ÿงช Debugging & Testing

  • Wrap all requests in try/except blocks.
  • Log response data for audits.
  • Use Postman with raw XML if you want to inspect raw request/response.
  • You can also try calling /xmlrpc/2/object   manually with an XML-RPC client.

๐Ÿ—ƒ๏ธ Complete Got2 API Models Reference

๐Ÿ‘ค Patients & Core Data

Model Name Purpose
got2.patient    Patient master records
res.partner    Contact info (used for patients, payers, manufacturers)
res.partner.title    Title (Mr., Mrs., Dr., etc.)
got2.patient.pays.tag    Insurance-related tags applied to patients
got2.allergy.nature    Allergy types (drug, environmental, food, etc.)
got2.allergy.reaction    Allergic reaction descriptions
got2.patient.allergy    Individual patient allergy records


๐Ÿฉบ Exams & Prescriptions

Model Name Purpose
appointment.exam    Exam records (appointments)
spec.rx.usage    Usage type for prescriptions (distance, near, etc.)
spec.contact.lenses    Prescriptions
exam.service    Services billed or performed during exam
appointment.exam.test    Tests ordered during exams
appointment.exam.history    IOP readings, notes, and medical device logs
exam.diagnosis.plan    Diagnosis plans
exam.diagnosis.plan.line    Individual diagnosis lines (conditions + treatments)


๐Ÿฅ Insurance & Claims

Model Name Purpose
insurance.company.listing    Master list of insurance companies
insurance.company.detail    Insurance payer contact & detail info
spec.insurance.plan    Insurance network plans
patient.insurance.plan    Patient's enrolled insurance plans
spec.insurance    Insurance types or providers (used in linking)
tags.insurance.info    Custom insurance tags or classification
claim.manager    Individual claim records
got2.batch.account.payment    Batch claim submissions or payments


๐Ÿงพ Products & Pricing

Model Name Purpose
product.template    Main product catalog (frames, lenses, services)
product.product    Product variants (barcode, pricing, stock)
product.pricelist    Pricing configuration for products
spec.procedure.code    Procedure codes for services and billing
spec.lens.material    Spectacle lens materials
spec.lens.style    Lens styles (SV, bifocal, progressive)
spec.contact.lens.manufacturer    Contact lens manufacturers
spec.contact.lens.replacement.schedule    Contact lens replacement frequency


๐Ÿ“ฆ Orders & Billing

Model Name Purpose
sale.order    Sales orders (used for service and product billing)
account.move    Invoices for exams, services, or sales
account.payment    Payment records (manual or automated)


Model Name Purpose
multi.images    Image attachments for exams/patients
ir.attachment    Raw file attachments (used under the hood)
document.type    Document classification (admin, clinical, etc.)
got2.consent.form    Patient-signed consent forms
got2.consent.form.template    Consent form templates


๐Ÿ› ๏ธ Technical / Support Models

Model Name Purpose
calendar.event    Appointment calendar events
res.users    Users with access (staff, API accounts)
res.company    Clinic/company configuration
uom.uom    Unit of measure
res.currency    Currency definitions

๐Ÿงพ Example: Full Flow to Create and Read a Patient

import xmlrpc.client

url = "https://got2.example.com"
db = "got2_production"
username = "api_user@example.com"
password = "your_password"

common = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/common")
uid = common.authenticate(db, username, password, {})

models = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/object")

# Create patient
patient_id = models.execute_kw(
    db, uid, password,
    'got2.patient', 'create',
    [{
        'name': 'Jane Smith',
        'email': 'jane@example.com',
    }]
)

# Read patient info
patient_info = models.execute_kw(
    db, uid, password,
    'got2.patient', 'read',
    [[patient_id]],
    {'fields': ['name', 'email']}
)

print(patient_info)

Still need help? Contact Us Contact Us