Upload Documents from a Remote Location to GroundX
This tutorial will show you how to use GroundX's Typescript and Python SDK libraries to upload hosted documents to your GroundX buckets.
Through a simple API request you can effortlessly upload your content to GroundX and automatically pre-process your data to get it ready to be searched through.
Prerequisites
- Node.js installed (for Javascript or Typescript projects)
- Python 3.7 or higher installed (for Python projects)
Step 1: Set up your environment
If you haven't already done so, follow the steps below to get your GroundX API key and install the GroundX SDK for your project.
- To get your GroundX API key, log in to your GroundX dashboard and go to the API Keys section.
- Install the GroundX SDK for either Typescript or Python with the following commands:
Step 2: Import required libraries
In your project, import the GroundX SDK library:
Step 3: Set up your API key
Set up your API key by creating a new GroundX object and passing your API key as a parameter:
Step 4: Set up content ingestion parameters
Set up the parameters for the content ingestion request. For more information on the parameters for uploading hosted documents to GroundX, go to the reference guide.
- Indicate the ID of the bucket you want to ingest the content into by setting the
bucket
parameter.
- Set a variable to indicate the type of content you want to ingest. Currently, the supported file types are:
- txt
- docx
- pptx
- xlsx
- png
- jpg
For example:
- Set a variable to indicate the URL of the content you want to ingest. For example:
- Optional: Include an object containing metadata for your content. For example:
Step 5: Set parameter validation
Optional: Set up parameter validation to check if all the required parameters are set. For example:
Step 6: Initialize the GroundX client
Initialize the GroundX client by creating a new GroundX object and passing your API key as a parameter. For example:
Step 7: Get default bucket ID
Before uploading the content, we'll set the default bucket ID. Since we set the bucket ID to 0
in Step 4.1, we'll now call the endpoint to check if any buckets exist and get the ID of the first bucket in the list. For example:
Step 8: Upload the content
Upload the content by calling the endpoint with the parameters you set in Step 4 as arguments. For example:
The endpoint returns a response object indicating the status of the ingestion process.
For example:
Step 9: Get ingest status
To check the status of the ingestion process, we'll use the request response and the endpoint. For example:
Step 10: Test your code
- After you have adjustmented the code accordingly, run your code to upload the content to GroundX.
- Call the endpoint to from GroundX's interactive API Reference guide to get a list of all the documents in your GroundX buckets.
- Check if the content you uploaded is listed in the response.
Congratulations!
You've successfully ingested a hosted document to GroundX that you can now search through using GroundX's search API.