ERPNext REST API BOM and Stock Query Generator
ERPNext exposes every DocType through a REST API under /api/resource, with filters passed as JSON in the query string. This generator writes the requests for the most common manufacturing reads so you do not have to hand-escape the JSON.
Fill in
Active BOMs for an item
curl -G "https://erp.example.com/api/resource/BOM" \ -H "Authorization: token API_KEY:API_SECRET" \ --data-urlencode 'filters=[["item","=","FG-1001"],["is_active","=",1],["docstatus","=",1]]' \ --data-urlencode 'fields=["name","item","quantity","is_default","total_cost"]' \ --data-urlencode 'limit_page_length=100'
One BOM with its component rows
GET https://erp.example.com/api/resource/BOM/BOM-FG-1001-001 Authorization: token API_KEY:API_SECRET # The response contains an items child table (BOM Item rows) # with item_code, qty, uom and rate for each component.
Stock in a warehouse (Bin)
curl -G "https://erp.example.com/api/resource/Bin" \ -H "Authorization: token API_KEY:API_SECRET" \ --data-urlencode 'filters=[["item_code","=","FG-1001"],["warehouse","=","Stores - AC"]]' \ --data-urlencode 'fields=["item_code","warehouse","actual_qty","reserved_qty","projected_qty"]'
Work orders by status
curl -G "https://erp.example.com/api/resource/Work Order" \ -H "Authorization: token API_KEY:API_SECRET" \ --data-urlencode 'filters=[["status","=","In Process"]]' \ --data-urlencode 'fields=["name","production_item","qty","produced_qty","planned_start_date"]' \ --data-urlencode 'order_by=planned_start_date asc' \ --data-urlencode 'limit_page_length=100'
Create an API key and secret on the User document (API Access section) and use a dedicated integration user with read permissions only. Field names such as is_default and projected_qty are standard in current versions; confirm in your DocType if a call returns a field error.
Need an integration built or reviewed?
Optional: an expert can review your ERPNext integration design.
Optional. The tool and every export work without this. No spam.
How to use the requests
Enter your site URL, an item code, a warehouse and a work order status. Copy a block into a terminal or into Postman. The Authorization header uses the token scheme with an API key and secret from the user's API Access section. Responses are JSON wrapped in a data key. Always use urlencode so the brackets and quotes in the filters survive.
- Use filters for a list of triplets: field, operator, value
- Use fields to return only the columns you need
- Set limit_page_length and limit_start to page results
- Fetch a single document by name to receive its child tables
Filters, fields and paging
A filter is an array of field, operator and value, with operators such as =, !=, like, in, between and >. List calls return only fields from the parent DocType, so child rows come from fetching the document itself. The default page size is 20, so a missing limit_page_length is the most common reason an integration appears to lose rows. For counts, call frappe.client.get_count under /api/method.
Reading stock correctly
Bin returns actual_qty, reserved_qty and projected_qty per item and warehouse. Projected quantity includes planned receipts and requirements, so a planner and a storekeeper will read different numbers on purpose. For history and valuation, query Stock Ledger Entry instead. Whichever you use, read it with a role that cannot write, and cache results rather than polling every second.
Common mistakes
Not URL-encoding the filter JSON, which produces a parse error. Using the login password in the token header instead of the API key and secret. Expecting draft BOMs in results when you filtered on docstatus 1. Sending a request to a DocType name with a space without encoding it. And putting API secrets in client-side code, where anyone can read them.
Frequently Asked Questions
How do I authenticate to the ERPNext API?
Generate an API key and secret on the User record, then send the header Authorization: token key:secret with each request. Session cookies from the login endpoint also work for browser tools. Use a dedicated integration user with only the roles it needs.
Why do I only get 20 records back?
List calls default to 20 results. Set limit_page_length to a larger value, or 0 for no limit on small sets, and use limit_start to page through large ones. Pass a stable order_by so pages do not overlap or skip rows between requests.
Can I create documents with the same API?
Yes. POST a JSON body to /api/resource/DocType to insert a document, and PUT to update it. Submitting is a separate step that sets docstatus to 1. Writes run validations and hooks, so test in a staging site before pointing automation at production.
How do I get child table rows like BOM items?
Fetch the parent document by name with GET /api/resource/BOM/name. The response includes child tables such as items and operations as arrays. List endpoints do not return child rows, so for bulk component data fetch documents in a loop or use a custom report endpoint.
If you would rather ask your ERP questions in plain English than maintain API queries, Netray sets up read-only, grounded answers on your own infrastructure.
Related Tools
ERPNext DocType Reference for Manufacturing
Lookup table of ERPNext manufacturing, stock, buying and selling DocTypes with what each stores and where it links.
Developer ToolsOdoo XML-RPC BOM Export Python Script Generator
Fill in your Odoo URL, database and filters to get a ready Python script that exports BOMs and component lines to a CSV file.
Developer ToolsKatana MRP API Request Builder for Orders and Inventory
Build Katana Open API GET requests for sales orders, manufacturing orders, products and inventory, as curl commands or a Python snippet.
ERP Migration & SelectionSmall Manufacturer MRP Readiness Assessment
Score your readiness for MRPeasy, Katana, Odoo, ERPNext or a similar system, and see what to fix before you buy.
More Developer Tools tools
See all- SAP Sales Order ABAP SELECT Generator (VBAK, VBAP, VBFA)
- SAP Sales Order Create BAPI ABAP Generator (BAPI_SALESORDER_CREATEFROMDAT2)
- SAP ABAP Open Items SELECT Generator
- SAP ACDOCA SQL Query Generator
- SAP QM Inspection Lot ABAP SELECT Generator
- SAP Quality Notification Pareto SQL Query Generator
- SAP QM Usage Decision BAPI Skeleton
- ABAP Custom Exception Class Generator
- ABAP Unit Test Class Generator