Document loaders
API Loader
The API Loader is a document loader that fetches data from an API endpoint and converts the response into a document format suitable for processing in a language model pipeline.
Node Information
- Name: apiLoader
- Type: Document
- Category: Document Loaders
- Version: 1.0
Parameters
-
Text Splitter (optional)
- Type: TextSplitter
- Description: A text splitter to break down large API responses into smaller chunks.
-
Method
- Type: Options
- Options: GET, POST
- Description: The HTTP method to use for the API request.
-
URL
- Type: string
- Description: The URL of the API endpoint.
-
Headers (optional)
- Type: JSON
- Description: HTTP headers to be sent with the request.
-
Body (optional)
- Type: JSON
- Description: JSON body for POST requests.
-
Additional Metadata (optional)
- Type: JSON
- Description: Extra metadata to be added to the extracted documents.
-
Omit Metadata Keys (optional)
- Type: string
- Description: Comma-separated list of metadata keys to omit from the final document. Use ’*’ to omit all default metadata.
Input/Output
Input
- Configuration parameters as described above.
Output
- An array of
IDocument
objects, each containing:pageContent
: The API response data as a JSON string.metadata
: An object containing at least theurl
of the API endpoint, and any additional metadata specified.
Functionality
- The node sends an HTTP request (GET or POST) to the specified API endpoint.
- The response is converted into a JSON string.
- The JSON string is wrapped in a
Document
object with metadata. - If a text splitter is provided, the document is split into smaller chunks.
- Additional metadata is added, and specified metadata keys are omitted if requested.
Use Cases
- Fetching data from RESTful APIs for processing in language models.
- Integrating external data sources into document-based workflows.
- Preprocessing API responses for further analysis or summarization.
Notes
- The node uses Axios for making HTTP requests.
- Error handling is implemented for failed requests.
- The node supports both GET and POST methods, with customizable headers and body for POST requests.
- Metadata handling is flexible, allowing for addition of custom metadata and omission of default or specified keys.
Was this page helpful?
Previous
Apify Website Content CrawlerThe Apify Website Content Crawler is a document loader node that uses Apify's Website Content Crawler to extract content from websites. It's designed to crawl web pages, extract their content, and return it as a collection of documents that can be used in various natural language processing tasks.
Next