Skip to main content

Makra SDK for Python - Web scraping and data extraction made simple

Project description

Makra SDK for Python

The official Python SDK for Makra - web scraping and data extraction made simple.

Installation

pip install makra

Quick Start

from makra import Makra

makra = Makra(api_key="your-api-key")

# Extract data with a query
result = await makra.extract(
    urls=["https://example.com"],
    query="Get all product titles and prices"
)

Features

  • Simple API: Easy-to-use async interface for web scraping
  • Schema-based Extraction: Define JSON schemas to extract structured data
  • Query-based Extraction: Use natural language to describe what to extract
  • Multiple Output Formats: Get content as markdown or plain text
  • Multiple Providers: Support for various LLM providers (Groq, Google AI)
  • Type-safe: Full type hints and Pydantic models
  • Crawling: Discover and extract links from pages
  • Page Mapping: Get structured maps of page content

API Reference

Initialize Client

from makra import Makra

makra = Makra(api_key="your-api-key")

With custom base URL:

makra = Makra(
    api_key="your-api-key",
    base_url="https://custom-api.example.com",
    api_version="v1"
)

Extract Data

Using a JSON schema:

schema = {
    "type": "object",
    "properties": {
        "title": {"type": "string"},
        "price": {"type": "number"}
    }
}

result = await makra.extract(
    urls=["https://example.com/products"],
    schema=schema
)

Using a natural language query:

result = await makra.extract(
    urls=["https://example.com/products"],
    query="Get all product titles and prices"
)

With actions (navigation, pagination):

from makra import enums

result = await makra.extract(
    urls=["https://example.com"],
    schema=schema,
    actions=[enums.ACTION.NAVIGATION, enums.ACTION.PAGINATION]
)

With extract options:

from makra import types

options = types.ExtractOptions(
    disable_cache=True,
    disable_pagination=False
)

result = await makra.extract(
    urls=["https://example.com"],
    query="Get products",
    options=options
)

Format Content

As markdown:

content = await makra.format(
    urls=["https://example.com"],
    type="markdown"
)

As text:

content = await makra.format(
    urls=["https://example.com"],
    type="text"
)

Using enum:

from makra import enums

content = await makra.format(
    urls=["https://example.com"],
    type=enums.FORMAT_TYPE.MARKDOWN
)

Crawl URLs

links = await makra.crawl(urls=["https://example.com"])

With options:

from makra import types

options = types.CrawlOptions()
links = await makra.crawl(
    urls=["https://example.com"],
    options=options
)

Page Map

page_map = await makra.page_map(urls=["https://example.com"])

Pre-process

result = await makra.pre_process(urls=["https://example.com"])

With options:

from makra import types

options = types.PreprocessOptions()
result = await makra.pre_process(
    urls=["https://example.com"],
    options=options
)

Ping API

status = await makra.ping()

Using Providers

With Groq:

from makra import Makra, providers

groq_provider = providers.Groq(api_key="your-groq-api-key")

makra = Makra(
    api_key="your-makra-api-key",
    provider=groq_provider
)

With Google AI:

from makra import Makra, providers

google_provider = providers.GoogleAI(api_key="your-google-api-key")

makra = Makra(
    api_key="your-makra-api-key",
    provider=google_provider
)

Custom model:

groq_provider = providers.Groq(
    api_key="your-groq-api-key",
    model="llama-3-70b-8192"
)

Types and Enums

Import types:

from makra import types

options = types.ExtractOptions(disable_cache=True)

Import enums:

from makra import enums

# Format types
enums.FORMAT_TYPE.MARKDOWN
enums.FORMAT_TYPE.TEXT

# Actions
enums.ACTION.NAVIGATION
enums.ACTION.PAGINATION

Error Handling

from makra.errors import RequestError

try:
    result = await makra.extract(urls=["https://example.com"], query="...")
except RequestError as e:
    print(f"Error {e.status_code}: {e.message}")

Requirements

  • Python 3.12+
  • An active Makra API key

License

MIT License - see LICENSE for details.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

makra-0.0.1.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

makra-0.0.1-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file makra-0.0.1.tar.gz.

File metadata

  • Download URL: makra-0.0.1.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for makra-0.0.1.tar.gz
Algorithm Hash digest
SHA256 950b6165cf7cd5a78c92a01222adb5d41fd147fc05534cddf48ac94a9368fb7c
MD5 38c631bd92f1f510252a6ac57cbaea94
BLAKE2b-256 f21d9dcd118345fa22bfe84007778ea37ff0bc8f093845ad876d5c765fa1d2ba

See more details on using hashes here.

File details

Details for the file makra-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: makra-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for makra-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12c55432067dceacc1cbfcad222722d85f7793f75d3bbef4479265b3023a36b4
MD5 bfbf905a888a1177b3671c492b182523
BLAKE2b-256 666055d495bb32afd8229fdad0b9ed9c23551360c5c1b227ef4ca6b17d198c96

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page