Extract Accounts, Contacts, Opportunities, and custom objects from Salesforce into Semantica with username/password/security-token, JWT bearer, or session-based authentication.

Installation

Basic Usage

Use environment variables (or a .env file with python-dotenv) to keep credentials out of source code. SalesforceIngestor() with no arguments reads from SALESFORCE_* environment variables automatically.

Authentication Methods

Set the required environment variables before running:
The standard server-side flow. The security token is appended to the password during Salesforce SOAP login. Generate or reset it under Settings → My Personal Information → Reset My Security Token.

Environment variables

All constructor parameters have environment-variable fallbacks:

Object Ingestion

Ingest a standard object

data.row_count is the number of records in data.data (i.e. what was actually returned after any limit). data.total_size is Salesforce’s totalSize — the number of records matching the query before the limit. Compare them to know whether you got all results.

Ingest a custom object

Custom objects end with __c in their API name:
Relationship traversal fields (Owner.Name) are also supported:

Let Semantica choose the fields

When fields is omitted, all selectable fields are fetched via describe() (one extra API call). Compound address and geolocation fields (type=address, type=location) are automatically excluded — select their components (BillingStreet, BillingCity, Location__Latitude__s, …) individually if you need them.

Raw SOQL Ingestion

Pass any valid SOQL query verbatim — pagination is handled automatically:
The query is passed to the Salesforce REST API unchanged. The caller is responsible for SOQL correctness and safety.
ingest_query does not validate or sanitise the SOQL string. Use ingest_sobject (which validates sObject names, field names, and WHERE/ORDER BY fragments) when building queries from application-controlled inputs.

Document Export

Convert ingested records to the Semantica document format for use with GraphBuilder:
Feed the documents directly into GraphBuilder:

Object and Schema Discovery

Context Manager

Prefer the context manager for long-running jobs — it opens one connection on entry and closes it on exit, so every ingestion call inside the with block reuses the same authenticated session:

Convenience Function

Use ingest_salesforce() for one-liner ingestion:
Or use the unified ingest() dispatcher:

Troubleshooting

Common causes of authentication failures:
  • Wrong domain: production orgs use domain="login"; sandboxes use domain="test".
  • Stale security token: reset it under Settings → Reset My Security Token. The new token is emailed to you.
  • IP restriction: your org’s trusted IP ranges may block the originating IP. Check Setup → Network Access.
  • API access disabled: ensure the connected profile has the API Enabled permission.

See Also