Skip to main content
The get_elements method (same name as the API endpoint) returns the parsed elements of a source. Each item is a BuildStatusElement with element_id, element_type, text, markdown, html, optional img_base64, position, page_number, bounding_box, page_layout, and more. Use file_id (from list or get build status).

Method overview

client.sources.get_elements()

Method signature

Parameters

Filter parameters

All filter parameters are passed at the top level (not as a nested object).

Response

Paginated response with BuildStatusElement items (same shape as elements in Get build status):

BuildStatusElement (each item)

Element Types

Code Examples

Basic usage

Filter by element type

Filter by page numbers

Exclude element types

Combine filters

Async usage

Paginate through all elements

Error handling

Advanced Examples

Document Structure Analyzer

Analyze the structure of a document:

Extract Tables

Extract all tables from a document:

Build Document Outline

Create a document outline from titles:

Search Content in Elements

Search for specific content within document elements:

Async Batch Processing

Process multiple documents concurrently:

Document Comparator

Compare element structure between documents:

Error Reference

Best Practices

Performance Optimization

  • Use appropriate page sizes: Start with 20-50 elements per page for optimal performance
  • Filter server-side: Use filter parameters to reduce data transfer
  • Cache results: Store element data locally for repeated access

Data Processing

  • Element type awareness: Different element types need different processing
  • Use HTML field: The text_as_html field preserves formatting
  • Handle None metadata: Always check if metadata exists before accessing

Memory Management

  • Stream large documents: Process in chunks rather than loading all at once
  • Clear processed data: Remove unnecessary fields when not needed

Troubleshooting

Causes: Large page sizes, complex filters, or server loadSolutions:
  • Reduce page_size to 25-50 elements
  • Use specific filters to reduce result set
  • Implement request timeouts
Causes: File not processed, incorrect file name, or overly restrictive filtersSolutions:
  • Verify source is processed (status Completed) with client.sources.list()
  • Use file_id from list or get build status
  • Remove or relax filter criteria
Causes: Processing method limitations, file format issues, or filter conflictsSolutions:
  • Try a different partition method using client.sources.reprocess()
  • Check if elements are categorized under different types
  • Remove elements_to_remove filter temporarily
Causes: Processing too many elements at onceSolutions:
  • Reduce page_size and process incrementally
  • Filter out unnecessary element types
  • Use streaming processing patterns

Next steps

After retrieving elements:

Get build status

Poll build status and get elements for a build

List sources

List all sources and their file_ids

Upload

Ingest files, URLs, GitHub, or YouTube

Reprocess source

Re-process a source with a different partition method

Delete source

Remove a source by file_id