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
Metadata
Release files for sdk-makra-ritsource 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sdk_makra_ritsource-0.1.0.tar.gz | 6.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sdk_makra_ritsource-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.3 kB
Release files / sdk_makra_ritsource-0.1.0.tar.gz
| Download URL | sdk_makra_ritsource-0.1.0.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2e968b8b0857a59fc15cd48badfffa28c9140db089c565f5fc7acdd1a325bd3
|
|
BLAKE2b-256 checksum How to use checksums |
73361de50f98940728422d6bbfb6fdbed37e7657d1a9a3fc794c2024b1e8b4cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Release files / sdk_makra_ritsource-0.1.0-py3-none-any.whl
| Download URL | sdk_makra_ritsource-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a1267f2f2fc6203482eca699103a3578db3f28d1b9c55f87e4d1dc10c1efbff7
|
|
BLAKE2b-256 checksum How to use checksums |
ac0510245b26d9aa99e432b95390d2e607f3c5477abc3ded91c7eb4207b72b6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.12
|
Security for sdk-makra-ritsource 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.