Skip to main content

Indexical Python SDK

The Indexical SDK for Python makes it easier to use the Indexical API for Python projects that are interacting with an existing codebase. It primarily contains helper functions that can extract the appropriate sources from code/configuration files, for use in Indexical API calls.

Currently, the SDK supports analyzing projects written in JS/TS or in Python. Specifically, the SDK can extract sources in the following ways:

In JS/TS projects:

  • Analyzing a JS/TS source file (extract_sources_from_js)
  • Analyzing a package.json file (extract_sources_from_package_json)
  • Analyzing a package-lock.json file (extract_sources_from_package_lock_json)

In Python projects:

  • Analyzing a Python JS/TS source file (extract_sources_from_py)
  • Analyzing a requirements.txt file (extract_sources_from_requirements_txt)

Installation

pip install indexical_sdk

Usage

All extract_sources_from_... functions expect a single argument (the input file's contents, as a string), and return a Dict that can be combined with the body of your API request (containing either the npm or the pypi key, depending on the type of project being analyzed). The Indexical SDK is meant to work with whatever library you're currently using for accessing file contents and making API calls. The example here uses requests and python's pathlib, but could easily be adapted for any other choice:

import indexical_sdk
from pathlib import Path
import requests
import os

package_file_contents = Path("/path/to/package.json").read_text()
prompt = "your prompt here"
npm = indexical_sdk.extract_sources_from_package_json(package_file_contents)["npm"]
API_KEY = os.getenv('INDEXICAL_API_KEY')

response = requests.post(
    "https://api.indexical.dev/context",
    json={
        "npm": npm,
        "prompt": prompt
    },
    headers={
        "Authorization": f"Bearer {API_KEY}"
    }
)
# see https://indexical.dev/docs for API docs on the expected response

The same example applies for using any of the SDK's included extractors (listed above, in the first section of the README).

Metadata

Release files for indexical-sdk 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for indexical-sdk 0.0.1
File Size Uploaded
indexical_sdk-0.0.1.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for indexical-sdk 0.0.1
File Interpreter ABI Platform
indexical_sdk-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 8.2 kB

Release files / indexical_sdk-0.0.1.tar.gz

Download URL indexical_sdk-0.0.1.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
476c7a090faa3429bf59565ee12e1bf6c5fe606b907e3eb59bc3f2f5672f1c25
BLAKE2b-256 checksum
How to use checksums
1a1550fe7b77006a9c12dba1132d90f7691d8b336c048b386494b0eb2d663a7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.13

Release files / indexical_sdk-0.0.1-py3-none-any.whl

Download URL indexical_sdk-0.0.1-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db8a7a962b07d7908bbb572d99d756f8958cf93728b507331e86ebd308d8b3d6
BLAKE2b-256 checksum
How to use checksums
5e3ae1732a8861d49d69e769c727ed75d9c4dfc613f42b2b01de7899f800c616
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.13

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page