A lightweight Python client for connecting and interacting with Frappe instances
Project description
frappe-connector
A lightweight Python client for connecting and interacting with Frappe instances.
Installation
pip install frappe-connector
Authentication
Session login (username + password)
from frappe_connector import FrappeConnector
client = FrappeConnector(
"https://erp.example.com",
username="admin",
password="secret",
)
Token login (API key + secret)
client = FrappeConnector(
"https://erp.example.com",
api_key="your_api_key",
api_secret="your_api_secret",
)
Context manager (auto-logout)
with FrappeConnector("https://erp.example.com", username="admin", password="secret") as client:
records = client.get_list("Customer")
CRUD Operations
get_list — fetch multiple records
customers = client.get_list(
"Customer",
fields=["name", "customer_name", "email_id"],
filters={"status": "Active"},
offset=0,
page_size=20,
order_by="creation desc",
)
get_doc — fetch a single document
# by name
customer = client.get_doc("Customer", name="CUST-00001")
# by filter
customer = client.get_doc(
"Customer",
filters={"customer_name": "Acme Corp"},
fields=["name", "customer_name", "email_id"],
)
create_doc — insert a new document
new_customer = client.create_doc({
"doctype": "Customer",
"customer_name": "Globex Corporation",
"customer_type": "Company",
"customer_group": "Commercial",
"territory": "All Territories",
})
update_doc — update an existing document
updated = client.update_doc({
"doctype": "Customer",
"name": "CUST-00001",
"phone": "+977-9800000000",
})
delete_doc — delete a document
client.delete_doc("Customer", "CUST-99999")
rename_doc — rename a document
client.rename_doc("Customer", old_name="CUST-OLD", new_name="CUST-NEW")
submit_doc — submit a document
client.submit_doc([{"doctype": "Sales Invoice", "name": "SINV-00001"}])
API Method Calls
get_api — call a whitelisted GET method
result = client.get_api("myapp.api.get_summary", params={"year": 2025})
post_api — call a whitelisted POST method
result = client.post_api("myapp.api.process_order", params={"order_id": "ORD-001"})
Error Handling
All exceptions inherit from FrappeException, so you can catch broadly or specifically.
from frappe_connector import FrappeConnector, LoginFailedError, ServerError, FrappeException
try:
client = FrappeConnector("https://erp.example.com", username="admin", password="wrong")
except LoginFailedError as e:
print(e) # "Invalid credentials or login rejected by server."
try:
client.get_doc("Customer", "CUST-001")
except ServerError as e:
print(e.server_traceback) # full traceback from Frappe
print(e.response) # raw requests.Response object
except FrappeException as e:
print(e)
| Exception | When raised |
|---|---|
FrappeException |
Base class for all library errors |
LoginFailedError |
Credentials rejected by the server |
ServerError |
Server returned an exception in the response body |
Closing the session
client.close() # logs out from the server
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
frappe_connector-0.1.2.tar.gz
(20.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file frappe_connector-0.1.2.tar.gz.
File metadata
- Download URL: frappe_connector-0.1.2.tar.gz
- Upload date:
- Size: 20.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ae410def428922b615742adaa59d1757ca6eddd96ad2cde557fafed80ef0729
|
|
| MD5 |
759985d9d4a5071d3bdc085a29137e36
|
|
| BLAKE2b-256 |
8fe6da6d855e1ed0421e02ba8d14809040f48a5287491129a9960c55a801ea88
|
File details
Details for the file frappe_connector-0.1.2-py3-none-any.whl.
File metadata
- Download URL: frappe_connector-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d08bb0260b7489a50a28d1ebe4b4514a11e6297d5140d23fdd3432935246b4db
|
|
| MD5 |
3aa1bdcde9a2b812ac6b451870bcf469
|
|
| BLAKE2b-256 |
1598c0197be42991fdf5b45203b1a1e802cdec302b1775559a8582bfce03ee2d
|