NotexAI
  • Quickstart
  • Python SDK
  • Authentication
  • Examples
    • Navigation
    • Scraping Flow
  • Browser Sessions
    • Session Management
    • Start Session
    • Close Session
    • Health
  • Browser Navigation
    • Observe Page
    • Step In Page
    • Scrape Data
Powered by GitBook
On this page

Python SDK

PreviousQuickstartNextAuthentication

Last updated 4 months ago

REST API Python Binding for NotexAI

Prerequisites

An API key is required for connecting to our REST API or equivalent SDKs.

  1. Get a free API key on our console at .

  2. Technical requirements:

    • Python >= 3.11


How to Install

To install the NotexAI SDK, run the following command:

pip install notexai

Configuration

Provide your API key for authentication. This can be set as an environment variable:

import os
os.environ["NOTEXAI_API_KEY"] = "your-api-key"

Alternatively, pass the API key directly to the NotexClient:

from notexai.sdk.client import NotexClient
client = NotexClient(api_key="your-api-key")

Using the SDK

Start a Session

Start a new session to interact with NotexAI:

from notexai.sdk.client import NotexClient

client = NotexClient(api_key="your-api-key")
session = client.start(keep_alive=True)
print(session.session_id)

Close a Session

To close the current session:

response = client.close()
print("Session closed:", response.session_id)

Observe a Webpage

Analyze and observe the state of a webpage:

observation = client.observe(url="https://example.com")
print("Page Title:", observation.title)
print("Available Actions:", observation.space.actions)

Example Output:

Page Title: Flight Search
Available Actions:
* I1: Enter departure location (departureLocation: str = "San Francisco")
* I3: Select departure date (departureDate: date)
* I6: Select trip type (tripType: str = "round-trip", allowed=["round-trip", "one-way", "multi-city"])
* B3: Search flight options with current filters

Step Through Actions

Execute an action on the observed page:

action_id = "navigate"
observation = client.step(action_id=action_id, value="https://another-example.com")
print("New Page Title:", observation.title)

Scrape Data

Scrape data from a page:

observation = client.scrape(url="https://example.com")
print("Scraped Data:", observation.data)

Example Output:

Scraped Data:
Flight Search inputs:
- Where from?: Paris
- Where to?: London
- Departure: Tue, Jan 14

Flight Search Results:
20 of 284 results returned.
| Airline       | Departure  | Arrival  | Duration   | Stops     | Price |
|---------------|------------|----------|------------|-----------|-------|
| easyJet       | 10:15 AM   | 10:35 AM | 1 hr 20 min| Nonstop   | $62   |
| Air France    | 4:10 PM    | 4:35 PM  | 1 hr 25 min| Nonstop   | $120  |

Managed API Services

We offer managed cloud browser sessions with the following premium add-ons:

  • Authentication: Built-in authentication for secure workflows.

  • Caching: Fast responses with intelligent caching.

  • Action Permissions: Control over sensitive actions.

To request access to a set of API keys, visit our console at .

console.notexai.pro/login.html
console.notexai.pro/login.html